Decompiled source of NeAi PEAK Toolbox v3.3.0

PEAKTrainer.dll

Decompiled 6 days ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace PEAKTrainer;

[BepInPlugin("dsh.peak.trainer", "Ne Ai * PEAK v3.3", "3.3.0")]
public class Plugin : BaseUnityPlugin
{
	public static bool NoStaminaDrain = false;

	public static bool NoHunger = false;

	private static Plugin _inst;

	private Harmony _h;

	private bool _showGui = false;

	private Rect _win = new Rect(90f, 70f, 560f, 720f);

	private int _tab = 0;

	private string _search = "";

	private Vector2 _scrollItems = new Vector2(0f, 0f);

	private Vector2 _scrollTeam = new Vector2(0f, 0f);

	private string _status = "就绪";

	private string _selected = "";

	private int _cat = 0;

	private int _warpSrc = 0;

	private int _warpDst = 1;

	private bool _reviveAtHost = true;

	private static readonly string[] Cats = new string[11]
	{
		"全部", "食物", "医疗", "照明", "绳索", "装备", "投掷", "工具", "护符", "棋子",
		"其他"
	};

	private Font _cjk;

	private bool _stylesReady;

	private GUIStyle _stWindow;

	private GUIStyle _stTitle;

	private GUIStyle _stLabel;

	private GUIStyle _stSmall;

	private GUIStyle _stBtn;

	private GUIStyle _stBtnOn;

	private GUIStyle _stItem;

	private GUIStyle _stItemSel;

	private GUIStyle _stTab;

	private GUIStyle _stTabOn;

	private GUIStyle _stHeader;

	private GUIStyle _stStatus;

	private GUIStyle _stField;

	private GUIStyle _stPick;

	private Texture2D _texBg;

	private Texture2D _texPanel;

	private Texture2D _texBtn;

	private Texture2D _texBtnHover;

	private Texture2D _texBtnOn;

	private Texture2D _texAccent;

	private Texture2D _texItemSel;

	private readonly List<string> _names = new List<string>();

	private readonly List<string> _filtered = new List<string>();

	private bool _loaded;

