PEAKKill.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PEAKKILL
{
	[BepInPlugin("dsh.peak.kill", "Kill", "2.0.0")]
	public class RunPlugin : BaseUnityPlugin
	{
		internal static class RunDriver
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static CameraCallback <>9__5_0;

				public static Action<ScriptableRenderContext, Camera> <>9__5_1;

				internal void <InitCamHook>b__5_0(Camera cam)
				{
					try
					{
						AttachToCamera(cam);
					}
					catch (Exception ex)
					{
						LogWarn("[Probe] onPreCull err: " + ex.Message);
					}
				}

				internal void <InitCamHook>b__5_1(ScriptableRenderContext ctx, Camera cam)
				{
					try
					{
						AttachToCamera(cam);
					}
					catch (Exception ex)
					{
						LogWarn("[Probe] beginCameraRendering err: " + ex.Message);
					}
				}
			}

			internal static RunDriverComp Comp;

			internal static RunDriverComp OwnComp;

			internal static float LastTick;

			private static bool _camHookInited;

			internal static void EnsureOwn()
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Expected O, but got Unknown
				if ((Object)(object)OwnComp != (Object)null && (Object)(object)((Component)OwnComp).gameObject != (Object)null)
				{
					Comp = OwnComp;
					return;
				}
				GameObject val = new GameObject("[KillDriver]");
				Object.DontDestroyOnLoad((Object)(object)val);
				OwnComp = val.AddComponent<RunDriverComp>();
				OwnComp.SpawnedFrom = "own";
				Comp = OwnComp;
				Log("[Probe] own driver GO created (DontDestroyOnLoad)");
			}

			internal static void InitCamHook()
			{
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected O, but got Unknown
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				if (_camHookInited)
				{
					return;
				}
				_camHookInited = true;
				CameraCallback onPreCull = Camera.onPreCull;
				object obj = <>c.<>9__5_0;
				if (obj == null)
				{
					CameraCallback val = delegate(Camera cam)
					{
						try
						{
							AttachToCamera(cam);
						}
						catch (Exception ex)
						{
							LogWarn("[Probe] onPreCull err: " + ex.Message);
						}
					};
					<>c.<>9__5_0 = val;
					obj = (object)val;
				}
				Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)onPreCull, (Delegate?)obj);
				RenderPipelineManager.beginCameraRendering += delegate(ScriptableRenderContext ctx, Camera cam)
				{
					try
					{
						AttachToCamera(cam);
					}
					catch (Exception ex)
					{
						LogWarn("[Probe] beginCameraRendering err: " + ex.Message);
					}
				};
				Log("[Probe] Camera.onPreCull + SRP beginCameraRendering subscribed");
			}

			internal static void AttachToCamera(Camera cam)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Invalid comparison between Unknown and I4
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Invalid comparison between Unknown and I4
				if ((Object)(object)cam == (Object)null || (int)cam.cameraType == 16 || (int)cam.cameraType == 4)
				{
					return;
				}
				EnsureOwn();
				if ((Object)(object)OwnComp != (Object)null && Time.realtimeSinceStartup - LastTick < 1.5f)
				{
					return;
				}
				GameObject gameObject = ((Component)cam).gameObject;
				if ((Object)(object)gameObject == (Object)null)
				{
					return;
				}
				RunDriverComp component = gameObject.GetComponent<RunDriverComp>();
				if ((Object)(object)component != (Object)null)
				{
					Comp = component;
					component.SpawnedFrom = "camera:" + ((Object)gameObject).name;
					return;
				}
				(Comp = gameObject.AddComponent<RunDriverComp>()).SpawnedFrom = "camera:" + ((Object)gameObject).name;
				Log("[Probe] RunDriverComp attached to camera GO: " + ((Object)gameObject).name + " (own driver stalled)");
				RunPlugin inst = _inst;
				if ((Object)(object)inst != (Object)null)
				{
					inst.DriverTick();
				}
			}

			internal static void HookCameraTick(MainCameraMovement __instance)
			{
				try
				{
					Camera val = null;
					if ((Object)(object)__instance != (Object)null)
					{
						val = ((Component)__instance).GetComponent<Camera>();
					}
					if ((Object)(object)val == (Object)null)
					{
						val = Camera.main;
					}
					AttachToCamera(val);
				}
				catch (Exception ex)
				{
					LogWarn("[Probe] HookCameraTick error: " + ex.Message);
				}
			}
		}

		internal class RunDriverComp : MonoBehaviour
		{
			internal string SpawnedFrom = "unknown";

			private void Awake()
			{
				Log("[Probe] RunDriverComp spawned via " + SpawnedFrom);
			}

			private void Update()
			{
				RunDriver.LastTick = Time.realtimeSinceStartup;
				RunPlugin inst = _inst;
				if ((Object)(object)inst != (Object)null)
				{
					inst.DriverTick();
				}
			}

			private void OnGUI()
			{
				RunPlugin inst = _inst;
				if ((Object)(object)inst != (Object)null)
				{
					inst.DriverOnGUI();
				}
			}
		}

		internal static RunPlugin _inst;

		private Harmony _harmony;

		private bool _showGui;

		private Rect _win = new Rect(40f, 40f, 620f, 880f);

		private bool _stylesReady;

		private bool _updateLogged;

		private bool _onGuiLogged;

		private float _uiAliveUntil;

		private readonly HashSet<Character> _netReady = new HashSet<Character>();

		private string _rulesRoom = "";

		private bool _rulesAcked;

		private float _rulesSeenAt;

		private Vector2 _rulesScroll;

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

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

		private void Awake()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			_inst = this;
			try
			{
				_harmony = new Harmony("dsh.peak.kill.driver");
				_harmony.Patch((MethodBase)AccessTools.Method(typeof(MainCameraMovement), "LateUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(RunDriver), "HookCameraTick", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Log("[Probe] LateUpdate harmony patch registered");
			}
			catch (Exception ex)
			{
				LogWarn("[Probe] harmony patch failed: " + ex.Message);
			}
			RunDriver.InitCamHook();
			_uiAliveUntil = Time.time + 60f;
			Log("[Probe] Awake done, uiAliveUntil=" + _uiAliveUntil);
		}

		private void BuildStyles()
		{
			if (!_stylesReady)
			{
				UI.Build();
				_stylesReady = true;
			}
		}

		private void Update()
		{
			if ((Object)(object)RunDriver.Comp == (Object)null)
			{
				DriverTick();
			}
		}

		internal void DriverTick()
		{
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			if (Time.frameCount % 600 == 0)
			{
				Log("[Probe] tick frame=" + Time.frameCount + " showGui=" + _showGui + " src=" + (((Object)(object)RunDriver.Comp != (Object)null) ? RunDriver.Comp.SpawnedFrom : "none"));
			}
			if (!_updateLogged)
			{
				_updateLogged = true;
				Log("[Probe] DriverTick (Update) ticking, time=" + Time.time);
			}
			if (Character.AllCharacters != null)
			{
				foreach (Character allCharacter in Character.AllCharacters)
				{
					if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)((Component)allCharacter).gameObject == (Object)null) && !_netReady.Contains(allCharacter))
					{
						if ((Object)(object)((Component)allCharacter).gameObject.GetComponent<RunNet>() == (Object)null)
						{
							((Component)allCharacter).gameObject.AddComponent<RunNet>();
						}
						_netReady.Add(allCharacter);
					}
				}
			}
			if (Input.GetKeyDown((KeyCode)290))
			{
				_showGui = !_showGui;
				Log("[Probe] F9 pressed, showGui -> " + _showGui);
			}
			if (PhotonNetwork.InRoom)
			{
				string text = ((PhotonNetwork.CurrentRoom != null) ? PhotonNetwork.CurrentRoom.Name : "");
				if (text != _rulesRoom)
				{
					_rulesRoom = text;
					_rulesAcked = false;
					_rulesSeenAt = Time.time;
					_rulesScroll = Vector2.zero;
					Log("[Rules] joined room " + text + ",等待阅读规则");
				}
			}
			else if (_rulesRoom != "")
			{
				_rulesRoom = "";
				_rulesAcked = false;
			}
			RunGame.Tick();
		}

		private void OnGUI()
		{
			if ((Object)(object)RunDriver.Comp == (Object)null)
			{
				DriverOnGUI();
			}
		}

		internal void DriverOnGUI()
		{
			if (!_onGuiLogged)
			{
				_onGuiLogged = true;
				Log("[Probe] DriverOnGUI entered, time=" + Time.time);
			}
			BuildStyles();
			DrawOverlays();
			if (_showGui)
			{
				DrawMainWindow();
			}
			DrawRulesGate();
		}

		private void DrawMainWindow()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			_win = GUI.Window(99821, _win, (WindowFunction)delegate
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref _win)).width, ((Rect)(ref _win)).height), (Texture)(object)UI.WinTex(Mathf.RoundToInt(((Rect)(ref _win)).width), Mathf.RoundToInt(((Rect)(ref _win)).height)));
				GUI.Label(new Rect(14f, 8f, ((Rect)(ref _win)).width - 28f, 24f), "KILL", UI.Title);
				GUI.Label(new Rect(14f, 30f, ((Rect)(ref _win)).width - 28f, 16f), "追猎模式\u30002.0", UI.Sub);
				GUI.DrawTexture(new Rect(14f, 45f, ((Rect)(ref _win)).width - 28f, 1f), (Texture)(object)UI.HairTex);
				float num = 58f;
				float num2 = ((Rect)(ref _win)).height - num - 26f;
				GUILayout.BeginArea(new Rect(14f, num, ((Rect)(ref _win)).width - 28f, num2));
				RunGame.DrawPanel();
				GUILayout.EndArea();
				GUI.Label(new Rect(0f, ((Rect)(ref _win)).height - 22f, ((Rect)(ref _win)).width, 18f), "NeAi 打造\u3000抖音号 Tkhh1314", UI.Author);
				GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _win)).width, 48f));
			}, "KILL", GUIStyle.none);
		}

		private void DrawRulesGate()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.InRoom)
			{
				return;
			}
			string text = ((PhotonNetwork.CurrentRoom != null) ? PhotonNetwork.CurrentRoom.Name : "");
			if (!(text == "") && !(text != _rulesRoom) && !_rulesAcked)
			{
				GUI.color = new Color(0f, 0f, 0f, 0.58f);
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)UI.WhiteTex);
				GUI.color = Color.white;
				float num = Mathf.Min(560f, (float)Screen.width - 80f);
				float num2 = Mathf.Min(580f, (float)Screen.height - 100f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2);
				GUI.DrawTexture(val, (Texture)(object)UI.WinTex(Mathf.RoundToInt(num), Mathf.RoundToInt(num2)));
				GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y + 14f, ((Rect)(ref val)).width - 28f, ((Rect)(ref val)).height - 28f));
				GUILayout.Label("游戏规则", UI.Title, Array.Empty<GUILayoutOption>());
				GUILayout.Label("加入房间后需要先阅读本局规则", UI.Sub, Array.Empty<GUILayoutOption>());
				GUILayout.Space(10f);
				Rect rect = GUILayoutUtility.GetRect(1f, 46f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
				GUI.color = UI.Accent;
				GUI.DrawTexture(rect, (Texture)(object)UI.WhiteTex);
				GUI.color = Color.white;
				GUI.Label(rect, "按 E S C  可 呼 出 鼠 标", UI.EscBig);
				GUILayout.Space(10f);
				_rulesScroll = GUILayout.BeginScrollView(_rulesScroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(((Rect)(ref val)).height - 224f) });
				GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
				GUILayout.Label(RunGame.RulesText, UI.Notice, Array.Empty<GUILayoutOption>());
				GUILayout.EndVertical();
				GUILayout.EndScrollView();
				GUILayout.Space(8f);
				float num3 = Mathf.Max(0f, 3f - (Time.time - _rulesSeenAt));
				bool flag = num3 <= 0f;
				if (GUILayout.Button(flag ? "我已阅读并同意" : ("请阅读 " + Mathf.CeilToInt(num3) + " 秒"), flag ? UI.BtnPrimary : UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(44f) }) && flag)
				{
					_rulesAcked = true;
					Log("[Rules] 已确认规则");
				}
				GUILayout.Label("确认后本局不再弹出;换房间会重新弹出", UI.Small, Array.Empty<GUILayoutOption>());
				GUILayout.EndArea();
			}
		}

		[RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)]
		private static void RunDriverBootstrap()
		{
			RunDriver.InitCamHook();
		}

		private void DrawOverlays()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			if (RunGame.BannerText != null && Time.time < RunGame.BannerUntil)
			{
				float num = Mathf.Min(780f, (float)Screen.width - 80f);
				float num2 = 76f;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor((float)Screen.width / 2f - num / 2f, (float)Screen.height * 0.26f, num, num2);
				GUI.DrawTexture(val, (Texture)(object)UI.PlateTex);
				GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 16f, ((Rect)(ref val)).width, 44f), RunGame.BannerText, UI.Banner);
			}
			if (RunGame.ActiveSync && RunGame.KillerNames != "" && Time.time < RunGame.ProtectUntil)
			{
				int num3 = Mathf.CeilToInt(RunGame.ProtectUntil - Time.time);
				GUI.Label(new Rect(0f, (float)Screen.height * 0.06f, (float)Screen.width, 30f), "保护期 " + num3 + " 秒\u3000杀手暂不可行动", UI.Cd);
			}
			if (RunGame.KillerNames == "" || (Object)(object)Camera.main == (Object)null)
			{
				return;
			}
			string[] array = RunGame.KillerNames.Split(',');
			if (Character.AllCharacters == null)
			{
				return;
			}
			Rect val4 = default(Rect);
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if ((Object)(object)allCharacter == (Object)null || (Object)(object)((Component)allCharacter).gameObject == (Object)null || allCharacter.characterName == null)
				{
					continue;
				}
				bool flag = false;
				for (int i = 0; i < array.Length; i++)
				{
					if (array[i] != null && array[i] == allCharacter.characterName)
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					Vector3 val2 = ((Component)allCharacter).transform.position + Vector3.up * 2.4f;
					Vector3 val3 = Camera.main.WorldToScreenPoint(val2);
					if (!(val3.z < 0f))
					{
						float x = val3.x;
						float num4 = (float)Screen.height - val3.y;
						((Rect)(ref val4))..ctor(x - 52f, num4 - 44f, 104f, 28f);
						GUI.DrawTexture(val4, (Texture)(object)UI.TagPlateTex);
						GUI.Label(val4, "杀手", UI.Tag);
					}
				}
			}
		}
	}
	public class RunNet : MonoBehaviour
	{
		[PunRPC]
		public void RunStart(string names, int protectSecs, PhotonMessageInfo info)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (FromMaster(info))
			{
				RunGame.OnRunStart(names, protectSecs);
			}
		}

		[PunRPC]
		public void RunAnnounce(string msg, PhotonMessageInfo info)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (FromMaster(info))
			{
				RunGame.OnRunAnnounce(msg);
			}
		}

		[PunRPC]
		public void RunEnd(string msg, PhotonMessageInfo info)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (FromMaster(info))
			{
				RunGame.OnRunEnd(msg);
			}
		}

		[PunRPC]
		public void RunState(string data, PhotonMessageInfo info)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (FromMaster(info))
			{
				RunGame.OnRunState(data);
			}
		}

		private static bool FromMaster(PhotonMessageInfo info)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			return info.Sender != null && info.Sender.IsMasterClient;
		}
	}
	public class KState
	{
		public Item knife = null;

		public int phase = 0;

		public float grantNextAt = 0f;

		public int grantTries = 0;

		public float flightStart = 0f;

		public int regrants = 0;

		public Vector3 lastPos = Vector3.zero;

		public float heldSince = 0f;
	}
	public static class RunGame
	{
		public class ClientRow
		{
			public string name = "";

			public float stamina = 0f;

			public string status = "";

			public bool killer = false;

			public bool elim = false;

			public bool me = false;
		}

		public static bool Active = false;

		public static bool ActiveSync = false;

		public static List<Character> Killers = new List<Character>();

		public static readonly HashSet<Character> Eliminated = new HashSet<Character>();

		public static readonly HashSet<Character> PassOutSet = new HashSet<Character>();

		public static readonly Dictionary<Character, float> PassOutRetry = new Dictionary<Character, float>();

		public static readonly Dictionary<Character, float> SummitDwell = new Dictionary<Character, float>();

		public static readonly Dictionary<Character, KState> KStates = new Dictionary<Character, KState>();

		public static int ProtectSeconds = 30;

		public static float ProtectUntil = 0f;

		public static bool HostSpectate = false;

		public static Vector3 SummitPos = Vector3.zero;

		public static bool SummitSet = false;

		public static bool SummitManual = false;

		private static readonly List<GameObject> _drops = new List<GameObject>();

		public static int KillerCountSetting = 0;

		public static float HitRadius = 2.5f;

		public static float ReturnDelay = 5f;

		public static float SummitRadius = 5f;

		public static float SummitHoldTime = 3f;

		public static int MysteryDropCount = 8;

		public static float CurseRadius = 1.5f;

		public static string BannerText = null;

		public static float BannerUntil = 0f;

		public static string KillerNames = "";

		public static string Status = "未开始";

		public static readonly string RulesText = "1. F9 开关面板;房主在开赛前调整规则,开赛后规则锁定。\n2. 开局有 30 秒保护期,杀手拿到刀也暂时不能行动。\n3. 角色随机抽取,房主可以预先指定杀手;人数 ≥8 时可能出现 2 名杀手。\n4. 杀手只有一把仪式匕首,投掷命中即淘汰,落空 5 秒后自动回收重发。\n5. 逃生者登上山顶篝火停留 3 秒即获胜;杀手淘汰全部逃生者获胜。\n6. 神秘道具接触后随机生效:正面增益或负面状态,目标随机为捡到者或杀手。\n7. 被淘汰后进入观战,可用游戏观战键切换任意玩家视角。\n8. 玩家端只读:可查看杀手、玩家名单、体力与负面状态,不能修改任何设置。\n9. 本 mod 为独立插件,所有玩家安装后才会同步开赛提示与杀手标记。";

		public static bool ShowRules = true;

		public static bool ShowHelp = false;

		public static bool ShowAuthor = false;

		private const string KNIFE_PREFAB = "0_Items/RitualDagger";

		private static readonly string[] _buffPrefabs = new string[5] { "Amulet_Healing", "Amulet_SuperJump", "Amulet_InfiniteStamina", "ClimbingChalk", "HealingPuffShroom" };

		public static Character DesignatedKiller = null;

		public static readonly List<ClientRow> ClientRows = new List<ClientRow>();

		private static float _lastSync = 0f;

		private static float _lastTick = 0f;

		public static int Tab = 0;

		private static Vector2 _playersScroll;

		private static Vector2 _aboutScroll;

		private static readonly string[] HostTabs = new string[7] { "主页", "玩家", "规则", "场地", "功能", "联机", "关于" };

		private static readonly string[] ClientTabs = new string[3] { "主页", "玩家", "关于" };

		private static readonly int[] HostPages = new int[7] { 0, 1, 2, 3, 4, 5, 6 };

		private static readonly int[] ClientPages = new int[3] { 0, 1, 6 };

		private static readonly string[] StatusNames = new string[15]
		{
			"受伤", "饥饿", "寒冷", "中毒", "螃蟹", "诅咒", "困倦", "负重", "炎热", "荆棘",
			"孢子", "蛛网", "箭矢", "石化", "捕蝇草"
		};

		public static List<Character> RealPlayersPublic()
		{
			return RealPlayers();
		}

		private static void SyncTick()
		{
			if (Time.time - _lastSync < 0.5f)
			{
				return;
			}
			_lastSync = Time.time;
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(Active ? "1" : "0").Append('|');
			stringBuilder.Append(KillerNames.Replace('|', '/').Replace(';', '/')).Append('|');
			stringBuilder.Append(Status.Replace('|', '/').Replace(';', '/'));
			if (Character.AllCharacters != null)
			{
				foreach (Character allCharacter in Character.AllCharacters)
				{
					if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter.data == (Object)null) && (Character.AllBotCharacters == null || !Character.AllBotCharacters.Contains(allCharacter)))
					{
						float num = 1f;
						try
						{
							num = Mathf.Max(1f, allCharacter.data.TotalStamina);
						}
						catch
						{
						}
						float num2 = Mathf.Clamp01(allCharacter.data.currentStamina / num);
						stringBuilder.Append(';');
						stringBuilder.Append(NameOf(allCharacter).Replace('|', '/').Replace(';', '/').Replace(',', '/'));
						stringBuilder.Append('|').Append(Mathf.RoundToInt(num2 * 100f));
						stringBuilder.Append('|').Append(StatusText(allCharacter).Replace('|', '/'));
						stringBuilder.Append('|').Append(IsKiller(allCharacter) ? "1" : "0");
						stringBuilder.Append('|').Append((Eliminated.Contains(allCharacter) || PassOutSet.Contains(allCharacter)) ? "1" : "0");
						stringBuilder.Append('|').Append("0");
					}
				}
			}
			PhotonView val = HostPv();
			if ((Object)(object)val != (Object)null)
			{
				val.RPC("RunState", (RpcTarget)1, new object[1] { stringBuilder.ToString() });
			}
		}

		public static void OnRunState(string data)
		{
			if (string.IsNullOrEmpty(data))
			{
				return;
			}
			try
			{
				string[] array = data.Split(';');
				string[] array2 = array[0].Split('|');
				ActiveSync = array2.Length != 0 && array2[0] == "1";
				KillerNames = ((array2.Length > 1) ? array2[1] : "");
				string text = ((array2.Length > 2) ? array2[2] : "");
				string text2 = (((Object)(object)Character.localCharacter != (Object)null) ? NameOf(Character.localCharacter) : "");
				ClientRows.Clear();
				for (int i = 1; i < array.Length; i++)
				{
					string[] array3 = array[i].Split('|');
					if (array3.Length >= 6)
					{
						ClientRow clientRow = new ClientRow();
						clientRow.name = array3[0];
						if (!int.TryParse(array3[1], out var result))
						{
							result = 0;
						}
						clientRow.stamina = Mathf.Clamp01((float)result / 100f);
						clientRow.status = array3[2];
						clientRow.killer = array3[3] == "1";
						clientRow.elim = array3[4] == "1";
						clientRow.me = clientRow.name == text2;
						ClientRows.Add(clientRow);
					}
				}
				if (text != "" && !PhotonNetwork.IsMasterClient)
				{
					Status = text;
				}
			}
			catch
			{
			}
		}

		private static PhotonView HostPv()
		{
			if ((Object)(object)Character.localCharacter == (Object)null)
			{
				return null;
			}
			return ((Component)Character.localCharacter).GetComponent<PhotonView>();
		}

		private static void RpcStart(string names)
		{
			PhotonView val = HostPv();
			if ((Object)(object)val != (Object)null)
			{
				val.RPC("RunStart", (RpcTarget)0, new object[2] { names, ProtectSeconds });
			}
		}

		private static void RpcAnnounce(string msg)
		{
			PhotonView val = HostPv();
			if ((Object)(object)val != (Object)null)
			{
				val.RPC("RunAnnounce", (RpcTarget)0, new object[1] { msg });
			}
		}

		private static void RpcEnd(string msg)
		{
			PhotonView val = HostPv();
			if ((Object)(object)val != (Object)null)
			{
				val.RPC("RunEnd", (RpcTarget)0, new object[1] { msg });
			}
		}

		public static void OnRunStart(string names, int protectSecs)
		{
			KillerNames = ((names == null) ? "" : names);
			ProtectUntil = Time.time + (float)protectSecs;
			ActiveSync = true;
			Active = true;
			string text = names.Replace(',', '、');
			if (names.Contains(","))
			{
				BannerText = "游戏开始!杀手:" + text;
			}
			else
			{
				BannerText = "游戏开始!" + text + " 是杀手!";
			}
			BannerUntil = Time.time + 6f;
			if (PhotonNetwork.IsMasterClient)
			{
				Status = "回合进行中";
			}
		}

		public static void OnRunAnnounce(string msg)
		{
			if (msg != null && !(msg == ""))
			{
				BannerText = msg;
				BannerUntil = Time.time + 5f;
				if (PhotonNetwork.IsMasterClient)
				{
					Status = msg;
				}
			}
		}

		public static void OnRunEnd(string msg)
		{
			ActiveSync = false;
			Active = false;
			KillerNames = "";
			if (msg != null && msg != "")
			{
				BannerText = msg;
				BannerUntil = Time.time + 5f;
			}
			if (PhotonNetwork.IsMasterClient)
			{
				Status = ((msg == null) ? "回合结束" : msg);
			}
		}

		private static bool Alive(Character c)
		{
			return (Object)(object)c != (Object)null && (Object)(object)c.data != (Object)null && !c.data.dead;
		}

		private static bool IsRealPlayer(Character c)
		{
			if ((Object)(object)c == (Object)null || Character.AllCharacters == null || Character.AllBotCharacters == null)
			{
				return false;
			}
			if (!Character.AllCharacters.Contains(c))
			{
				return false;
			}
			if (Character.AllBotCharacters.Contains(c))
			{
				return false;
			}
			return Alive(c);
		}

		private static bool IsKiller(Character c)
		{
			for (int i = 0; i < Killers.Count; i++)
			{
				if ((Object)(object)Killers[i] == (Object)(object)c)
				{
					return true;
				}
			}
			return false;
		}

		private static string NameOf(Character c)
		{
			if ((Object)(object)c == (Object)null)
			{
				return "?";
			}
			string text = c.characterName;
			if (string.IsNullOrEmpty(text))
			{
				text = "玩家";
			}
			return text;
		}

		private static List<Character> RealPlayers()
		{
			List<Character> list = new List<Character>();
			if (Character.AllCharacters == null)
			{
				return list;
			}
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (IsRealPlayer(allCharacter) && (!HostSpectate || !((Object)(object)allCharacter == (Object)(object)Character.localCharacter)))
				{
					list.Add(allCharacter);
				}
			}
			return list;
		}

		private static List<Item> WorldKnives()
		{
			List<Item> list = new List<Item>();
			if (Item.ALL_ACTIVE_ITEMS == null)
			{
				return list;
			}
			foreach (Item aLL_ACTIVE_ITEM in Item.ALL_ACTIVE_ITEMS)
			{
				if (!((Object)(object)aLL_ACTIVE_ITEM == (Object)null) && !((Object)(object)((Component)aLL_ACTIVE_ITEM).gameObject == (Object)null) && ((Component)aLL_ACTIVE_ITEM).gameObject.activeInHierarchy && ((Object)((Component)aLL_ACTIVE_ITEM).gameObject).name != null && ((Object)((Component)aLL_ACTIVE_ITEM).gameObject).name.Contains("RitualDagger"))
				{
					list.Add(aLL_ACTIVE_ITEM);
				}
			}
			return list;
		}

		private static void DestroyUnownedKnives()
		{
			foreach (Item item in WorldKnives())
			{
				bool flag = false;
				foreach (KeyValuePair<Character, KState> kState in KStates)
				{
					KState value = kState.Value;
					if (value != null && (Object)(object)value.knife != (Object)null && (Object)(object)((Component)value.knife).gameObject != (Object)null && (Object)(object)((Component)value.knife).gameObject == (Object)(object)((Component)item).gameObject)
					{
						flag = true;
						break;
					}
				}
				if (!flag && (Object)(object)((Component)item).gameObject != (Object)null)
				{
					PhotonNetwork.Destroy(((Component)item).gameObject);
				}
			}
		}

		private static void DestroyAllKnives()
		{
			foreach (Item item in WorldKnives())
			{
				if ((Object)(object)((Component)item).gameObject != (Object)null)
				{
					PhotonNetwork.Destroy(((Component)item).gameObject);
				}
			}
		}

		public static void Tick()
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			HostTools.Tick();
			SyncTick();
			if (!Active || Time.time - _lastTick < 0.1f)
			{
				return;
			}
			_lastTick = Time.time;
			if (Killers.Count == 0)
			{
				EndRound("杀手全部离开,逃生者获胜!");
				return;
			}
			bool flag = false;
			List<Character> list = new List<Character>();
			for (int i = 0; i < Killers.Count; i++)
			{
				Character val = Killers[i];
				if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null)
				{
					list.Add(val);
				}
				else if (!Eliminated.Contains(val))
				{
					if (!IsRealPlayer(val))
					{
						list.Add(val);
					}
					else
					{
						flag = true;
					}
				}
			}
			foreach (Character item in list)
			{
				Killers.Remove(item);
				KStates.Remove(item);
				RpcAnnounce("杀手 " + NameOf(item) + " 失效,剩余杀手 " + Killers.Count + " 人");
			}
			if (Killers.Count == 0)
			{
				EndRound("杀手全部离开,逃生者获胜!");
				return;
			}
			if (!flag)
			{
				EndRound("杀手已阵亡,逃生者获胜!");
				return;
			}
			KeepSpectating();
			if (Time.time < ProtectUntil)
			{
				return;
			}
			foreach (Character killer in Killers)
			{
				if (!((Object)(object)killer == (Object)null) && !((Object)(object)killer.data == (Object)null))
				{
					if (!KStates.TryGetValue(killer, out var value))
					{
						value = new KState();
						KStates[killer] = value;
					}
					TryGrantKnife(killer, value);
					HandleKnife(killer, value);
				}
			}
			TryMysteryPickups();
			CheckSummitWin();
			CheckKillerWin();
		}

		private static void KeepSpectating()
		{
			List<Character> list = new List<Character>(PassOutSet);
			foreach (Character item in list)
			{
				if ((Object)(object)item == (Object)null || (Object)(object)item.data == (Object)null)
				{
					continue;
				}
				if (!PassOutRetry.TryGetValue(item, out var value))
				{
					value = 0f;
				}
				if (!item.data.fullyPassedOut && Time.time >= value)
				{
					PhotonView component = ((Component)item).GetComponent<PhotonView>();
					if ((Object)(object)component != (Object)null)
					{
						component.RPC("RPCA_PassOut", (RpcTarget)0, new object[0]);
					}
					PassOutRetry[item] = Time.time + 2f;
				}
			}
		}

		private static void TryGrantKnife(Character killer, KState ks)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if (ks.phase == 1 || ks.phase == 2 || ks.phase == 3 || (ks.phase == 0 && Time.time < ks.grantNextAt) || (ks.phase == 4 && Time.time < ks.grantNextAt))
			{
				return;
			}
			if (ks.phase == 4)
			{
				ks.phase = 0;
				ks.grantTries = 0;
			}
			DestroyUnownedKnives();
			GameObject val = PhotonNetwork.Instantiate("0_Items/RitualDagger", ((Component)killer).transform.position + Vector3.up * 1.2f, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val == (Object)null)
			{
				ks.grantNextAt = Time.time + 0.6f;
				ks.grantTries++;
				if (ks.grantTries > 8)
				{
					Status = "发刀失败(多次重试)";
				}
				return;
			}
			Item component = val.GetComponent<Item>();
			if ((Object)(object)component == (Object)null)
			{
				PhotonNetwork.Destroy(val);
				ks.grantNextAt = Time.time + 0.6f;
				return;
			}
			ks.knife = component;
			ks.phase = 1;
			ks.grantNextAt = Time.time + 0.4f;
			ks.grantTries = 0;
		}

		private static void HandleKnife(Character killer, KState ks)
		{
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			Item knife = ks.knife;
			if ((Object)(object)knife == (Object)null || (Object)(object)((Component)knife).gameObject == (Object)null)
			{
				ks.knife = null;
				ks.phase = 0;
				ks.grantNextAt = Mathf.Max(ks.grantNextAt, Time.time + 0.6f);
				return;
			}
			bool activeInHierarchy = ((Component)knife).gameObject.activeInHierarchy;
			if (ks.phase == 1)
			{
				if (activeInHierarchy)
				{
					if (Time.time >= ks.grantNextAt && (Object)(object)killer.data != (Object)null)
					{
						try
						{
							knife.Interact(killer);
						}
						catch (Exception ex)
						{
							RunPlugin.LogWarn("Interact fail: " + ex.Message);
						}
						ks.grantNextAt = Time.time + 0.6f;
						ks.grantTries++;
						if (ks.grantTries > 8)
						{
							ReturnKnife(killer, ks, 0.6f, "拾取超时,回收重发");
						}
					}
				}
				else
				{
					ks.phase = 2;
					ks.heldSince = Time.time;
				}
			}
			else if (ks.phase == 2)
			{
				if (activeInHierarchy)
				{
					ks.phase = 3;
					ks.flightStart = Time.time;
					ks.lastPos = knife.transform.position;
				}
				else if (ks.heldSince <= 0f)
				{
					ks.heldSince = Time.time;
				}
				else if (Time.time - ks.heldSince > 25f)
				{
					ReturnKnife(killer, ks, 0.6f, "刀长时间未使用,回收重发");
				}
			}
			else
			{
				if (ks.phase != 3)
				{
					return;
				}
				if (!activeInHierarchy)
				{
					ks.phase = 2;
					ks.heldSince = Time.time;
					return;
				}
				if (Time.time - ks.flightStart > ReturnDelay)
				{
					ReturnKnife(killer, ks, 0.6f, "落空 " + ReturnDelay + " 秒,回收重发");
					return;
				}
				Vector3 position = knife.transform.position;
				Vector3 a = ((ks.lastPos == Vector3.zero) ? position : ks.lastPos);
				ks.lastPos = position;
				List<Character> list = RealPlayers();
				for (int i = 0; i < list.Count; i++)
				{
					Character val = list[i];
					if (!((Object)(object)val == (Object)(object)killer) && !IsKiller(val) && !Eliminated.Contains(val) && !PassOutSet.Contains(val))
					{
						Vector3 p = ((Component)val).transform.position + Vector3.up * 0.9f;
						if (DistToSegment(p, a, position) <= HitRadius)
						{
							Eliminate(val);
							ReturnKnife(killer, ks, 1.2f, "命中 " + NameOf(val) + ",刀回收");
							break;
						}
					}
				}
			}
		}

		private static float DistToSegment(Vector3 p, Vector3 a, Vector3 b)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = b - a;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			if (sqrMagnitude < 0.0001f)
			{
				return Vector3.Distance(p, a);
			}
			float num = Mathf.Clamp01(Vector3.Dot(p - a, val) / sqrMagnitude);
			return Vector3.Distance(p, a + val * num);
		}

		private static void ReturnKnife(Character killer, KState ks, float delay, string why)
		{
			if ((Object)(object)ks.knife != (Object)null && (Object)(object)((Component)ks.knife).gameObject != (Object)null)
			{
				PhotonNetwork.Destroy(((Component)ks.knife).gameObject);
			}
			ks.knife = null;
			ks.phase = 4;
			ks.grantNextAt = Time.time + delay;
			ks.regrants++;
			if (why != null && why != "")
			{
				RpcAnnounce(why);
			}
			if (ks.regrants > 30)
			{
				EndRound("发刀异常,回合强制结束");
			}
		}

		public static void Eliminate(Character c)
		{
			if (!((Object)(object)c == (Object)null) && !((Object)(object)c.data == (Object)null) && !Eliminated.Contains(c))
			{
				Eliminated.Add(c);
				PassOutSet.Add(c);
				PassOutRetry[c] = Time.time + 0.5f;
				PhotonView component = ((Component)c).GetComponent<PhotonView>();
				if ((Object)(object)component != (Object)null)
				{
					component.RPC("RPCA_PassOut", (RpcTarget)0, new object[0]);
				}
				Status = NameOf(c) + " 被飞刀淘汰,进入观战模式!";
				RpcAnnounce(NameOf(c) + " 被飞刀淘汰!");
			}
		}

		public static void StartRound()
		{
			if (Active)
			{
				Status = "回合已在进行中";
				return;
			}
			if (!PhotonNetwork.IsMasterClient)
			{
				Status = "只有房主能开始";
				return;
			}
			List<Character> list = RealPlayers();
			if (list.Count < 2)
			{
				Status = "玩家不足 2 人,无法开始";
				return;
			}
			int num = Mathf.Min(2, list.Count - 1);
			int num2 = KillerCountSetting;
			if (num2 <= 0)
			{
				num2 = ((list.Count < 8) ? 1 : 2);
			}
			if (num2 > num)
			{
				num2 = num;
			}
			if (num2 < 1)
			{
				num2 = 1;
			}
			List<Character> list2 = new List<Character>(list);
			for (int num3 = list2.Count - 1; num3 > 0; num3--)
			{
				int index = Random.Range(0, num3 + 1);
				Character value = list2[num3];
				list2[num3] = list2[index];
				list2[index] = value;
			}
			Killers.Clear();
			if ((Object)(object)DesignatedKiller != (Object)null && list2.Contains(DesignatedKiller))
			{
				Killers.Add(DesignatedKiller);
				for (int i = 0; i < list2.Count; i++)
				{
					if (Killers.Count >= num2)
					{
						break;
					}
					if ((Object)(object)list2[i] != (Object)(object)DesignatedKiller)
					{
						Killers.Add(list2[i]);
					}
				}
			}
			else
			{
				for (int j = 0; j < num2; j++)
				{
					Killers.Add(list2[j]);
				}
			}
			KStates.Clear();
			foreach (Character killer in Killers)
			{
				KStates[killer] = new KState();
			}
			Eliminated.Clear();
			PassOutSet.Clear();
			PassOutRetry.Clear();
			SummitDwell.Clear();
			DestroyAllKnives();
			CleanupDrops();
			Active = true;
			ActiveSync = true;
			ProtectUntil = Time.time + (float)ProtectSeconds;
			Status = "回合开始:保护期 " + ProtectSeconds + " 秒";
			SpawnDrops();
			AutoSummit();
			string text = "";
			for (int k = 0; k < Killers.Count; k++)
			{
				if (k > 0)
				{
					text += ",";
				}
				text += NameOf(Killers[k]);
			}
			RpcStart(text);
			if (HostSpectate && (Object)(object)Character.localCharacter != (Object)null)
			{
				PassOutSet.Add(Character.localCharacter);
				PassOutRetry[Character.localCharacter] = Time.time + 0.5f;
				PhotonView component = ((Component)Character.localCharacter).GetComponent<PhotonView>();
				if ((Object)(object)component != (Object)null)
				{
					component.RPC("RPCA_PassOut", (RpcTarget)0, new object[0]);
				}
				Status = "房主观战中(可按游戏观战键切换任意玩家视角)";
			}
		}

		public static void EndRound(string reason)
		{
			if (!Active && !ActiveSync)
			{
				return;
			}
			List<Character> list = new List<Character>(PassOutSet);
			foreach (Character item in list)
			{
				if (!((Object)(object)item == (Object)null) && !((Object)(object)item.data == (Object)null))
				{
					PhotonView component = ((Component)item).GetComponent<PhotonView>();
					if ((Object)(object)component != (Object)null)
					{
						component.RPC("RPCA_UnPassOut", (RpcTarget)0, new object[0]);
					}
				}
			}
			DestroyAllKnives();
			CleanupDrops();
			KStates.Clear();
			Killers.Clear();
			Eliminated.Clear();
			PassOutSet.Clear();
			PassOutRetry.Clear();
			SummitDwell.Clear();
			Active = false;
			ActiveSync = false;
			RpcEnd(Status = ((reason == null) ? "回合结束" : reason));
		}

		private static void SpawnDrops()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < MysteryDropCount; i++)
			{
				Vector2 val = Random.insideUnitCircle * 45f;
				((Vector3)(ref val2))..ctor(val.x, 1f, val.y);
				GameObject val3 = PhotonNetwork.Instantiate("0_Items/Stone", val2, Quaternion.identity, (byte)0, (object[])null);
				if ((Object)(object)val3 != (Object)null)
				{
					_drops.Add(val3);
				}
			}
		}

		private static void CleanupDrops()
		{
			foreach (GameObject drop in _drops)
			{
				if ((Object)(object)drop != (Object)null)
				{
					PhotonNetwork.Destroy(drop);
				}
			}
			_drops.Clear();
		}

		private static void TryMysteryPickups()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			List<Character> list = RealPlayers();
			List<GameObject> list2 = new List<GameObject>();
			foreach (GameObject drop in _drops)
			{
				if ((Object)(object)drop == (Object)null)
				{
					list2.Add(drop);
					continue;
				}
				bool flag = false;
				for (int i = 0; i < list.Count; i++)
				{
					Character val = list[i];
					if (!((Object)(object)val == (Object)null) && !((Object)(object)val.data == (Object)null) && !Eliminated.Contains(val) && !PassOutSet.Contains(val) && Vector3.Distance(drop.transform.position, ((Component)val).transform.position) <= CurseRadius)
					{
						PhotonNetwork.Destroy(drop);
						list2.Add(drop);
						MysteryTrigger(val);
						flag = true;
						break;
					}
				}
				if (!flag)
				{
				}
			}
			foreach (GameObject item in list2)
			{
				_drops.Remove(item);
			}
		}

		private static void MysteryTrigger(Character picker)
		{
			if (!((Object)(object)picker == (Object)null))
			{
				bool flag = Random.value < 0.5f;
				Character val = ((Killers.Count <= 0 || !(Random.value < 0.5f)) ? picker : Killers[Random.Range(0, Killers.Count)]);
				if ((Object)(object)val == (Object)null)
				{
					val = picker;
				}
				string text = NameOf(picker) + " 触发神秘道具:";
				if (flag)
				{
					GrantPositiveBuff(val);
					Status = text + "正面增益 → " + NameOf(val);
					RpcAnnounce(NameOf(picker) + " 触发神秘道具:正面增益 → " + NameOf(val) + "!");
				}
				else
				{
					Curse(val);
					Status = text + "负面诅咒 → " + NameOf(val);
					RpcAnnounce(NameOf(picker) + " 触发神秘道具:负面诅咒 → " + NameOf(val) + "!");
				}
			}
		}

		private static void GrantPositiveBuff(Character target)
		{
			//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_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_0060: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target == (Object)null || (Object)(object)target.data == (Object)null)
			{
				return;
			}
			string text = _buffPrefabs[Random.Range(0, _buffPrefabs.Length)];
			GameObject val = PhotonNetwork.Instantiate("0_Items/" + text, ((Component)target).transform.position + Vector3.up * 1.2f, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Item component = val.GetComponent<Item>();
			if (!((Object)(object)component != (Object)null))
			{
				return;
			}
			try
			{
				component.Interact(target);
			}
			catch (Exception ex)
			{
				RunPlugin.LogWarn("buff Interact fail: " + ex.Message);
			}
		}

		private static void Curse(Character target)
		{
			if (!((Object)(object)target == (Object)null) && !((Object)(object)target.data == (Object)null))
			{
				float[] array = new float[15];
				array[6] = 0.8f;
				array[2] = 0.7f;
				array[3] = 0.5f;
				PhotonView component = ((Component)target).GetComponent<PhotonView>();
				if ((Object)(object)component != (Object)null)
				{
					component.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { array });
				}
			}
		}

		private static void CheckSummitWin()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (!SummitSet)
			{
				return;
			}
			List<Character> list = RealPlayers();
			for (int i = 0; i < list.Count; i++)
			{
				Character val = list[i];
				if (!IsKiller(val) && !Eliminated.Contains(val) && !PassOutSet.Contains(val))
				{
					if (!SummitDwell.TryGetValue(val, out var value))
					{
						value = 0f;
					}
					value = ((!(Vector3.Distance(((Component)val).transform.position, SummitPos) <= SummitRadius)) ? 0f : (value + Time.deltaTime));
					SummitDwell[val] = value;
					if (value >= SummitHoldTime)
					{
						EndRound("逃生者获胜!" + NameOf(val) + " 登顶成功!");
						break;
					}
				}
			}
		}

		private static void CheckKillerWin()
		{
			List<Character> list = RealPlayers();
			bool flag = false;
			for (int i = 0; i < list.Count; i++)
			{
				Character val = list[i];
				if (!IsKiller(val) && !Eliminated.Contains(val) && !PassOutSet.Contains(val))
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				EndRound("杀手获胜!全部逃生者已被淘汰!");
			}
		}

		public static void AutoSummit()
		{
			//IL_0046: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if (SummitManual)
			{
				SummitSet = true;
				return;
			}
			Campfire[] array = Object.FindObjectsOfType<Campfire>();
			if (array == null || array.Length == 0)
			{
				SummitSet = false;
				return;
			}
			Campfire val = array[0];
			for (int i = 1; i < array.Length; i++)
			{
				if (((Component)array[i]).transform.position.y > ((Component)val).transform.position.y)
				{
					val = array[i];
				}
			}
			SummitPos = ((Component)val).transform.position;
			SummitSet = true;
		}

		public static void MarkSummitHere()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Character.localCharacter == (Object)null))
			{
				SummitPos = ((Component)Character.localCharacter).transform.position;
				SummitSet = true;
				SummitManual = true;
				Status = "山顶已标记为当前位置";
			}
		}

		public static void DrawPanel()
		{
			bool isMasterClient = PhotonNetwork.IsMasterClient;
			string[] array = (isMasterClient ? HostTabs : ClientTabs);
			int[] array2 = (isMasterClient ? HostPages : ClientPages);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			for (int i = 0; i < array.Length; i++)
			{
				TabButton(array2[i], array[i]);
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
			switch (Tab)
			{
			case 1:
				PagePlayers();
				break;
			case 2:
				PageRules();
				break;
			case 3:
				PageField();
				break;
			case 4:
				PageFunc();
				break;
			case 5:
				PageNet();
				break;
			case 6:
				PageAbout();
				break;
			default:
				PageMain();
				break;
			}
		}

		private static void TabButton(int index, string label)
		{
			if (GUILayout.Button(label, (Tab == index) ? UI.TabOn : UI.TabOff, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				Tab = index;
			}
		}

		private static void PageMain()
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: 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_060e: Unknown result type (might be due to invalid IL or missing references)
			bool isMasterClient = PhotonNetwork.IsMasterClient;
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(isMasterClient ? "房主端" : "玩家端", UI.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(48f) });
			GUILayout.Label(isMasterClient ? "可调整规则、开启功能" : "只读:仅可查看信息", UI.Small, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.Space(8f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			Color color = GUI.color;
			GUI.color = ((!Active) ? UI.Ok : ((ProtectUntil > Time.time) ? UI.Warn : UI.Danger));
			GUI.DrawTexture(GUILayoutUtility.GetRect(4f, 42f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(4f) }), (Texture)(object)UI.WhiteTex);
			GUI.color = color;
			GUILayout.Space(12f);
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Label(Status, UI.Status, Array.Empty<GUILayoutOption>());
			int num = Mathf.CeilToInt(ProtectUntil - Time.time);
			if (Active)
			{
				GUILayout.Label((num > 0) ? ("保护期\u3000剩 " + num + " 秒,杀手暂不可行动") : "保护期已结束\u3000杀手可以出击", UI.Small, Array.Empty<GUILayoutOption>());
			}
			else
			{
				GUILayout.Label(isMasterClient ? "未开赛,可先指定杀手" : "等待房主开赛", UI.Small, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
			if (Active)
			{
				GUILayout.Space(10f);
				float num2 = Mathf.Clamp01((ProtectUntil - Time.time) / Mathf.Max(1f, (float)ProtectSeconds));
				Rect rect = GUILayoutUtility.GetRect(1f, 3f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
				GUI.DrawTexture(rect, (Texture)(object)UI.TrackTex);
				if (num2 > 0f)
				{
					GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width * num2, ((Rect)(ref rect)).height), (Texture)(object)UI.AccentTex);
				}
			}
			GUILayout.EndVertical();
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			GUILayout.Label("本回合", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			if (isMasterClient)
			{
				if (!Active)
				{
					if (GUILayout.Button(((Object)(object)DesignatedKiller != (Object)null) ? "开始回合(已指定杀手)" : "开始回合(随机抽取杀手)", UI.BtnPrimary, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(46f) }))
					{
						StartRound();
					}
					GUILayout.Space(10f);
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Label("房主身份", UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) });
					GUILayout.Label(HostSpectate ? "观战" : "游玩", UI.Label, Array.Empty<GUILayoutOption>());
					GUILayout.FlexibleSpace();
					if (GUILayout.Button(HostSpectate ? "改为游玩" : "改为观战", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(96f),
						GUILayout.Height(30f)
					}))
					{
						HostSpectate = !HostSpectate;
						if (!HostSpectate)
						{
							HostTools.RestoreSandbox();
						}
					}
					GUILayout.EndHorizontal();
					GUILayout.Label(HostSpectate ? "观战房主可用飞天/加速/传送" : "游玩中不能开启飞天/加速/传送", UI.Small, Array.Empty<GUILayoutOption>());
					GUILayout.Space(8f);
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Label("杀手数量", UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) });
					GUILayout.FlexibleSpace();
					if (GUILayout.Button("−", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(26f),
						GUILayout.Height(26f)
					}))
					{
						KillerCountSetting = ((KillerCountSetting <= 0) ? 1 : 0);
					}
					GUILayout.Label((KillerCountSetting == 0) ? "自动" : KillerCountSetting.ToString(), UI.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(46f) });
					if (GUILayout.Button("+", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(26f),
						GUILayout.Height(26f)
					}))
					{
						KillerCountSetting = ((KillerCountSetting < 2) ? ((KillerCountSetting == 0) ? 1 : 2) : 0);
					}
					GUILayout.EndHorizontal();
					GUILayout.Label("自动\u30007 人以下 1 名,8 人以上 2 名", UI.Small, Array.Empty<GUILayoutOption>());
				}
				else if (GUILayout.Button("结束本回合", UI.BtnDanger, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
				{
					EndRound("回合已结束");
				}
			}
			else
			{
				GUILayout.Label(Active ? "回合进行中" : "等待房主开赛", UI.Small, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			GUILayout.Label("概览", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("杀手", UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) });
			GUI.color = ((KillerNames == "") ? UI.Text3 : UI.Danger);
			GUILayout.Label((KillerNames == "") ? "未抽取" : KillerNames.Replace(',', '、'), UI.Label, Array.Empty<GUILayoutOption>());
			GUI.color = Color.white;
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("玩家", UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) });
			GUILayout.Label((isMasterClient ? RealPlayers().Count : ClientRows.Count) + " 人", UI.Label, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Label(isMasterClient ? ("存活 " + AliveSurvivors()) : "", UI.Small, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			if (isMasterClient)
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUILayout.Label("山顶", UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) });
				GUILayout.Label((!SummitSet) ? "未设定" : (SummitManual ? "已设定(手动)" : "已设定(最高篝火)"), SummitSet ? UI.Label : UI.Small, Array.Empty<GUILayoutOption>());
				GUILayout.EndHorizontal();
			}
			if (isMasterClient)
			{
				GUILayout.Space(10f);
				UI.Line();
				GUILayout.Space(8f);
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				if (GUILayout.Button("查看玩家", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
				{
					Tab = 1;
				}
				if (GUILayout.Button("调整规则", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
				{
					Tab = 2;
				}
				if (GUILayout.Button("房主功能", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
				{
					Tab = 4;
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndVertical();
		}

		private static int AliveSurvivors()
		{
			int num = 0;
			foreach (Character item in RealPlayers())
			{
				if (!Eliminated.Contains(item) && !PassOutSet.Contains(item))
				{
					num++;
				}
			}
			return num;
		}

		private static void PagePlayers()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			bool isMasterClient = PhotonNetwork.IsMasterClient;
			int num = (isMasterClient ? RealPlayers().Count : ClientRows.Count);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("玩家名单", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Label(num + " 人", UI.Small, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Label(isMasterClient ? "点“指定”可钦定下一局的杀手" : "只读:体力与负面状态由房主同步", UI.Small, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			_playersScroll = GUILayout.BeginScrollView(_playersScroll, Array.Empty<GUILayoutOption>());
			if (isMasterClient)
			{
				List<Character> allCharacters = Character.AllCharacters;
				if (allCharacters != null)
				{
					foreach (Character item in allCharacters)
					{
						if (!((Object)(object)item == (Object)null) && !((Object)(object)item.data == (Object)null) && (Character.AllBotCharacters == null || !Character.AllBotCharacters.Contains(item)) && (!HostSpectate || !((Object)(object)item == (Object)(object)Character.localCharacter)))
						{
							PlayerRowLive(item, isMasterClient);
						}
					}
				}
			}
			else
			{
				for (int i = 0; i < ClientRows.Count; i++)
				{
					ClientRow r = ClientRows[i];
					PlayerRowSynced(r, isMasterClient);
				}
				if (ClientRows.Count == 0)
				{
					GUILayout.Label("暂无玩家", UI.Small, Array.Empty<GUILayoutOption>());
				}
			}
			GUILayout.EndScrollView();
		}

		private static void PlayerRowLive(Character c, bool master)
		{
			//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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			bool isMe = (Object)(object)c == (Object)(object)Character.localCharacter;
			float num = 1f;
			try
			{
				num = Mathf.Max(1f, c.data.TotalStamina);
			}
			catch
			{
				num = 1f;
			}
			float pct = Mathf.Clamp01(c.data.currentStamina / num);
			string tag;
			Color tagColor;
			if (IsKiller(c))
			{
				tag = "杀手";
				tagColor = UI.Danger;
			}
			else if (Eliminated.Contains(c) || PassOutSet.Contains(c))
			{
				tag = "已淘汰";
				tagColor = UI.Text3;
			}
			else
			{
				tag = "逃生者";
				tagColor = UI.Text2;
			}
			DrawPlayerCard(isMe, NameOf(c), pct, StatusText(c), tag, tagColor);
			if (master && !Active)
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUILayout.FlexibleSpace();
				bool flag = (Object)(object)DesignatedKiller == (Object)(object)c;
				if (GUILayout.Button(flag ? "取消指定" : "指定为杀手", flag ? UI.TabOn : UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(96f),
					GUILayout.Height(24f)
				}))
				{
					DesignatedKiller = (flag ? null : c);
				}
				GUILayout.EndHorizontal();
			}
		}

		private static void PlayerRowSynced(ClientRow r, bool master)
		{
			//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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			string tag;
			Color tagColor;
			if (r.killer)
			{
				tag = "杀手";
				tagColor = UI.Danger;
			}
			else if (r.elim)
			{
				tag = "已淘汰";
				tagColor = UI.Text3;
			}
			else
			{
				tag = "逃生者";
				tagColor = UI.Text2;
			}
			DrawPlayerCard(r.me, r.name, r.stamina, r.status, tag, tagColor);
		}

		private static void DrawPlayerCard(bool isMe, string name, float pct, string status, string tag, Color tagColor)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUI.color = (isMe ? UI.Accent : UI.Text);
			GUILayout.Label((isMe ? "● " : "\u3000") + name, UI.Name, Array.Empty<GUILayoutOption>());
			GUI.color = Color.white;
			GUILayout.FlexibleSpace();
			GUI.color = tagColor;
			GUILayout.Label(tag, UI.TagCell, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(56f) });
			GUI.color = Color.white;
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("体力", UI.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) });
			Rect rect = GUILayoutUtility.GetRect(110f, 8f, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(110f),
				GUILayout.Height(8f)
			});
			GUI.DrawTexture(rect, (Texture)(object)UI.TrackTex);
			if (pct > 0f)
			{
				Color color = GUI.color;
				GUI.color = ((pct > 0.5f) ? UI.Ok : ((pct > 0.2f) ? UI.Warn : UI.Danger));
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width * Mathf.Clamp01(pct), ((Rect)(ref rect)).height), (Texture)(object)UI.WhiteTex);
				GUI.color = color;
			}
			GUILayout.Label(Mathf.RoundToInt(pct * 100f) + "%", UI.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(42f) });
			GUILayout.FlexibleSpace();
			GUILayout.Label(status, UI.Small, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}

		private static string StatusText(Character c)
		{
			if ((Object)(object)c == (Object)null || c.refs == null || (Object)(object)c.refs.afflictions == (Object)null)
			{
				return "状态正常";
			}
			float[] currentStatuses = c.refs.afflictions.currentStatuses;
			if (currentStatuses == null)
			{
				return "状态正常";
			}
			string text = "";
			int num = 0;
			for (int i = 0; i < currentStatuses.Length && i < StatusNames.Length; i++)
			{
				if (!(currentStatuses[i] < 0.05f))
				{
					if (num >= 3)
					{
						text += " …";
						break;
					}
					if (num > 0)
					{
						text += " · ";
					}
					text = text + StatusNames[i] + " " + Mathf.RoundToInt(currentStatuses[i]);
					num++;
				}
			}
			return (num == 0) ? "状态正常" : text;
		}

		private static void PageRules()
		{
			GUILayout.Label("可调规则", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			KnobRow("飞刀命中半径", ref HitRadius, 1f, 0.5f, 6f);
			KnobRow("落空回收秒数", ref ReturnDelay, 1f, 1f, 10f);
			KnobRow("山顶判定半径", ref SummitRadius, 1f, 1f, 12f);
			KnobRow("山顶停留秒数", ref SummitHoldTime, 1f, 1f, 10f);
			KnobRow("神秘道具数量", ref MysteryDropCount, 1, 1, 20);
			KnobRow("道具触发半径", ref CurseRadius, 0.5f, 0.5f, 5f);
			GUILayout.EndVertical();
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			GUILayout.Label("不可修改", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			GUILayout.Label("30 秒保护期", UI.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Label("角色随机或房主指定,开赛后锁定", UI.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Label("单刀制,任何时刻只存在一把", UI.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Label("投掷命中直接淘汰", UI.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Label("开赛与结果全员可见", UI.Label, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
		}

		private static void PageField()
		{
			GUILayout.Label("山顶设定", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			GUILayout.Label("逃生者在山顶范围内停留到计时结束即获胜。", UI.Notice, Array.Empty<GUILayoutOption>());
			GUILayout.Space(10f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("标记当前位置", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }))
			{
				MarkSummitHere();
			}
			if (GUILayout.Button("用最高篝火", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }))
			{
				SummitManual = false;
				AutoSummit();
				Status = (SummitSet ? "山顶为最高篝火" : "未找到篝火");
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
			UI.Line();
			GUILayout.Space(8f);
			GUILayout.Label(SummitSet ? ("当前山顶\u3000" + ((Vector3)(ref SummitPos)).ToString("F1") + (SummitManual ? "(手动标记)" : "(最高篝火)")) : "尚未设定\u3000逃生者暂时无法靠登顶获胜", UI.Label, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
		}

		private static void PageFunc()
		{
			GUILayout.Label("房主功能", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			if (!PhotonNetwork.IsMasterClient)
			{
				GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
				GUILayout.Label("只有房主客户端能使用功能页。", UI.Notice, Array.Empty<GUILayoutOption>());
				GUILayout.EndVertical();
				return;
			}
			GUILayout.Label("自身增强", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			bool flag = !Active || HostSpectate;
			GUILayout.Label((!flag) ? "本局已开始且你以玩家身份参战,自身增强已自动关闭并锁定,结束后再开" : (Active ? "本局进行中:以观战身份可继续使用" : "对本机角色即时生效(未开赛可用)"), UI.Small, Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			bool enabled = GUI.enabled;
			GUI.enabled = flag && enabled;
			if (GUILayout.Button(HostTools.Invincible ? "无限血量\u3000开" : "无限血量\u3000关", HostTools.Invincible ? UI.TabOn : UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) }))
			{
				HostTools.Invincible = !HostTools.Invincible;
				if (!HostTools.Invincible)
				{
					HostTools.ClearInvincible();
				}
			}
			GUILayout.Label("不再受到伤害与击倒判定", UI.Small, Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			if (GUILayout.Button(HostTools.IgnoreBuffs ? "无视负面状态\u3000开" : "无视负面状态\u3000关", HostTools.IgnoreBuffs ? UI.TabOn : UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) }))
			{
				HostTools.IgnoreBuffs = !HostTools.IgnoreBuffs;
			}
			GUILayout.Label("每 0.5 秒清空一次负面状态(受伤/寒冷/中毒等全部 15 项)", UI.Small, Array.Empty<GUILayoutOption>());
			GUI.enabled = enabled;
			GUILayout.EndVertical();
			GUILayout.Space(10f);
			GUILayout.Label("沙盒工具", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			bool available = HostTools.Available;
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			if (!available)
			{
				GUILayout.Label("当前不可开启", UI.Label, Array.Empty<GUILayoutOption>());
				GUILayout.Space(4f);
				GUILayout.Label((!PhotonNetwork.IsMasterClient) ? "只有房主客户端能开启功能。" : (Active ? "本局已开始,功能已锁定,结束后再开。" : "房主正在以玩家身份参与,请先在主页把身份改为“观战”。"), UI.Notice, Array.Empty<GUILayoutOption>());
				GUILayout.EndVertical();
				return;
			}
			GUILayout.Label("仅在未开赛且房主观战时可用", UI.Small, Array.Empty<GUILayoutOption>());
			GUILayout.Space(10f);
			if (GUILayout.Button(HostTools.Fly ? "飞天\u3000开" : "飞天\u3000关", HostTools.Fly ? UI.TabOn : UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) }))
			{
				HostTools.Fly = !HostTools.Fly;
			}
			GUILayout.Label("WASD 平移,空格上升,Ctrl 下降", UI.Small, Array.Empty<GUILayoutOption>());
			KnobRow("飞行速度", ref HostTools.FlySpeed, 1f, 2f, 30f);
			GUILayout.Space(8f);
			if (GUILayout.Button(HostTools.Speed ? "加速\u3000开" : "加速\u3000关", HostTools.Speed ? UI.TabOn : UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) }))
			{
				HostTools.Speed = !HostTools.Speed;
			}
			KnobRow("移速倍率", ref HostTools.SpeedMul, 0.5f, 1f, 5f);
			GUILayout.Space(8f);
			if (GUILayout.Button(HostTools.InfiniteStam ? "无限体力\u3000开" : "无限体力\u3000关", HostTools.InfiniteStam ? UI.TabOn : UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) }))
			{
				HostTools.InfiniteStam = !HostTools.InfiniteStam;
			}
			GUILayout.Space(10f);
			UI.Line();
			GUILayout.Space(8f);
			GUILayout.Label("传送", UI.Label, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("传送到准星", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) }))
			{
				HostTools.TeleportToAim();
			}
			if (GUILayout.Button("传送到下一位玩家", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) }))
			{
				HostTools.TeleportToNextPlayer();
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}

		private static void PageNet()
		{
			bool isMasterClient = PhotonNetwork.IsMasterClient;
			GUILayout.Label("多人联机", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			Room currentRoom = PhotonNetwork.CurrentRoom;
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("房间", UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) });
			GUILayout.Label((currentRoom != null) ? currentRoom.Name : "未加入房间", UI.Label, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("人数", UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) });
			GUILayout.Label((currentRoom != null) ? (currentRoom.PlayerCount + " / " + currentRoom.MaxPlayers) : "-", UI.Label, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Label(isMasterClient ? "房主" : "玩家", UI.Small, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			if (isMasterClient)
			{
				GUILayout.Space(10f);
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUILayout.Label("人数上限", UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) });
				GUILayout.FlexibleSpace();
				if (GUILayout.Button("−", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(26f),
					GUILayout.Height(26f)
				}))
				{
					SetMaxPlayers(-2);
				}
				GUILayout.Label((currentRoom != null) ? currentRoom.MaxPlayers.ToString() : "-", UI.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(46f) });
				if (GUILayout.Button("+", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(26f),
					GUILayout.Height(26f)
				}))
				{
					SetMaxPlayers(2);
				}
				GUILayout.EndHorizontal();
				GUILayout.Label("仅房主可改,新加入的玩家按键后的上限进入", UI.Small, Array.Empty<GUILayoutOption>());
			}
			else
			{
				GUILayout.Space(8f);
				GUILayout.Label("人数上限由房主设置", UI.Small, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
		}

		private static void SetMaxPlayers(int delta)
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			Room currentRoom = PhotonNetwork.CurrentRoom;
			if (currentRoom == null)
			{
				return;
			}
			int maxPlayers = Mathf.Clamp(currentRoom.MaxPlayers + delta, 2, 20);
			try
			{
				currentRoom.MaxPlayers = maxPlayers;
				Status = "人数上限改为 " + maxPlayers;
			}
			catch
			{
				Status = "人数上限修改失败";
			}
		}

		private static void PageAbout()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			_aboutScroll = GUILayout.BeginScrollView(_aboutScroll, Array.Empty<GUILayoutOption>());
			GUILayout.Label("玩法说明", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			GUILayout.Label(RulesText, UI.Notice, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
			GUILayout.Label("关于作者", UI.SectionTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			GUILayout.BeginVertical(UI.Card, Array.Empty<GUILayoutOption>());
			GUILayout.Label("本程序由 NeAi 打造\n如有侵权等行为请联系我删除\n反馈 Bug 等问题来抖音找我反馈吧\n作者抖音号:Tkhh1314", UI.Notice, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
			GUILayout.EndScrollView();
		}

		private static void KnobRow(string label, ref float val, float step, float min, float max)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(label, UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("−", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }))
			{
				val = Mathf.Max(min, val - step);
			}
			GUILayout.Label(val.ToString("F1"), UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(46f) });
			if (GUILayout.Button("+", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }))
			{
				val = Mathf.Min(max, val + step);
			}
			GUILayout.EndHorizontal();
		}

		private static void KnobRow(string label, ref int val, int step, int min, int max)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(label, UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("−", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }))
			{
				val = Mathf.Max(min, val - step);
			}
			GUILayout.Label(val.ToString(), UI.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(46f) });
			if (GUILayout.Button("+", UI.Btn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }))
			{
				val = Mathf.Min(max, val + step);
			}
			GUILayout.EndHorizontal();
		}
	}
	public static class HostTools
	{
		public static bool Fly = false;

		public static bool Speed = false;

		public static bool InfiniteStam = false;

		public static bool Invincible = false;

		public static bool IgnoreBuffs = false;

		public static float FlySpeed = 12f;

		public static float SpeedMul = 2f;

		private static float _baseMod = -1f;

		private static float _baseSprint = -1f;

		private static float _baseForce = -1f;

		private static bool _speedApplied = false;

		private static bool _stamApplied = false;

		private static bool _flyApplied = false;

		private static bool _invApplied = false;

		private static FieldInfo _invField;

		private static float _buffClearAt = 0f;

		private static int _tpIndex = 0;

		public static bool Available => PhotonNetwork.IsMasterClient && RunGame.HostSpectate && !RunGame.Active;

		public static void Tick()
		{
			Character localCharacter = Character.localCharacter;
			bool flag = PhotonNetwork.IsMasterClient && (!RunGame.Active || RunGame.HostSpectate);
			if (flag && (Object)(object)localCharacter != (Object)null && (Object)(object)localCharacter.data != (Object)null)
			{
				ApplyInvincible(localCharacter);
				ApplyIgnoreBuffs(localCharacter);
			}
			else if (!flag)
			{
				if (Invincible)
				{
					Invincible = false;
				}
				if (IgnoreBuffs)
				{
					IgnoreBuffs = false;
				}
				if (_invApplied)
				{
					ClearInvincible();
				}
			}
			if (!Available)
			{
				RestoreSandbox();
				return;
			}
			Character localCharacter2 = Character.localCharacter;
			if ((Object)(object)localCharacter2 == (Object)null || localCharacter2.refs == null)
			{
				RestoreSandbox();
				return;
			}
			ApplySpeed(localCharacter2);
			ApplyStam(localCharacter2);
			ApplyFly(localCharacter2);
		}

		public static void RestoreSandbox()
		{
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter != (Object)null && localCharacter.refs != null && (Object)(object)localCharacter.refs.movement != (Object)null && _speedApplied)
			{
				CharacterMovement movement = localCharacter.refs.movement;
				if (_baseMod >= 0f)
				{
					movement.movementModifier = _baseMod;
				}
				if (_baseSprint >= 0f)
				{
					movement.sprintMultiplier = _baseSprint;
				}
				if (_baseForce >= 0f)
				{
					movement.movementForce = _baseForce;
				}
			}
			_speedApplied = false;
			_baseMod = (_baseSprint = (_baseForce = -1f));
			if ((Object)(object)localCharacter != (Object)null && _stamApplied)
			{
				localCharacter.infiniteStam = false;
				_stamApplied = false;
			}
			if ((Object)(object)localCharacter != (Object)null && localCharacter.refs != null)
			{
				ReleaseFly(localCharacter);
			}
		}

		private static void ApplySpeed(Character c)
		{
			CharacterMovement movement = c.refs.movement;
			if ((Object)(object)movement == (Object)null)
			{
				return;
			}
			if (Speed)
			{
				if (!_speedApplied)
				{
					_baseMod = movement.movementModifier;
					_baseSprint = movement.sprintMultiplier;
					_baseForce = movement.movementForce;
					_speedApplied = true;
				}
				movement.movementModifier = _baseMod * SpeedMul;
				movement.sprintMultiplier = _baseSprint * SpeedMul;
				movement.movementForce = _baseForce * SpeedMul;
			}
			else if (_speedApplied)
			{
				movement.movementModifier = _baseMod;
				movement.sprintMultiplier = _baseSprint;
				movement.movementForce = _baseForce;
				_speedApplied = false;
				_baseMod = (_baseSprint = (_baseForce = -1f));
			}
		}

		private static void ApplyStam(Character c)
		{
			if (InfiniteStam)
			{
				if (!_stamApplied)
				{
					c.infiniteStam = true;
					_stamApplied = true;
				}
			}
			else if (_stamApplied)
			{
				c.infiniteStam = false;
				_stamApplied = false;
			}
		}

		private static void ApplyInvincible(Character c)
		{
			if ((Object)(object)c.data == (Object)null)
			{
				return;
			}
			if (_invField == null)
			{
				_invField = typeof(CharacterData).GetField("isInvincible", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			}
			if (_invField == null)
			{
				return;
			}
			try
			{
				if (Invincible)
				{
					if (!(bool)_invField.GetValue(c.data))
					{
						_invField.SetValue(c.data, true);
						_invApplied = true;
					}
				}
				else if (_invApplied)
				{
					_invField.SetValue(c.data, false);
					_invApplied = false;
					try
					{
						c.data.RecalculateInvincibility();
						return;
					}
					catch
					{
						return;
					}
				}
			}
			catch
			{
			}
		}

		public static void ClearInvincible()
		{
			if (!_invApplied)
			{
				return;
			}
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter != (Object)null && (Object)(object)localCharacter.data != (Object)null && _invField != null)
			{
				try
				{
					_invField.SetValue(localCharacter.data, false);
					try
					{
						localCharacter.data.RecalculateInvincibility();
					}
					catch
					{
					}
				}
				catch
				{
				}
			}
			_invApplied = false;
		}

		private static void ApplyIgnoreBuffs(Character c)
		{
			if (!IgnoreBuffs || c.refs == null || (Object)(object)c.refs.afflictions == (Object)null || Time.time < _buffClearAt || c.refs.afflictions.statusSum < 0.01f)
			{
				return;
			}
			_buffClearAt = Time.time + 0.5f;
			PhotonView component = ((Component)c).GetComponent<PhotonView>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			try
			{
				component.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { new float[15] });
				RunPlugin.Log("[HostTools] 已清除负面状态");
			}
			catch (Exception ex)
			{
				RunPlugin.LogWarn("[HostTools] 清状态失败: " + ex.Message);
			}
		}

		private static void ApplyFly(Character c)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			Bodypart hip = c.refs.hip;
			if ((Object)(object)hip == (Object)null || (Object)(object)hip.Rig == (Object)null)
			{
				return;
			}
			Rigidbody rig = hip.Rig;
			if (!Fly)
			{
				if (_flyApplied)
				{
					rig.useGravity = true;
					rig.velocity = Vector3.zero;
					_flyApplied = false;
				}
				return;
			}
			_flyApplied = true;
			Vector2 val = (((Object)(object)c.input != (Object)null) ? c.input.movementInput : Vector2.zero);
			float num = ReadAxis(CharacterInput.action_jump);
			float num2 = ReadAxis(CharacterInput.action_crouch);
			Transform val2 = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : null);
			Vector3 val3 = (((Object)(object)val2 != (Object)null) ? val2.forward : Vector3.forward);
			Vector3 val4 = (((Object)(object)val2 != (Object)null) ? val2.right : Vector3.right);
			Vector3 val5 = val3 * val.y + val4 * val.x + Vector3.up * (num - num2);
			rig.useGravity = false;
			rig.velocity = ((((Vector3)(ref val5)).sqrMagnitude > 0.0001f) ? (((Vector3)(ref val5)).normalized * FlySpeed) : Vector3.zero);
		}

		private static void ReleaseFly(Character c)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (_flyApplied)
			{
				Bodypart hip = c.refs.hip;
				if ((Object)(object)hip != (Object)null && (Object)(object)hip.Rig != (Object)null)
				{
					hip.Rig.useGravity = true;
					hip.Rig.velocity = Vector3.zero;
				}
				_flyApplied = false;
			}
		}

		private static float ReadAxis(InputAction a)
		{
			if (a == null)
			{
				return 0f;
			}
			try
			{
				return a.ReadValue<float>();
			}
			catch
			{
				return 0f;
			}
		}

		public static void TeleportToAim()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if (!((Object)(object)main == (Object)null))
			{
				RaycastHit val = default(RaycastHit);
				Vector3 pos = ((!Physics.Raycast(((Component)main).transform.position, ((Component)main).transform.forward, ref val, 300f, -1, (QueryTriggerInteraction)1)) ? (((Component)main).transform.position + ((Component)main).transform.forward * 30f) : (((RaycastHit)(ref val)).point + Vector3.up * 0.5f));
				Warp(pos);
			}
		}

		public static void TeleportToNextPlayer()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			List<Character> list = RunGame.RealPlayersPublic();
			if (list != null && list.Count != 0)
			{
				_tpIndex = (_tpIndex + 1) % list.Count;
				Character val = list[_tpIndex];
				if (!((Object)(object)val == (Object)null))
				{
					Warp(((Component)val).transform.position + Vector3.up * 0.8f);
				}
			}
		}

		private static void Warp(Vector3 pos)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			Character localCharacter = Character.localCharacter;
			if (!((Object)(object)localCharacter == (Object)null))
			{
				PhotonView component = ((Component)localCharacter).GetComponent<PhotonView>();
				if (!((Object)(object)component == (Object)null))
				{
					component.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { pos, true });
				}
			}
		}
	}
	internal static class UI
	{
		public static readonly Color Text = new Color(0.106f, 0.122f, 0.145f);

		public static readonly Color Text2 = new Color(0.29f, 0.329f, 0.365f);

		public static readonly Color Text3 = new Color(0.478f, 0.514f, 0.553f);

		public static readonly Color Accent = new Color(0.91f, 0.4f, 0.102f);

		public static readonly Color Ok = new Color(0.18f, 0.49f, 0.275f);

		public static readonly Color Warn = new Color(0.722f, 0.459f, 0.012f);

		public static readonly Color Danger = new Color(0.788f, 0.204f, 0.173f);

		public static readonly Color Info = new Color(0.122f, 0.435f, 0.749f);

		public static readonly Color Ink = new Color(1f, 1f, 1f);

		public static float S = 1f;

		public const float TitleH = 48f;

		public const float Pad = 14f;

		private static Texture2D _bg;

		private static Texture2D _title;

		private static Texture2D _card;

		private static Texture2D _head;

		private static Texture2D _row;

		private static Texture2D _rowAlt;

		private static Texture2D _line;

		private static Texture2D _white;

		private static Texture2D _accent;

		private static Texture2D _btn;

		private static Texture2D _btnH;

		private static Texture2D _dangerBg;

		private static Texture2D _dangerBgH;

		private static Texture2D _track;

		private static Texture2D _plate;

		private static Texture2D _hair;

		private static bool _built;

		public static GUIStyle Title;

		public static GUIStyle Sub;

		public static GUIStyle Section;

		public static GUIStyle SectionTitle;

		public static GUIStyle Card;

		public static GUIStyle Btn;

		public static GUIStyle BtnPrimary;

		public static GUIStyle BtnDanger;

		public static GUIStyle Label;

		public static GUIStyle Value;

		public static GUIStyle Small;

		public static GUIStyle Notice;

		public static GUIStyle Status;

		public static GUIStyle Author;

		public static GUIStyle Name;

		public static GUIStyle TagCell;

		public static GUIStyle Row;

		public static GUIStyle RowAlt;

		public static GUIStyle Banner;

		public static GUIStyle Tag;

		public static GUIStyle Cd;

		public static GUIStyle TabOn;

		public static GUIStyle TabOff;

		public static GUIStyle EscBig;

		private static Texture2D _winTex;

		private static int _winW;

		private static int _winH;

		public static Texture2D BgTex => _bg;

		public static Texture2D TitleTex => _title;

		public static Texture2D WhiteTex => _white;

		public static Texture2D TrackTex => _track;

		public static Texture2D AccentTex => _accent;

		public static Texture2D PlateTex => _plate;

		public static Texture2D TagPlateTex => _plate;

		public static Texture2D HairTex => _hair;

		private static Texture2D Tex(Color c)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, c);
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			return val;
		}

		public static Texture2D WinTex(int w, int h)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			w = Mathf.Clamp(w, 32, 2048);
			h = Mathf.Clamp(h, 32, 2048);
			if ((Object)(object)_winTex != (Object)null && _winW == w && _winH == h)
			{
				return _winTex;
			}
			if ((Object)(object)_winTex != (Object)null)
			{
				Object.Destroy((Object)(object)_winTex);
			}
			_winW = w;
			_winH = h;
			Texture2D val = new Texture2D(w, h, (TextureFormat)4, false);
			((Object)val).hideFlags = (HideFlags)61;
			Color32[] array = (Color32[])(object)new Color32[w * h];
			float num = 22f;
			float num2 = (float)w * 0.5f;
			float num3 = (float)h * 0.5f;
			for (int i = 0; i < h; i++)
			{
				float num4 = Mathf.Clamp01(((float)i - (float)h * 0.45f) / ((float)h * 0.55f));
				for (int j = 0; j < w; j++)
				{
					float num5 = Mathf.Abs((float)j + 0.5f - num2) - (num2 - num);
					float num6 = Mathf.Abs((float)i + 0.5f - num3) - (num3 - num);
					float num7 = Mathf.Max(num5, 0f);
					float num8 = Mathf.Max(num6, 0f);
					float num9 = Mathf.Min(Mathf.Max(num5, num6), 0f) + Mathf.Sqrt(num7 * num7 + num8 * num8) - num;
					float num10 = Mathf.Clamp01(0.5f - num9);
					float num11 = (0.76f + 0.14f * num4) * num10;
					float num12 = Mathf.Clamp01(1f - Mathf.Abs(num9 + 1.1f) / 1.3f);
					num11 = Mathf.Clamp01(num11 + num12 * 0.16f * num10);
					array[i * w + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num11 * 255f));
				}
			}
			val.SetPixels32(array);
			val.Apply();
			_winTex = val;
			return val;
		}

		private static int F(int pt)
		{
			return Mathf.RoundToInt((float)pt * S);
		}

		public static void Build()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00d5: Unknown result type (m