	private static readonly string[][] Table = new string[197][]
	{
		new string[3] { "Airplane Food", "飞机餐", "食物" },
		new string[3] { "AloeVera", "芦荟", "医疗" },
		new string[3] { "Amulet_Clone", "护符·复制", "护符" },
		new string[3] { "Amulet_Healing", "护符·治疗", "护符" },
		new string[3] { "Amulet_InfiniteStamina", "护符·无限体力", "护符" },
		new string[3] { "Amulet_SuperJump", "护符·超级跳跃", "护符" },
		new string[3] { "AncientIdol", "远古神像", "工具" },
		new string[3] { "Antidote", "解毒剂", "医疗" },
		new string[3] { "Anti-Rope Spool", "反绳索卷", "绳索" },
		new string[3] { "AntiZooka", "反火箭筒", "投掷" },
		new string[3] { "Apple Berry Green", "绿苹果浆果", "食物" },
		new string[3] { "Apple Berry Red", "红苹果浆果", "食物" },
		new string[3] { "Apple Berry Yellow", "黄苹果浆果", "食物" },
		new string[3] { "Backpack", "背包", "装备" },
		new string[3] { "Balloon", "气球", "投掷" },
		new string[3] { "BalloonBunch", "气球束", "投掷" },
		new string[3] { "Bandages", "绷带", "医疗" },
		new string[3] { "BaseConstructable Variant", "建造体", "其他" },
		new string[3] { "BaseObject", "基础物件", "其他" },
		new string[3] { "Basketball", "篮球", "投掷" },
		new string[3] { "Beehive", "蜂巢", "其他" },
		new string[3] { "Berrynana Blue", "蓝香蕉莓", "食物" },
		new string[3] { "Berrynana Brown", "褐香蕉莓", "食物" },
		new string[3] { "Berrynana Peel Blue Variant", "蓝香蕉莓皮", "其他" },
		new string[3] { "Berrynana Peel Brown Variant", "褐香蕉莓皮", "其他" },
		new string[3] { "Berrynana Peel Pink Variant", "粉香蕉莓皮", "其他" },
		new string[3] { "Berrynana Peel Yellow", "黄香蕉莓皮", "其他" },
		new string[3] { "Berrynana Pink", "粉香蕉莓", "食物" },
		new string[3] { "Berrynana Yellow", "黄香蕉莓", "食物" },
		new string[3] { "BingBong", "铜锣", "工具" },
		new string[3] { "BingBong_Prop Variant", "铜锣(道具版)", "其他" },
		new string[3] { "Binoculars", "望远镜", "装备" },
		new string[3] { "Binoculars_Prop", "望远镜(道具版)", "其他" },
		new string[3] { "BookOfBones", "骸骨之书", "工具" },
		new string[3] { "BounceShroom", "弹跳菇", "食物" },
		new string[3] { "Bugfix", "小虫", "其他" },
		new string[3] { "Bugle", "号角", "工具" },
		new string[3] { "Bugle_Magic", "魔法号角", "工具" },
		new string[3] { "Bugle_Prop Variant", "号角(道具版)", "其他" },
		new string[3] { "Bugle_Scoutmaster Variant", "童军大师号角", "工具" },
		new string[3] { "C_Bishop B", "棋子·象(黑)", "棋子" },
		new string[3] { "C_Bishop W", "棋子·象(白)", "棋子" },
		new string[3] { "C_Bishop_f", "棋子·象(女)", "棋子" },
		new string[3] { "C_Bishop_f Variant", "棋子·象(女)", "棋子" },
		new string[3] { "C_Bishop_m", "棋子·象(男)", "棋子" },
		new string[3] { "C_Bishop_m Variant", "棋子·象(男)", "棋子" },
		new string[3] { "C_King", "棋子·王", "棋子" },
		new string[3] { "C_King B", "棋子·王(黑)", "棋子" },
		new string[3] { "C_King Variant", "棋子·王", "棋子" },
		new string[3] { "C_King W", "棋子·王(白)", "棋子" },
		new string[3] { "C_Knight", "棋子·马", "棋子" },
		new string[3] { "C_Knight B", "棋子·马(黑)", "棋子" },
		new string[3] { "C_Knight Variant", "棋子·马", "棋子" },
		new string[3] { "C_Knight W", "棋子·马(白)", "棋子" },
		new string[3] { "C_Pawn B", "棋子·兵(黑)", "棋子" },
		new string[3] { "C_Pawn W", "棋子·兵(白)", "棋子" },
		new string[3] { "C_Pawn_f", "棋子·兵(女)", "棋子" },
		new string[3] { "C_Pawn_f Variant", "棋子·兵(女)", "棋子" },
		new string[3] { "C_Pawn_m", "棋子·兵(男)", "棋子" },
		new string[3] { "C_Pawn_m Variant", "棋子·兵(男)", "棋子" },
		new string[3] { "C_Queen", "棋子·后", "棋子" },
		new string[3] { "C_Queen B", "棋子·后(黑)", "棋子" },
		new string[3] { "C_Queen Variant", "棋子·后", "棋子" },
		new string[3] { "C_Queen W", "棋子·后(白)", "棋子" },
		new string[3] { "C_Rook B", "棋子·车(黑)", "棋子" },
		new string[3] { "C_Rook W", "棋子·车(白)", "棋子" },
		new string[3] { "C_Rook_f", "棋子·车(女)", "棋子" },
		new string[3] { "C_Rook_f Variant", "棋子·车(女)", "棋子" },
		new string[3] { "C_Rook_m", "棋子·车(男)", "棋子" },
		new string[3] { "C_Rook_m Variant", "棋子·车(男)", "棋子" },
		new string[3] { "CactusBall", "仙人球", "投掷" },
		new string[3] { "Candle", "蜡烛", "照明" },
		new string[3] { "ChainShooter", "链条发射器", "绳索" },
		new string[3] { "Cheat Compass", "作弊罗盘", "工具" },
		new string[3] { "Cheat Compass 1", "作弊罗盘 2", "工具" },
		new string[3] { "ClimbingChalk", "攀岩粉", "医疗" },
		new string[3] { "ClimbingSpike", "攀爬钉", "绳索" },
		new string[3] { "CloudFungus", "云菌", "食物" },
		new string[3] { "Clusterberry Black", "黑串珠浆果", "食物" },
		new string[3] { "Clusterberry Red", "红串珠浆果", "食物" },
		new string[3] { "Clusterberry Yellow", "黄串珠浆果", "食物" },
		new string[3] { "Clusterberry_UNUSED", "串珠浆果(未用)", "其他" },
		new string[3] { "Compass", "指南针", "工具" },
		new string[3] { "Cure-All", "万能药", "医疗" },
		new string[3] { "Cursed Skull", "诅咒头骨", "工具" },
		new string[3] { "Dynamite", "炸药", "投掷" },
		new string[3] { "EarlyWorm", "早起的虫", "食物" },
		new string[3] { "Egg", "蛋", "食物" },
		new string[3] { "EggRaven", "乌鸦蛋", "食物" },
		new string[3] { "EggTurkey", "火鸡蛋", "食物" },
		new string[3] { "Energy Drink", "能量饮料", "食物" },
		new string[3] { "Fannypack", "腰包", "装备" },
		new string[3] { "FireWood", "木柴", "照明" },
		new string[3] { "FirstAidKit", "急救包", "医疗" },
		new string[3] { "Flag_Plantable_Checkpoint", "检查点旗帜", "工具" },
		new string[3] { "Flare", "信号弹", "照明" },
		new string[3] { "FortifiedMilk", "强化牛奶", "食物" },
		new string[3] { "Frisbee", "飞盘", "投掷" },
		new string[3] { "Frog", "青蛙", "食物" },
		new string[3] { "FrogLegs", "蛙腿", "食物" },
		new string[3] { "Glider", "滑翔伞", "装备" },
		new string[3] { "Glizzy", "热狗", "食物" },
		new string[3] { "Glizzy_CattailVariant", "热狗(香蒲)", "食物" },
		new string[3] { "Granola Bar", "燕麦棒", "食物" },
		new string[3] { "Guidebook", "指南手册", "工具" },
		new string[3] { "GuidebookPage", "指南书页", "工具" },
		new string[3] { "GuidebookPage_0_Intro", "指南书页·序", "工具" },
		new string[3] { "GuidebookPage_1_Mushrooms", "指南书页·蘑菇", "工具" },
		new string[3] { "GuidebookPage_2_Campfire", "指南书页·篝火", "工具" },
		new string[3] { "GuidebookPage_3_Revival", "指南书页·复活", "工具" },
		new string[3] { "GuidebookPage_4_Poison", "指南书页·中毒", "工具" },
		new string[3] { "GuidebookPage_5_Zombies", "指南书页·丧尸", "工具" },
		new string[3] { "GuidebookPage_6_BodyHeat", "指南书页·体温", "工具" },
		new string[3] { "GuidebookPage_7_BurningSun", "指南书页·灼日", "工具" },
		new string[3] { "GuidebookPage_8_Magma", "指南书页·岩浆", "工具" },
		new string[3] { "GuidebookPage_9_Gloom", "指南书页·幽暗", "工具" },
		new string[3] { "GuidebookPage_10_Sleepy", "指南书页·困倦", "工具" },
		new string[3] { "GuidebookPage_11_Awake", "指南书页·清醒", "工具" },
		new string[3] { "GuidebookPage_12_Crashout", "指南书页·崩溃", "工具" },
		new string[3] { "GuidebookPage_13_FirstTeams", "指南书页·先遣队", "工具" },
		new string[3] { "GuidebookPageScroll Variant", "书页卷轴", "其他" },
		new string[3] { "HealingDart Variant", "治疗针", "医疗" },
		new string[3] { "HealingPuffShroom", "治疗粉菇", "医疗" },
		new string[3] { "Heat Pack", "暖宝宝", "医疗" },
		new string[3] { "Item_Coconut", "椰子", "食物" },
		new string[3] { "Item_Coconut_half", "半个椰子", "食物" },
		new string[3] { "Item_Honeycomb", "蜂巢块", "食物" },
		new string[3] { "Jetpack", "喷气背包", "装备" },
		new string[3] { "Kingberry Green", "绿王浆果", "食物" },
		new string[3] { "Kingberry Purple", "紫王浆果", "食物" },
		new string[3] { "Kingberry Yellow", "黄王浆果", "食物" },
		new string[3] { "Lantern", "灯笼", "照明" },
		new string[3] { "Lantern_Faerie", "精灵灯笼", "照明" },
		new string[3] { "Lollipop", "棒棒糖", "食物" },
		new string[3] { "Lollipop_Prop", "棒棒糖(道具版)", "其他" },
		new string[3] { "MagicBean", "魔豆", "工具" },
		new string[3] { "Mandrake", "曼德拉草", "食物" },
		new string[3] { "Mandrake_Hidden", "曼德拉草(隐藏)", "其他" },
		new string[3] { "Marshmallow", "棉花糖", "食物" },
		new string[3] { "MedicinalRoot", "药根", "医疗" },
		new string[3] { "Megaphone", "扩音器", "工具" },
		new string[3] { "Mushroom Chubby", "胖蘑菇", "食物" },
		new string[3] { "Mushroom Cluster", "簇蘑菇", "食物" },
		new string[3] { "Mushroom Cluster Poison", "簇蘑菇(毒)", "食物" },
		new string[3] { "Mushroom Glow", "发光蘑菇", "食物" },
		new string[3] { "Mushroom Lace", "蕾丝蘑菇", "食物" },
		new string[3] { "Mushroom Lace Poison", "蕾丝蘑菇(毒)", "食物" },
		new string[3] { "Mushroom Normie", "普通蘑菇", "食物" },
		new string[3] { "Mushroom Normie Poison", "普通蘑菇(毒)", "食物" },
		new string[3] { "Napberry", "睡眠莓", "食物" },
		new string[3] { "NestEgg", "巢蛋", "其他" },
		new string[3] { "NestEgg_Raven", "乌鸦巢蛋", "其他" },
		new string[3] { "PandorasBox", "潘多拉魔盒", "工具" },
		new string[3] { "Parachute", "降落伞", "装备" },
		new string[3] { "Parasol", "阳伞", "装备" },
		new string[3] { "Parasol_Roots Variant", "阳伞(根须)", "其他" },
		new string[3] { "Passport", "护照", "工具" },
		new string[3] { "Pepper Berry", "辣椒浆果", "食物" },
		new string[3] { "Pirate Compass", "海盗罗盘", "工具" },
		new string[3] { "PortableStovetopItem", "便携炉", "工具" },
		new string[3] { "Prickleberry_Gold", "金刺莓", "食物" },
		new string[3] { "Prickleberry_Red", "红刺莓", "食物" },
		new string[3] { "RescueHook", "救援钩", "绳索" },
		new string[3] { "RescueHook_Infinite", "救援钩(无限)", "绳索" },
		new string[3] { "RitualDagger", "仪式匕首", "工具" },
		new string[3] { "Rocketpack", "火箭背包", "装备" },
		new string[3] { "RopeShooter", "绳索发射器", "绳索" },
		new string[3] { "RopeShooterAnti", "反绳索发射器", "绳索" },
		new string[3] { "RopeSpool", "绳卷", "绳索" },
		new string[3] { "Scorpion", "蝎子", "食物" },
		new string[3] { "ScoutCannonItem", "童军大炮", "工具" },
		new string[3] { "ScoutCookies", "童军饼干", "食物" },
		new string[3] { "ScoutCookies_Vanilla", "香草童军饼干", "食物" },
		new string[3] { "ScoutEffigy", "童军人偶", "工具" },
		new string[3] { "ScoutmasterSoul", "童军大师之魂", "工具" },
		new string[3] { "ScoutsHonor", "童军荣誉", "工具" },
		new string[3] { "ShelfShroom", "层菇", "食物" },
		new string[3] { "Shell Big", "大贝壳", "投掷" },
		new string[3] { "Shroomberry_Blue", "蓝菇莓", "食物" },
		new string[3] { "Shroomberry_Green", "绿菇莓", "食物" },
		new string[3] { "Shroomberry_Purple", "紫菇莓", "食物" },
		new string[3] { "Shroomberry_Red", "红菇莓", "食物" },
		new string[3] { "Shroomberry_Yellow", "黄菇莓", "食物" },
		new string[3] { "Skull", "头骨", "工具" },
		new string[3] { "Snowball", "雪球", "投掷" },
		new string[3] { "Sports Drink", "运动饮料", "食物" },
		new string[3] { "Stone", "石头", "投掷" },
		new string[3] { "Strange Gem", "奇异宝石", "工具" },
		new string[3] { "Sunscreen", "防晒霜", "医疗" },
		new string[3] { "TestConstructable Variant", "测试建造体", "其他" },
		new string[3] { "Torch", "火把", "照明" },
		new string[3] { "TrailMix", "什锦果仁", "食物" },
		new string[3] { "Warp Compass", "传送罗盘", "工具" },
		new string[3] { "WarpFungus", "传送菌", "食物" },
		new string[3] { "Warpsketball", "传送篮球", "投掷" },
		new string[3] { "Winterberry Orange", "橙冬莓", "食物" },
		new string[3] { "Winterberry Yellow", "黄冬莓", "食物" }
	};

	private static Dictionary<string, string> _cnMap;

	private static Dictionary<string, string> _catMap;

	private static object _mpEntry;

	private static PropertyInfo _mpValueProp;

	public static void Log(string s)
	{
		if ((Object)(object)_inst != (Object)null)
		{
			((BaseUnityPlugin)_inst).Logger.LogInfo((object)s);
		}
		else
		{
			Debug.Log((object)("[PEAKTrainer] " + s));
		}
	}

	public static void LogWarn(string s)
	{
		if ((Object)(object)_inst != (Object)null)
		{
			((BaseUnityPlugin)_inst).Logger.LogWarning((object)s);
		}
		else
		{
			Debug.LogWarning((object)("[PEAKTrainer] " + s));
		}
	}

	private void Awake()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		_inst = this;
		_h = new Harmony("dsh.peak.trainer");
		try
		{
			_h.PatchAll();
			Log("harmony patches applied.");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("[PEAKTrainer] patch failed: " + ex));
		}
		try
		{
			_cjk = Font.CreateDynamicFontFromOSFont(new string[5] { "Microsoft YaHei UI", "Microsoft YaHei", "SimHei", "SimSun", "Arial" }, 15);
		}
		catch
		{
		}
		Log("Ne Ai * PEAK v3.3 loaded. F11 = panel");
	}

	private void Update()
	{
		if (Input.GetKeyDown((KeyCode)292))
		{
			ToggleGui();
		}
		if (!NoStaminaDrain || !Character.localCharacterExists)
		{
			return;
		}
		Character localCharacter = Character.localCharacter;
		if (!((Object)(object)localCharacter == (Object)null) && !((Object)(object)localCharacter.data == (Object)null))
		{
			float totalStamina = localCharacter.GetTotalStamina();
			if (localCharacter.data.currentStamina < totalStamina)
			{
				localCharacter.data.currentStamina = totalStamina;
			}
		}
	}

	private void ToggleGui()
	{
		_showGui = !_showGui;
		Cursor.visible = _showGui;
		Cursor.lockState = (CursorLockMode)(!_showGui);
		if (_showGui && !_loaded)
		{
			ReloadItemList();
		}
	}

	private void ReloadItemList()
	{
		_names.Clear();
		try
		{
			Item[] array = Resources.LoadAll<Item>("0_Items");
			if (array != null)
			{
				for (int i = 0; i < array.Length; i++)
				{
					if ((Object)(object)array[i] != (Object)null)
					{
						AddName(((Object)array[i]).name);
					}
				}
			}
		}
		catch (Exception ex)
		{
			LogWarn("Resources.LoadAll: " + ex.Message);
		}
		if (_names.Count == 0)
		{
			try
			{
				Item[] array2 = Resources.FindObjectsOfTypeAll<Item>();
				if (array2 != null)
				{
					for (int i = 0; i < array2.Length; i++)
					{
						if (!((Object)(object)array2[i] == (Object)null))
						{
							string text = ((Object)array2[i]).name;
							if (text.EndsWith("(Clone)"))
							{
								text = text.Substring(0, text.Length - 7).Trim();
							}
							AddName(text);
						}
					}
				}
			}
			catch (Exception ex)
			{
				LogWarn("FindObjectsOfTypeAll: " + ex.Message);
			}
		}
		_names.Sort(StringComparer.OrdinalIgnoreCase);
		_loaded = true;
		ApplyFilter();
		_status = "已载入 " + _names.Count + " 件物品";
		Log("item prefabs = " + _names.Count);
	}

	private void AddName(string n)
	{
		if (string.IsNullOrEmpty(n))
		{
			return;
		}
		for (int i = 0; i < _names.Count; i++)
		{
			if (_names[i] == n)
			{
				return;
			}
		}
		_names.Add(n);
	}

	private void ApplyFilter()
	{
		_filtered.Clear();
		for (int i = 0; i < _names.Count; i++)
		{
			if (_cat <= 0 || !(CatOf(_names[i]) != Cats[_cat]))
			{
				string text = Cn(_names[i]);
				if (_search.Length == 0 || _names[i].IndexOf(_search, StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf(_search, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					_filtered.Add(_names[i]);
				}
			}
		}
	}

	private static bool SendRpc(PhotonView pv, string method, object[] args)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)pv == (Object)null)
		{
			LogWarn("rpc " + method + " : view 为空");
			return false;
		}
		try
		{
			Hashtable val = new Hashtable();
			val[(byte)0] = pv.ViewID;
			val[(byte)1] = method;
			val[(byte)2] = args;
			RaiseEventOptions val2 = new RaiseEventOptions();
			val2.Receivers = (ReceiverGroup)1;
			bool flag = PhotonNetwork.NetworkingClient.OpRaiseEvent((byte)200, (object)val, val2, SendOptions.SendReliable);
			Log("raw rpc " + method + " viewId=" + pv.ViewID + " ok=" + flag);
			return flag;
		}
		catch (Exception ex)
		{
			LogWarn("raw rpc " + method + " failed: " + ex.Message);
			return false;
		}
	}

	private void SpawnFor(Character target, string itemName)
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)target == (Object)null)
		{
			_status = "目标不存在";
			return;
		}
		if (!PhotonNetwork.IsConnected)
		{
			_status = "未连接房间";
			return;
		}
		try
		{
			Vector3 val = target.Center + ((Component)target).transform.forward * 0.7f + Vector3.up * 0.3f;
			GameObject val2 = PhotonNetwork.Instantiate("0_Items/" + itemName, val, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val2 == (Object)null)
			{
				_status = "生成失败:" + itemName;
				return;
			}
			Item component = val2.GetComponent<Item>();
			PhotonView val3 = ViewOf(target);
			if ((Object)(object)component != (Object)null && (Object)(object)val3 != (Object)null)
			{
				component.RequestPickup(val3);
			}
			_status = "已为 " + NameOf(target) + " 生成 " + Cn(itemName);
		}
		catch (Exception ex)
		{
			_status = "异常:" + ex.Message;
			((BaseUnityPlugin)this).Logger.LogError((object)ex);
		}
	}

	private static string NameOf(Character c)
	{
		if ((Object)(object)c == (Object)null)
		{
			return "角色";
		}
		try
		{
			string characterName = c.characterName;
			if (!string.IsNullOrEmpty(characterName))
			{
				return characterName;
			}
		}
		catch
		{
		}
		try
		{
			return c.IsLocal ? "你" : "队友";
		}
		catch
		{
		}
		return "角色";
	}

	private static List<Character> Team()
	{
		List<Character> list = new List<Character>();
		try
		{
			List<Character> allCharacters = Character.AllCharacters;
			if (allCharacters != null)
			{
				for (int i = 0; i < allCharacters.Count; i++)
				{
					if ((Object)(object)allCharacters[i] != (Object)null)
					{
						list.Add(allCharacters[i]);
					}
				}
			}
		}
		catch
		{
		}
		return list;
	}

	private static PhotonView ViewOf(Character c)
	{
		if ((Object)(object)c == (Object)null)
		{
			return null;
		}
		try
		{
			PhotonView component = ((Component)c).GetComponent<PhotonView>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
		}
		catch
		{
		}
		try
		{
			Transform transform = ((Component)c).transform;
			if ((Object)(object)transform != (Object)null)
			{
				return ((Component)transform).GetComponent<PhotonView>();
			}
		}
		catch
		{
		}
		return null;
	}

	private static Character HostCharacter()
	{
		try
		{
			List<Character> allCharacters = Character.AllCharacters;
			if (allCharacters != null)
			{
				for (int i = 0; i < allCharacters.Count; i++)
				{
					Character val = allCharacters[i];
					if (!((Object)(object)val == (Object)null))
					{
						PhotonView val2 = ViewOf(val);
						if (!((Object)(object)val2 == (Object)null) && val2.Owner != null && val2.Owner.IsMasterClient)
						{
							return val;
						}
					}
				}
			}
		}
		catch
		{
		}
		return Character.localCharacter;
	}

	private static Vector3 GroundSnap(Vector3 p)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(p + Vector3.up * 3f, Vector3.down, ref val, 14f, -1, (QueryTriggerInteraction)1))
			{
				return ((RaycastHit)(ref val)).point + Vector3.up * 0.05f;
			}
		}
		catch
		{
		}
		return p;
	}

	private static Vector3 NearHost()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		Character val = HostCharacter();
		if ((Object)(object)val == (Object)null)
		{
			return Vector3.zero;
		}
		Vector3 p = ((Component)val).transform.position + ((Component)val).transform.right * 1.1f + ((Component)val).transform.forward * 0.2f;
		return GroundSnap(p);
	}

	private void RefillStamina(Character c)
	{
		try
		{
			if ((Object)(object)c != (Object)null && (Object)(object)c.data != (Object)null)
			{
				c.data.currentStamina = c.GetTotalStamina();
			}
		}
		catch (Exception ex)
		{
			_status = "加体力失败:" + ex.Message;
		}
	}

	private static void BuildMaps()
	{
		if (_cnMap != null)
		{
			return;
		}
		_cnMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
		_catMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
		for (int i = 0; i < Table.Length; i++)
		{
			string key = Table[i][0];
			if (!_cnMap.ContainsKey(key))
			{
				_cnMap.Add(key, Table[i][1]);
			}
			if (!_catMap.ContainsKey(key))
			{
				_catMap.Add(key, Table[i][2]);
			}
		}
	}

	public static string Cn(string raw)
	{
		if (string.IsNullOrEmpty(raw))
		{
			return raw;
		}
		BuildMaps();
		if (_cnMap.TryGetValue(raw, out var value))
		{
			return value;
		}
		string key = raw.Replace("_", " ").Trim();
		if (_cnMap.TryGetValue(key, out value))
		{
			return value;
		}
		return raw;
	}

	public static string CatOf(string raw)
	{
		if (string.IsNullOrEmpty(raw))
		{
			return "其他";
		}
		BuildMaps();
		if (_catMap.TryGetValue(raw, out var value))
		{
			return value;
		}
		string key = raw.Replace("_", " ").Trim();
		if (_catMap.TryGetValue(key, out value))
		{
			return value;
		}
		string text = raw.ToLowerInvariant();
		if (text.IndexOf("amulet") >= 0)
		{
			return "护符";
		}
		if (text.IndexOf("rope") >= 0 || text.IndexOf("piton") >= 0 || text.IndexOf("spike") >= 0 || text.IndexOf("hook") >= 0)
		{
			return "绳索";
		}
		if (text.IndexOf("berry") >= 0 || text.IndexOf("shroom") >= 0 || text.IndexOf("mushroom") >= 0 || text.IndexOf("egg") >= 0)
		{
			return "食物";
		}
		if (text.IndexOf("cure") >= 0 || text.IndexOf("aid") >= 0)
		{
			return "医疗";
		}
		if (text.IndexOf("lantern") >= 0 || text.IndexOf("torch") >= 0 || text.IndexOf("flare") >= 0)
		{
			return "照明";
		}
		if (text.IndexOf("ball") >= 0 || text.IndexOf("bomb") >= 0 || text.IndexOf("dynamite") >= 0)
		{
			return "投掷";
		}
		return "其他";
	}

	private static bool ResolveMaxPlayers()
	{
		if (_mpValueProp != null)
		{
			return true;
		}
		try
		{
			Type type = null;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			for (int i = 0; i < assemblies.Length; i++)
			{
				type = assemblies[i].GetType("PEAKUnlimited.ConfigurationHandler", throwOnError: false);
				if (type != null)
				{
					break;
				}
			}
			if (type == null)
			{
				return false;
			}
			FieldInfo field = type.GetField("ConfigMaxPlayers", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				return false;
			}
			_mpEntry = field.GetValue(null);
			if (_mpEntry == null)
			{
				return false;
			}
			_mpValueProp = _mpEntry.GetType().GetProperty("Value");
			return _mpValueProp != null;
		}
		catch
		{
			return false;
		}
	}

	public static int GetMaxPlayers()
	{
		if (!ResolveMaxPlayers())
		{
			return -1;
		}
		try
		{
			return (int)_mpValueProp.GetValue(_mpEntry, null);
		}
		catch
		{
			return -1;
		}
	}

	public static bool SetMaxPlayers(int n)
	{
		if (!ResolveMaxPlayers())
		{
			return false;
		}
		try
		{
			_mpValueProp.SetValue(_mpEntry, n, null);
			return true;
		}
		catch
		{
			return false;
		}
	}

	private static Texture2D MakeTex(Color c)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Expected O, but got Unknown
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(1, 1);
		val.SetPixel(0, 0, c);
		val.Apply();
		return val;
	}

	private void BuildStyles()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Expected O, but got Unknown
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Expected O, but got Unknown
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Expected O, but got Unknown
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Expected O, but got Unknown
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Expected O, but got Unknown
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Expected O, but got Unknown
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Expected O, but got Unknown
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Expected O, but got Unknown
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0336: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Expected O, but got Unknown
		//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f8: Expected O, but got Unknown
		//IL_0403: Unknown result type (might be due to invalid IL or missing references)
		//IL_040d: Expected O, but got Unknown
		//IL_0415: Unknown result type (might be due to invalid IL or missing references)
		//IL_041f: Expected O, but got Unknown
		//IL_0458: Unknown result type (might be due to invalid IL or missing references)
		//IL_0477: Unknown result type (might be due to invalid IL or missing references)
		//IL_0481: Expected O, but got Unknown
		//IL_0496: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a0: Expected O, but got Unknown
		//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b5: Expected O, but got Unknown
		//IL_0518: Unknown result type (might be due to invalid IL or missing references)
		//IL_052e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0543: Unknown result type (might be due to invalid IL or missing references)
		//IL_054d: Expected O, but got Unknown
		//IL_0558: Unknown result type (might be due to invalid IL or missing references)
		//IL_0562: Expected O, but got Unknown
		//IL_056a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0574: Expected O, but got Unknown
		//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cd: Expected O, but got Unknown
		//IL_060c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0621: Unknown result type (might be due to invalid IL or missing references)
		//IL_062b: Expected O, but got Unknown
		//IL_0637: Unknown result type (might be due to invalid IL or missing references)
		//IL_0641: Expected O, but got Unknown
		//IL_067e: Unknown result type (might be due to invalid IL or missing references)
		if (!_stylesReady)
		{
			_texBg = MakeTex(new Color(0.08f, 0.09f, 0.11f, 0.97f));
			_texPanel = MakeTex(new Color(0.13f, 0.15f, 0.18f, 1f));
			_texBtn = MakeTex(new Color(0.2f, 0.23f, 0.27f, 1f));
			_texBtnHover = MakeTex(new Color(0.28f, 0.32f, 0.38f, 1f));
			_texBtnOn = MakeTex(new Color(0.16f, 0.48f, 0.72f, 1f));
			_texAccent = MakeTex(new Color(0.3f, 0.76f, 1f, 1f));
			_texItemSel = MakeTex(new Color(0.18f, 0.4f, 0.58f, 1f));
			_stWindow = new GUIStyle(GUI.skin.window);
			_stWindow.normal.background = _texBg;
			_stWindow.onNormal.background = _texBg;
			_stWindow.border = new RectOffset(6, 6, 26, 6);
			_stWindow.padding = new RectOffset(10, 10, 26, 10);
			_stWindow.fontSize = 15;
			_stTitle = new GUIStyle(GUI.skin.label);
			_stTitle.fontSize = 18;
			_stTitle.fontStyle = (FontStyle)1;
			_stTitle.normal.textColor = new Color(0.93f, 0.96f, 1f);
			_stHeader = new GUIStyle(GUI.skin.label);
			_stHeader.fontSize = 13;
			_stHeader.fontStyle = (FontStyle)1;
			_stHeader.normal.textColor = new Color(0.3f, 0.76f, 1f);
			_stLabel = new GUIStyle(GUI.skin.label);
			_stLabel.fontSize = 14;
			_stLabel.normal.textColor = new Color(0.88f, 0.9f, 0.93f);
			_stSmall = new GUIStyle(GUI.skin.label);
			_stSmall.fontSize = 11;
			_stSmall.wordWrap = true;
			_stSmall.normal.textColor = new Color(0.62f, 0.66f, 0.72f);
			_stStatus = new GUIStyle(GUI.skin.label);
			_stStatus.fontSize = 12;
			_stStatus.wordWrap = true;
			_stStatus.normal.textColor = new Color(0.55f, 0.85f, 0.65f);
			_stBtn = new GUIStyle(GUI.skin.button);
			_stBtn.fontSize = 13;
			_stBtn.normal.background = _texBtn;
			_stBtn.hover.background = _texBtnHover;
			_stBtn.active.background = _texBtnHover;
			_stBtn.normal.textColor = new Color(0.9f, 0.93f, 0.96f);
			_stBtn.hover.textColor = Color.white;
			_stBtn.active.textColor = Color.white;
			_stBtn.border = new RectOffset(4, 4, 4, 4);
			_stBtn.padding = new RectOffset(8, 8, 4, 4);
			_stBtnOn = new GUIStyle(_stBtn);
			_stBtnOn.normal.background = _texBtnOn;
			_stBtnOn.hover.background = _texBtnOn;
			_stBtnOn.normal.textColor = Color.white;
			_stBtnOn.fontStyle = (FontStyle)1;
			_stTab = new GUIStyle(_stBtn);
			_stTab.fontSize = 13;
			_stTabOn = new GUIStyle(_stBtnOn);
			_stItem = new GUIStyle(GUI.skin.button);
			_stItem.fontSize = 12;
			_stItem.alignment = (TextAnchor)3;
			_stItem.normal.background = _texPanel;
			_stItem.hover.background = _texBtnHover;
			_stItem.normal.textColor = new Color(0.86f, 0.89f, 0.92f);
			_stItem.hover.textColor = Color.white;
			_stItem.border = new RectOffset(2, 2, 2, 2);
			_stItem.padding = new RectOffset(8, 8, 2, 2);
			_stItemSel = new GUIStyle(_stItem);
			_stItemSel.normal.background = _texItemSel;
			_stItemSel.hover.background = _texItemSel;
			_stItemSel.normal.textColor = Color.white;
			_stField = new GUIStyle(GUI.skin.textField);
			_stField.fontSize = 13;
			_stField.normal.background = _texPanel;
			_stField.normal.textColor = new Color(0.92f, 0.95f, 1f);
			_stField.padding = new RectOffset(6, 6, 4, 4);
			_stPick = new GUIStyle(GUI.skin.box);
			_stPick.fontSize = 13;
			_stPick.alignment = (TextAnchor)4;
			_stPick.normal.background = _texItemSel;
			_stPick.normal.textColor = Color.white;
			if ((Object)(object)_cjk != (Object)null)
			{
				_stWindow.font = _cjk;
				_stTitle.font = _cjk;
				_stHeader.font = _cjk;
				_stLabel.font = _cjk;
				_stSmall.font = _cjk;
				_stStatus.font = _cjk;
				_stBtn.font = _cjk;
				_stBtnOn.font = _cjk;
				_stItem.font = _cjk;
				_stItemSel.font = _cjk;
				_stTab.font = _cjk;
				_stTabOn.font = _cjk;
				_stField.font = _cjk;
				_stPick.font = _cjk;
			}
			_stylesReady = true;
		}
	}

	private void OnGUI()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		if (_showGui)
		{
			BuildStyles();
			_win = GUI.Window(20251109, _win, new WindowFunction(DrawWindow), "Ne Ai * PEAK v3.3", _stWindow);
		}
	}

	private void DrawWindow(int id)
	{
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Label("PEAK 工具箱", _stTitle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.FlexibleSpace();
		if (GUILayout.Button("×", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(28f),
			GUILayout.Height(22f)
		}))
		{
			ToggleGui();
			return;
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (GUILayout.Button("物品", (_tab == 0) ? _stTabOn : _stTab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
		{
			_tab = 0;
		}
		if (GUILayout.Button("队友", (_tab == 1) ? _stTabOn : _stTab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
		{
			_tab = 1;
		}
		if (GUILayout.Button("设置", (_tab == 2) ? _stTabOn : _stTab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
		{
			_tab = 2;
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(6f);
		if (_tab == 0)
		{
			DrawItems();
		}
		else if (_tab == 1)
		{
			DrawTeam();
		}
		else
		{
			DrawSettings();
		}
		GUILayout.FlexibleSpace();
		GUILayout.Label("状态:" + _status, _stStatus, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Label("F11 开关面板 · 所有功能仅在面板内生效", _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Label("本程序由 NeAi 出品", _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Label("不代表最终品质 · 如有侵权请联系 3191985805 进行删除", _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _win)).width, 24f));
	}

	private void DrawItems()
	{
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Label("物品生成", _stHeader, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		string text = GUILayout.TextField(_search, _stField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) });
		if (text != _search)
		{
			_search = text;
			ApplyFilter();
		}
		if (GUILayout.Button("刷新", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(52f),
			GUILayout.Height(24f)
		}))
		{
			_loaded = false;
			ReloadItemList();
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		for (int i = 0; i < 2; i++)
		{
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			int num = ((i != 0) ? 6 : 0);
			int num2 = ((i == 0) ? 6 : Cats.Length);
			for (int j = num; j < num2; j++)
			{
				int num3 = j;
				if (GUILayout.Button(Cats[j], (_cat == num3) ? _stBtnOn : _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(52f),
					GUILayout.Height(22f)
				}))
				{
					_cat = num3;
					ApplyFilter();
				}
			}
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
		}
		GUILayout.Space(4f);
		_scrollItems = GUILayout.BeginScrollView(_scrollItems, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(((Rect)(ref _win)).height - 300f) });
		if (!_loaded)
		{
			GUILayout.Label("正在扫描…", _stLabel, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		}
		else if (_filtered.Count == 0)
		{
			GUILayout.Label("无匹配物品", _stLabel, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		}
		else
		{
			for (int j = 0; j < _filtered.Count; j++)
			{
				string text2 = _filtered[j];
				bool flag = text2 == _selected;
				string text3 = (flag ? "● " : "   ") + Cn(text2) + "    " + text2;
				if (GUILayout.Button(text3, flag ? _stItemSel : _stItem, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) }))
				{
					_selected = text2;
				}
			}
		}
		GUILayout.EndScrollView();
		GUILayout.Space(6f);
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		string text4 = (string.IsNullOrEmpty(_selected) ? "(未选择)" : (Cn(_selected) + "  " + _selected));
		GUILayout.Label("当前:" + text4, _stLabel, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.FlexibleSpace();
		if (GUILayout.Button("刷给自己", _stBtnOn, (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(96f),
			GUILayout.Height(26f)
		}))
		{
			if (string.IsNullOrEmpty(_selected))
			{
				_status = "先在上面选一件物品";
			}
			else
			{
				SpawnFor(Character.localCharacter, _selected);
			}
		}
		GUILayout.EndHorizontal();
	}

	private void DrawTeam()
	{
		//IL_0638: Unknown result type (might be due to invalid IL or missing references)
		//IL_0661: Unknown result type (might be due to invalid IL or missing references)
		//IL_0666: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Label("联机 · 队友", _stHeader, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(18f) });
		bool flag = false;
		try
		{
			flag = PhotonNetwork.IsConnected;
		}
		catch
		{
		}
		List<Character> list = Team();
		GUILayout.Label(flag ? ("已连接房间,共 " + list.Count + " 名角色") : "未连接房间(单人 / 离线)", _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		string text = (string.IsNullOrEmpty(_selected) ? "(未选择,去「物品」页选一件)" : (Cn(_selected) + "  " + _selected));
		GUILayout.Label("待发放:" + text, _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(4f);
		GUILayout.Label("传送(房主指定:把谁送到哪个玩家身边)", _stHeader, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (list.Count < 2)
		{
			GUILayout.Label("至少要两个角色才能指定传送目标。", _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		}
		else
		{
			if (_warpSrc < 0 || _warpSrc >= list.Count)
			{
				_warpSrc = 0;
			}
			if (_warpDst < 0 || _warpDst >= list.Count)
			{
				_warpDst = ((list.Count > 1) ? 1 : 0);
			}
			if (_warpDst == _warpSrc)
			{
				_warpDst = (_warpSrc + 1) % list.Count;
			}
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("把", _stLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(24f) });
			if (GUILayout.Button("<", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(24f),
				GUILayout.Height(24f)
			}))
			{
				_warpSrc = (_warpSrc - 1 + list.Count) % list.Count;
			}
			GUILayout.Label(NameOf(list[_warpSrc]), _stPick, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(118f),
				GUILayout.Height(24f)
			});
			if (GUILayout.Button(">", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(24f),
				GUILayout.Height(24f)
			}))
			{
				_warpSrc = (_warpSrc + 1) % list.Count;
			}
			GUILayout.Label("送到", _stLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(38f) });
			if (GUILayout.Button("<", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(24f),
				GUILayout.Height(24f)
			}))
			{
				_warpDst = (_warpDst - 1 + list.Count) % list.Count;
			}
			GUILayout.Label(NameOf(list[_warpDst]), _stPick, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(118f),
				GUILayout.Height(24f)
			});
			if (GUILayout.Button(">", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(24f),
				GUILayout.Height(24f)
			}))
			{
				_warpDst = (_warpDst + 1) % list.Count;
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (GUILayout.Button("执行传送", _stBtnOn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
			{
				if (_warpSrc == _warpDst)
				{
					_status = "起点和终点是同一个玩家";
				}
				else
				{
					WarpToCharacter(list[_warpSrc], list[_warpDst]);
				}
			}
			if (GUILayout.Button("把我送到他身边", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
			{
				Character localCharacter = Character.localCharacter;
				Character val = list[_warpDst];
				if ((Object)(object)localCharacter == (Object)null || (Object)(object)val == (Object)null)
				{
					_status = "缺少角色";
				}
				else
				{
					WarpSelfTo(val);
				}
			}
			GUILayout.EndHorizontal();
		}
		GUILayout.Space(6f);
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (GUILayout.Button("全队各发一件", _stBtnOn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
		{
			if (string.IsNullOrEmpty(_selected))
			{
				_status = "先到「物品」页选一件物品";
			}
			else
			{
				int num = 0;
				for (int i = 0; i < list.Count; i++)
				{
					SpawnFor(list[i], _selected);
					num++;
				}
				_status = "已向 " + num + " 名角色各发放 1 个 " + Cn(_selected);
			}
		}
		if (GUILayout.Button("给自己加满体力", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
		{
			RefillStamina(Character.localCharacter);
			_status = "已加满自己的体力";
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(6f);
		_scrollTeam = GUILayout.BeginScrollView(_scrollTeam, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(((Rect)(ref _win)).height - 470f) });
		if (list.Count == 0)
		{
			GUILayout.Label("暂未找到角色(进关卡后再看)", _stLabel, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		}
		for (int i = 0; i < list.Count; i++)
		{
			Character val2 = list[i];
			bool flag2 = false;
			try
			{
				flag2 = val2.IsLocal;
			}
			catch
			{
			}
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label((flag2 ? "  [你] " : "  ") + NameOf(val2), _stLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) });
			GUILayout.Label(Dist(val2), _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(52f) });
			if (GUILayout.Button("发物品", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(60f),
				GUILayout.Height(22f)
			}))
			{
				if (string.IsNullOrEmpty(_selected))
				{
					_status = "先到「物品」页选一件物品";
				}
				else
				{
					SpawnFor(val2, _selected);
				}
			}
			if (!flag2 && GUILayout.Button("传到我", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(58f),
				GUILayout.Height(22f)
			}))
			{
				WarpToCharacter(val2, Character.localCharacter);
			}
			if (!flag2 && GUILayout.Button("复活", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(48f),
				GUILayout.Height(22f)
			}))
			{
				ReviveTarget(val2);
			}
			if (flag2 && GUILayout.Button("加满体力", _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(78f),
				GUILayout.Height(22f)
			}))
			{
				RefillStamina(val2);
			}
			GUILayout.EndHorizontal();
		}
		GUILayout.EndScrollView();
		GUILayout.Space(4f);
		bool flag3 = GUILayout.Toggle(_reviveAtHost, "   复活落点放在房主身边(关掉 = 在队友原地复活)", _stItemSel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) });
		if (flag3 != _reviveAtHost)
		{
			_reviveAtHost = flag3;
			_status = "复活落点:" + (flag3 ? "房主身边" : "队友原地");
		}
		GUILayout.Label("复活与传送都走 Photon 原始 RPC 事件包,和双方距离无关:隔着上万米照样能拉、能复活。唯一前提是对方还在房间里、角色没被销毁。", _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[0]);
	}

	private static string Dist(Character c)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter == (Object)null || (Object)(object)c == (Object)null || (Object)(object)c == (Object)(object)localCharacter)
			{
				return "";
			}
			float num = Vector3.Distance(((Component)localCharacter).transform.position, ((Component)c).transform.position);
			return "(" + Mathf.RoundToInt(num) + " 米)";
		}
		catch
		{
			return "";
		}
	}

	private void WarpToCharacter(Character moved, Character anchor)
	{
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)moved == (Object)null || (Object)(object)anchor == (Object)null)
		{
			_status = "缺少角色";
			return;
		}
		if ((Object)(object)moved == (Object)(object)anchor)
		{
			_status = "起点和终点是同一个玩家";
			return;
		}
		try
		{
			PhotonView val = ViewOf(moved);
			if ((Object)(object)val == (Object)null)
			{
				_status = "目标没有 PhotonView";
				return;
			}
			Vector3 val2 = GroundSnap(((Component)anchor).transform.position + ((Component)anchor).transform.right * 1f + Vector3.up * 0.2f);
			bool flag = SendRpc(val, "WarpPlayerRPC", new object[2] { val2, true });
			_status = (flag ? ("已把 " + NameOf(moved) + " 送到 " + NameOf(anchor) + " 身边") : "传送包发送失败,看日志");
		}
		catch (Exception ex)
		{
			_status = "传送失败:" + ex.Message;
			LogWarn("warp failed: " + ex.Message);
		}
	}

	private void WarpSelfTo(Character dst)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter == (Object)null || (Object)(object)dst == (Object)null)
			{
				_status = "缺少角色";
				return;
			}
			Vector3 val = GroundSnap(((Component)dst).transform.position + ((Component)dst).transform.right * 1f + Vector3.up * 0.2f);
			((Component)localCharacter).transform.position = val;
			PhotonView val2 = ViewOf(localCharacter);
			if ((Object)(object)val2 != (Object)null)
			{
				SendRpc(val2, "WarpPlayerRPC", new object[2] { val, true });
			}
			_status = "已移动到 " + NameOf(dst) + " 身边";
		}
		catch (Exception ex)
		{
			_status = "移动失败:" + ex.Message;
		}
	}

	private void ReviveTarget(Character c)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)c == (Object)null)
			{
				_status = "缺少目标";
				return;
			}
			PhotonView val = ViewOf(c);
			if ((Object)(object)val == (Object)null)
			{
				_status = "目标没有 PhotonView";
				return;
			}
			Vector3 val2 = (_reviveAtHost ? NearHost() : GroundSnap(((Component)c).transform.position));
			bool flag = SendRpc(val, "RPCA_ReviveAtPosition", new object[3] { val2, true, 0 });
			Character c2 = HostCharacter();
			_status = (flag ? ("已请求复活 " + NameOf(c) + "(落点 " + NameOf(c2) + " 身边)") : "复活包发送失败,看日志");
		}
		catch (Exception ex)
		{
			_status = "复活失败:" + ex.Message;
			LogWarn("revive failed: " + ex.Message);
		}
	}

	private void DrawSettings()
	{
		GUILayout.Label("功能开关", _stHeader, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		bool flag = GUILayout.Toggle(NoStaminaDrain, "   无限体力(体力不再消耗)", _stItemSel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) });
		if (flag != NoStaminaDrain)
		{
			NoStaminaDrain = flag;
			_status = "无限体力:" + (flag ? "已开启" : "已关闭");
		}
		bool flag2 = GUILayout.Toggle(NoHunger, "   不挨饿(饥饿值不再增长)", _stItemSel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) });
		if (flag2 != NoHunger)
		{
			NoHunger = flag2;
			_status = "不挨饿:" + (flag2 ? "已开启" : "已关闭");
		}
		GUILayout.Space(10f);
		GUILayout.Label("联机人数上限", _stHeader, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		int maxPlayers = GetMaxPlayers();
		if (maxPlayers < 0)
		{
			GUILayout.Label("未检测到联机组件(PEAKUnlimited)。请用完整安装包重装,或确认它没有被杀软删掉。", _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		}
		else
		{
			GUILayout.Label("当前 " + maxPlayers + " 人 · 仅房主开房时生效 · 已合并到本面板,不用再按 PEAKUnlimited 的 F2", _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			int[] array = new int[8] { 2, 4, 6, 8, 10, 12, 16, 20 };
			for (int i = 0; i < array.Length; i++)
			{
				int num = array[i];
				if (GUILayout.Button(num.ToString(), (maxPlayers == num) ? _stBtnOn : _stBtn, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(40f),
					GUILayout.Height(24f)
				}))
				{
					if (SetMaxPlayers(num))
					{
						_status = "联机人数上限已设为 " + num + " 人(下次开房生效)";
					}
					else
					{
						_status = "设置失败:联机组件未就绪";
					}
				}
			}
			GUILayout.EndHorizontal();
		}
		GUILayout.Space(10f);
		GUILayout.Label("说明", _stHeader, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Label("所有开关关闭后即为原版行为,无需重启游戏。物品生成走游戏自带的 Photon 实例化通道,联机时队友可见。人数上限会写回 PEAKUnlimited.cfg,重开游戏也保留。", _stSmall, (GUILayoutOption[])(object)new GUILayoutOption[0]);
	}
}
[HarmonyPatch(typeof(Character), "UseStamina")]
public static class PatchUseStamina
{
	public static bool Prefix(ref bool __result)
	{
		if (Plugin.NoStaminaDrain)
		{
			__result = true;
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(CharacterAfflictions), "AddHunger")]
public static class PatchAddHunger
{
	public static bool Prefix()
	{
		return !Plugin.NoHunger;
	}
}
[HarmonyPatch(typeof(CharacterAfflictions), "AddTinyHunger")]
public static class PatchAddTinyHunger
{
	public static bool Prefix()
	{
		return !Plugin.NoHunger;
	}
}