Decompiled source of Powerful Admin Tool v1.1.0

AdminTool.dll

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("AdminTool")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("AdminTool")]
[assembly: AssemblyTitle("AdminTool")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[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 AdminTool
{
	public static class Build
	{
		public static bool NoCost;

		public static bool NoCreatorTag;

		public static bool InfiniteHealth;

		public static bool BuildAnywhere;

		public static bool NoPhysics;

		public static bool Indestructible;

		public static bool CopyAnything;

		public static string s_copiedPrefab = "";

		public static string s_copiedName = "";

		private static Quaternion s_copiedRotation;

		private static GameObject s_ghost;

		public static void SetCopy(bool on)
		{
			CopyAnything = on;
			if (!on)
			{
				s_copiedPrefab = "";
				s_copiedName = "";
				DestroyGhost();
			}
		}

		private static bool DoRaycast(float maxDist, out RaycastHit hit)
		{
			//IL_0001: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			hit = default(RaycastHit);
			if ((Object)(object)GameCamera.instance == (Object)null)
			{
				return false;
			}
			int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "terrain", "piece", "piece_nonsolid" });
			Transform transform = ((Component)GameCamera.instance).transform;
			return Physics.Raycast(transform.position, transform.forward, ref hit, maxDist, mask);
		}

		public static void Update()
		{
			//IL_0108: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)Player.m_localPlayer == (Object)null)
				{
					return;
				}
				if (!CopyAnything)
				{
					DestroyGhost();
					return;
				}
				if (Input.GetKeyDown((KeyCode)104) && DoRaycast(200f, out var hit))
				{
					ZNetView componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<ZNetView>();
					if ((Object)(object)componentInParent != (Object)null)
					{
						string prefabName = Utils.GetPrefabName(((Component)componentInParent).gameObject);
						Piece component = ((Component)componentInParent).GetComponent<Piece>();
						s_copiedPrefab = prefabName;
						s_copiedName = (((Object)(object)component != (Object)null) ? Localization.instance.Localize(component.m_name) : prefabName);
						s_copiedRotation = ((Component)componentInParent).transform.rotation;
						((Character)Player.m_localPlayer).Message((MessageType)1, "Copied: " + s_copiedName, 0, (Sprite)null, false);
						CreateGhost();
					}
				}
				if (s_copiedPrefab != "" && (Object)(object)s_ghost != (Object)null)
				{
					if (DoRaycast(200f, out var hit2))
					{
						s_ghost.SetActive(true);
						s_ghost.transform.position = ((RaycastHit)(ref hit2)).point;
						s_ghost.transform.rotation = s_copiedRotation;
					}
					else
					{
						s_ghost.SetActive(false);
					}
				}
				if (s_copiedPrefab != "" && Input.GetKeyDown((KeyCode)323) && !Plugin.MenuOpen && DoRaycast(200f, out var hit3))
				{
					PlaceCopied(((RaycastHit)(ref hit3)).point);
				}
			}
			catch
			{
			}
		}

		private static void PlaceCopied(Vector3 pos)
		{
			//IL_004b: 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)
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab(s_copiedPrefab);
			if ((Object)(object)prefab == (Object)null)
			{
				Player localPlayer = Player.m_localPlayer;
				if (localPlayer != null)
				{
					((Character)localPlayer).Message((MessageType)1, "Prefab not found: " + s_copiedPrefab, 0, (Sprite)null, false);
				}
				return;
			}
			Object.Instantiate<GameObject>(prefab, pos, s_copiedRotation);
			Player localPlayer2 = Player.m_localPlayer;
			if (localPlayer2 != null)
			{
				((Character)localPlayer2).Message((MessageType)1, "Placed: " + s_copiedName, 0, (Sprite)null, false);
			}
		}

		private static void CreateGhost()
		{
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			DestroyGhost();
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab(s_copiedPrefab);
			if ((Object)(object)prefab == (Object)null)
			{
				return;
			}
			ZNetView.m_forceDisableInit = true;
			s_ghost = Object.Instantiate<GameObject>(prefab);
			ZNetView.m_forceDisableInit = false;
			((Object)s_ghost).name = s_copiedPrefab + "_ghost";
			Joint[] componentsInChildren = s_ghost.GetComponentsInChildren<Joint>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren[i]);
			}
			Rigidbody[] componentsInChildren2 = s_ghost.GetComponentsInChildren<Rigidbody>();
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren2[i]);
			}
			Collider[] componentsInChildren3 = s_ghost.GetComponentsInChildren<Collider>();
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				componentsInChildren3[i].enabled = false;
			}
			Light[] componentsInChildren4 = s_ghost.GetComponentsInChildren<Light>();
			for (int i = 0; i < componentsInChildren4.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren4[i]);
			}
			ZNetView[] componentsInChildren5 = s_ghost.GetComponentsInChildren<ZNetView>();
			for (int i = 0; i < componentsInChildren5.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren5[i]);
			}
			TerrainModifier[] componentsInChildren6 = s_ghost.GetComponentsInChildren<TerrainModifier>();
			for (int i = 0; i < componentsInChildren6.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren6[i]);
			}
			int layer = LayerMask.NameToLayer("ghost");
			Transform[] componentsInChildren7 = s_ghost.GetComponentsInChildren<Transform>();
			for (int i = 0; i < componentsInChildren7.Length; i++)
			{
				((Component)componentsInChildren7[i]).gameObject.layer = layer;
			}
			MeshRenderer[] componentsInChildren8 = s_ghost.GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val in componentsInChildren8)
			{
				Material[] materials = ((Renderer)val).materials;
				for (int j = 0; j < materials.Length; j++)
				{
					Color color = materials[j].color;
					color.a = 0.3f;
					materials[j].color = color;
					materials[j].SetFloat("_Mode", 3f);
					materials[j].SetInt("_SrcBlend", 5);
					materials[j].SetInt("_DstBlend", 10);
					materials[j].SetInt("_ZWrite", 0);
					materials[j].EnableKeyword("_ALPHABLEND_ON");
					materials[j].renderQueue = 3000;
				}
				((Renderer)val).materials = materials;
			}
			s_ghost.SetActive(false);
		}

		private static void DestroyGhost()
		{
			if ((Object)(object)s_ghost != (Object)null)
			{
				Object.Destroy((Object)(object)s_ghost);
				s_ghost = null;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
	{
		typeof(Piece),
		typeof(RequirementMode)
	})]
	public class NoCost_HaveRequirements
	{
		private static bool Prefix(RequirementMode mode, ref bool __result)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			if (!Build.NoCost)
			{
				return true;
			}
			if ((int)mode == 1)
			{
				return true;
			}
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(Player), "ConsumeResources")]
	public class NoCost_ConsumeResources
	{
		private static bool Prefix()
		{
			return !Build.NoCost;
		}
	}
	[HarmonyPatch(typeof(PieceTable), "UpdateAvailable")]
	public class NoCost_UpdateAvailable
	{
		private static void Prefix(ref bool noPlacementCost)
		{
			if (Build.NoCost)
			{
				noPlacementCost = true;
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "CanRepair", new Type[] { typeof(ItemData) })]
	public class NoCost_CanRepair
	{
		private static bool Prefix(ref bool __result)
		{
			if (!Build.NoCost)
			{
				return true;
			}
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(Location), "IsInsideNoBuildLocation")]
	public static class BuildAnywhere_NoBuildZone
	{
		private static bool Prefix(ref bool __result)
		{
			if (!Build.BuildAnywhere)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(Player), "UpdatePlacementGhost")]
	public static class BuildAnywhere_Ghost
	{
		private static readonly FieldInfo s_status = typeof(Player).GetField("m_placementStatus", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_ghost = typeof(Player).GetField("m_placementGhost", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly MethodInfo s_setValid = typeof(Player).GetMethod("SetPlacementGhostValid", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static void Postfix(Player __instance)
		{
			if (Build.BuildAnywhere && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				s_status?.SetValue(__instance, 0);
				object? obj = s_ghost?.GetValue(__instance);
				GameObject val = (GameObject)((obj is GameObject) ? obj : null);
				if ((Object)(object)val != (Object)null)
				{
					val.SetActive(true);
					s_setValid?.Invoke(__instance, new object[1] { true });
				}
			}
		}
	}
	[HarmonyPatch(typeof(PrivateArea), "CheckAccess")]
	public static class BuildAnywhere_PrivateArea
	{
		private static bool Prefix(ref bool __result)
		{
			if (!Build.BuildAnywhere)
			{
				return true;
			}
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(WearNTear), "ApplyDamage")]
	public static class InfiniteStructureHealth
	{
		private static readonly FieldInfo s_nview = typeof(WearNTear).GetField("m_nview", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static bool Prefix(WearNTear __instance, ref bool __result)
		{
			if (!Build.InfiniteHealth || s_nview == null)
			{
				return true;
			}
			object? value = s_nview.GetValue(__instance);
			ZNetView val = (ZNetView)((value is ZNetView) ? value : null);
			if ((Object)(object)val == (Object)null || !val.IsValid() || !val.IsOwner())
			{
				return true;
			}
			val.GetZDO().Set(ZDOVars.s_health, __instance.m_health);
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(Piece), "SetCreator")]
	public static class Build_SetCreator
	{
		private static readonly FieldInfo s_creator = typeof(Piece).GetField("m_creator", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static bool Prefix(Piece __instance)
		{
			try
			{
				if (!Build.NoCreatorTag)
				{
					return true;
				}
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid() || component.GetZDO() == null)
				{
					return true;
				}
				component.GetZDO().Set(ZDOVars.s_creator, 0L);
				s_creator?.SetValue(__instance, 0L);
				return false;
			}
			catch
			{
				return true;
			}
		}

		private static void Postfix(Piece __instance)
		{
			try
			{
				if (!Build.NoPhysics && !Build.Indestructible)
				{
					return;
				}
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid())
				{
					return;
				}
				if (!component.IsOwner())
				{
					component.ClaimOwnership();
				}
				ZDO zDO = component.GetZDO();
				if (zDO == null)
				{
					return;
				}
				WearNTear component2 = ((Component)__instance).GetComponent<WearNTear>();
				if ((Object)(object)component2 == (Object)null)
				{
					return;
				}
				if (Build.NoPhysics)
				{
					component2.m_noRoofWear = false;
					component2.m_noSupportWear = false;
					component2.m_health *= 1000f;
					zDO.Set(ZDOVars.s_health, component2.m_health);
					zDO.Set("vt_noPhysics", 1);
					Rigidbody[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Rigidbody>();
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].isKinematic = true;
					}
				}
				if (Build.Indestructible)
				{
					component2.m_health = float.MaxValue;
					zDO.Set(ZDOVars.s_health, float.MaxValue);
					zDO.Set(ZDOVars.s_maxHealth, float.MaxValue);
					__instance.m_canBeRemoved = false;
					zDO.Set("vt_noRemove", 1);
				}
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(Piece), "Awake")]
	public static class Build_PieceAwakeRestore
	{
		private static void Postfix(Piece __instance)
		{
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return;
			}
			ZDO zDO = component.GetZDO();
			if (zDO == null)
			{
				return;
			}
			if (zDO.GetInt("vt_noRemove", 0) == 1)
			{
				__instance.m_canBeRemoved = false;
			}
			if (zDO.GetInt("vt_noPhysics", 0) == 1)
			{
				WearNTear component2 = ((Component)__instance).GetComponent<WearNTear>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.m_noRoofWear = false;
					component2.m_noSupportWear = false;
				}
				Rigidbody[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Rigidbody>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].isKinematic = true;
				}
			}
		}
	}
	[HarmonyPatch(typeof(WearNTear), "UpdateWear")]
	public static class Build_NoPhysicsSkipWear
	{
		private static readonly FieldInfo s_nview = typeof(WearNTear).GetField("m_nview", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static bool Prefix(WearNTear __instance)
		{
			object? obj = s_nview?.GetValue(__instance);
			ZNetView val = (ZNetView)((obj is ZNetView) ? obj : null);
			if ((Object)(object)val == (Object)null || !val.IsValid())
			{
				return true;
			}
			ZDO zDO = val.GetZDO();
			if (zDO == null)
			{
				return true;
			}
			if (zDO.GetInt("vt_noPhysics", 0) != 1)
			{
				return zDO.GetInt("vt_noRemove", 0) != 1;
			}
			return false;
		}
	}
	public static class Esp
	{
		private static readonly MethodInfo s_getHoverObject = typeof(Player).GetMethod("GetHoverObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_mineRockAreas = typeof(MineRock).GetField("m_hitAreas", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly FieldInfo s_mineRock5Areas = typeof(MineRock5).GetField("m_hitAreas", BindingFlags.Instance | BindingFlags.NonPublic);

		private static GUIStyle s_chestItemsStyle;

		private static GameObject GetHoverGO()
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null || s_getHoverObject == null)
			{
				return null;
			}
			object? obj = s_getHoverObject.Invoke(Player.m_localPlayer, null);
			return (GameObject)((obj is GameObject) ? obj : null);
		}

		public static void Draw()
		{
			Camera mainCamera = Utils.GetMainCamera();
			if (!((Object)(object)mainCamera == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null))
			{
				if (Plugin.EspPlayers)
				{
					DrawPlayerNameHealthESP(mainCamera);
				}
				if (Plugin.EspPlayerList)
				{
					DrawPlayerList(mainCamera);
				}
				if (Plugin.EspMobs)
				{
					DrawMobNameHealthESP(mainCamera);
				}
				if (Plugin.EspLookStructure)
				{
					DrawLookAtStructure(mainCamera);
				}
				if (Plugin.EspLookChest)
				{
					DrawLookAtChestItems(mainCamera);
				}
				if (Plugin.EspLookTree)
				{
					DrawLookAtNature(mainCamera, trees: true);
				}
				if (Plugin.EspLookRock)
				{
					DrawLookAtNature(mainCamera, trees: false);
				}
			}
		}

		private static void DrawPlayerNameHealthESP(Camera cam)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_001e: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 11,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			val.normal.textColor = new Color(1f, 1f, 0.6f);
			GUIStyle val2 = val;
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (!((Object)(object)allPlayer == (Object)null) && !((Object)(object)allPlayer == (Object)(object)Player.m_localPlayer))
				{
					Vector3 val3 = Utils.WorldToScreenPointScaled(cam, ((Character)allPlayer).GetCenterPoint());
					if (!(val3.z <= 0f))
					{
						string text = $"{allPlayer.GetPlayerName()}  {((Character)allPlayer).GetHealth():0}/{((Character)allPlayer).GetMaxHealth():0}";
						GUI.Label(new Rect(val3.x - 150f, (float)Screen.height - val3.y - 8f, 300f, 16f), text, val2);
					}
				}
			}
		}

		private static void DrawPlayerList(Camera cam)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00bc: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_00fa: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (!((Object)(object)allPlayer == (Object)null) && !((Object)(object)allPlayer == (Object)(object)Player.m_localPlayer))
				{
					float num = Vector3.Distance(((Component)cam).transform.position, ((Component)allPlayer).transform.position);
					list.Add($"{allPlayer.GetPlayerName()} [{(int)num}m]");
				}
			}
			if (list.Count == 0)
			{
				return;
			}
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 14
			};
			val.normal.textColor = Color.white;
			GUIStyle val2 = val;
			GUIStyle val3 = new GUIStyle(GUI.skin.label)
			{
				fontSize = 14,
				fontStyle = (FontStyle)1
			};
			val3.normal.textColor = new Color(1f, 0.75f, 0f);
			GUIStyle val4 = val3;
			float num2 = 10f;
			float num3 = 10f;
			float num4 = 300f;
			float num5 = 18f;
			GUI.Label(new Rect(num2, num3, num4, num5), $"Players ({list.Count})", val4);
			num3 += num5;
			foreach (string item in list)
			{
				GUI.Label(new Rect(num2, num3, num4, num5), item, val2);
				num3 += num5;
			}
		}

		private static void DrawMobNameHealthESP(Camera cam)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_001e: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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)
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 11,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			val.normal.textColor = new Color(1f, 1f, 0.6f);
			GUIStyle val2 = val;
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if ((Object)(object)allCharacter == (Object)null || allCharacter.IsPlayer())
				{
					continue;
				}
				Vector3 val3 = Utils.WorldToScreenPointScaled(cam, allCharacter.GetCenterPoint());
				if (!(val3.z <= 0f))
				{
					string arg = ((!string.IsNullOrEmpty(allCharacter.m_name)) ? Localization.instance.Localize(allCharacter.m_name) : ((Object)allCharacter).name);
					string text = $"{arg}\nHP {allCharacter.GetHealth():0}/{allCharacter.GetMaxHealth():0}";
					float mobDamage = GetMobDamage(allCharacter);
					if (mobDamage > 0f)
					{
						text += $"\nDMG {mobDamage:0}";
					}
					string mobTarget = GetMobTarget(allCharacter);
					if (mobTarget != null)
					{
						text = text + "\nTarget: " + mobTarget;
					}
					float num = (float)text.Split(new char[1] { '\n' }).Length * 15f;
					GUI.Label(new Rect(val3.x - 175f, (float)Screen.height - val3.y - num / 2f, 350f, num), text, val2);
				}
			}
		}

		private static float GetMobDamage(Character c)
		{
			try
			{
				Humanoid val = (Humanoid)(object)((c is Humanoid) ? c : null);
				if ((Object)(object)val == (Object)null)
				{
					return 0f;
				}
				float num = 0f;
				ItemData currentWeapon = val.GetCurrentWeapon();
				if (currentWeapon != null && currentWeapon.m_shared != null && currentWeapon.m_shared.m_attack != null)
				{
					num = ((DamageTypes)(ref currentWeapon.m_shared.m_damages)).GetTotalDamage();
				}
				if (num <= 0f)
				{
					num = Mathf.Max(ScanItemDamage(val.m_defaultItems), ScanItemDamage(val.m_randomWeapon));
				}
				if (num <= 0f && (Object)(object)val.m_unarmedWeapon != (Object)null && val.m_unarmedWeapon.m_itemData != null && val.m_unarmedWeapon.m_itemData.m_shared != null)
				{
					num = ((DamageTypes)(ref val.m_unarmedWeapon.m_itemData.m_shared.m_damages)).GetTotalDamage();
				}
				if (num <= 0f)
				{
					return 0f;
				}
				float num2 = 1f + (float)Mathf.Max(0, c.GetLevel() - 1) * 0.5f;
				return num * num2;
			}
			catch
			{
				return 0f;
			}
		}

		private static string GetMobTarget(Character c)
		{
			try
			{
				BaseAI component = ((Component)c).GetComponent<BaseAI>();
				Character val = (((Object)(object)component != (Object)null) ? component.GetTargetCreature() : null);
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				if ((Object)(object)val == (Object)(object)Player.m_localPlayer)
				{
					return "Me";
				}
				if (val.IsPlayer())
				{
					return ((Player)((val is Player) ? val : null)).GetPlayerName();
				}
				return (!string.IsNullOrEmpty(val.m_name)) ? Localization.instance.Localize(val.m_name) : ((Object)val).name;
			}
			catch
			{
				return null;
			}
		}

		private static float ScanItemDamage(GameObject[] items)
		{
			float num = 0f;
			if (items == null)
			{
				return 0f;
			}
			foreach (GameObject val in items)
			{
				ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null);
				SharedData val3 = (((Object)(object)val2 != (Object)null && val2.m_itemData != null) ? val2.m_itemData.m_shared : null);
				if (val3 != null && val3.m_attack != null)
				{
					float totalDamage = ((DamageTypes)(ref val3.m_damages)).GetTotalDamage();
					if (totalDamage > num)
					{
						num = totalDamage;
					}
				}
			}
			return num;
		}

		private static WearNTear ResolveLookAtStructure(Camera cam)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			GameObject hoverGO = GetHoverGO();
			if ((Object)(object)hoverGO != (Object)null)
			{
				WearNTear componentInParent = hoverGO.GetComponentInParent<WearNTear>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					return componentInParent;
				}
			}
			if ((Object)(object)cam == (Object)null)
			{
				return null;
			}
			Ray val = cam.ScreenPointToRay(new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f));
			int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "piece", "piece_nonsolid", "vehicle" });
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(val, ref val2, 100f, mask))
			{
				return null;
			}
			return ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<WearNTear>();
		}

		private static void ReadStructure(WearNTear wnt, out string name, out string builder, out float cur, out float max, out string owner, out bool ownerIsMe)
		{
			Piece component = ((Component)wnt).GetComponent<Piece>();
			name = (((Object)(object)component != (Object)null && !string.IsNullOrEmpty(component.m_name)) ? Localization.instance.Localize(component.m_name) : ((Object)((Component)wnt).gameObject).name);
			max = wnt.m_health;
			cur = wnt.m_health;
			builder = "world";
			owner = "none";
			ownerIsMe = false;
			ZNetView component2 = ((Component)wnt).GetComponent<ZNetView>();
			if ((Object)(object)component2 != (Object)null && component2.IsValid())
			{
				ZDO zDO = component2.GetZDO();
				cur = zDO.GetFloat(ZDOVars.s_health, wnt.m_health);
				long num = zDO.GetLong(ZDOVars.s_creator, 0L);
				if (num != 0L)
				{
					builder = ResolveBuilderName(zDO, num);
				}
				long owner2 = zDO.GetOwner();
				if (owner2 == 0L)
				{
					owner = "none (dormant)";
				}
				else if (owner2 == ZDOMan.GetSessionID())
				{
					owner = "ME (you)";
					ownerIsMe = true;
				}
				else
				{
					owner = GetPlayerNameBySessionId(owner2);
				}
			}
		}

		private static string GetPlayerNameBySessionId(long sessionId)
		{
			if ((Object)(object)ZNet.instance != (Object)null)
			{
				foreach (ZNetPeer peer in ZNet.instance.GetPeers())
				{
					if (peer != null && peer.m_uid == sessionId)
					{
						return string.IsNullOrEmpty(peer.m_playerName) ? $"peer {sessionId}" : peer.m_playerName;
					}
				}
			}
			return $"another player ({sessionId})";
		}

		private static string ResolveBuilderName(ZDO zdo, long creatorId)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int num = zdo.GetInt(ZDOVars.s_creatorIndex, -1);
				World world = ZNet.World;
				if (num >= 0 && world != null && world.m_playerHistory != null && num < world.m_playerHistory.Count)
				{
					CrossNetworkUserInfo val = world.m_playerHistory[num];
					string text = ((!string.IsNullOrEmpty(val.m_serverAssignedDisplayName)) ? val.m_serverAssignedDisplayName : val.m_displayName);
					if (!string.IsNullOrEmpty(text))
					{
						return text;
					}
				}
			}
			catch
			{
			}
			string playerNameById = GetPlayerNameById(creatorId);
			if (!(playerNameById == creatorId.ToString()))
			{
				return playerNameById;
			}
			return $"unknown ({creatorId})";
		}

		private static string GetPlayerNameById(long playerId)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNet.instance != (Object)null)
			{
				foreach (PlayerInfo player in ZNet.instance.GetPlayerList())
				{
					ZDOID characterID = player.m_characterID;
					if (((ZDOID)(ref characterID)).UserID == playerId)
					{
						return player.m_name;
					}
				}
			}
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (allPlayer.GetPlayerID() == playerId)
				{
					return allPlayer.GetPlayerName();
				}
			}
			return playerId.ToString();
		}

		private static void DrawLookAtStructure(Camera cam)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_004c: Expected O, but got Unknown
			//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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0095: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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)
			WearNTear val = ResolveLookAtStructure(cam);
			if (!((Object)(object)val == (Object)null))
			{
				ReadStructure(val, out var name, out var builder, out var cur, out var max, out var owner, out var ownerIsMe);
				GUIStyle val2 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 18
				};
				val2.normal.textColor = Color.white;
				GUIStyle val3 = val2;
				GUIStyle val4 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 20,
					fontStyle = (FontStyle)1
				};
				val4.normal.textColor = new Color(0.4f, 0.8f, 1f);
				GUIStyle val5 = val4;
				GUIStyle val6 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 18
				};
				val6.normal.textColor = (ownerIsMe ? new Color(0.5f, 1f, 0.5f) : new Color(1f, 0.6f, 0.2f));
				GUIStyle val7 = val6;
				float num = 340f;
				float num2 = 23f;
				float num3 = (float)Screen.width / 2f - num - 24f;
				float num4 = (float)Screen.height / 2f - 30f - 5f * num2;
				GUI.Label(new Rect(num3, num4, num, num2), name, val5);
				num4 += num2;
				GUI.Label(new Rect(num3, num4, num, num2), "Built by: " + builder, val3);
				num4 += num2;
				GUI.Label(new Rect(num3, num4, num, num2), "ZDO owner: " + owner, val7);
				num4 += num2;
				GUI.Label(new Rect(num3, num4, num, num2), $"HP: {cur:0} / {max:0}", val3);
			}
		}

		private static Container ResolveLookAtChest(Camera cam)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			GameObject hoverGO = GetHoverGO();
			if ((Object)(object)hoverGO != (Object)null)
			{
				Container componentInParent = hoverGO.GetComponentInParent<Container>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					return componentInParent;
				}
			}
			if ((Object)(object)cam == (Object)null)
			{
				return null;
			}
			Ray val = cam.ScreenPointToRay(new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f));
			int mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "piece", "piece_nonsolid", "item", "vehicle" });
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(val, ref val2, 100f, mask))
			{
				return null;
			}
			return ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Container>();
		}

		private static void DrawLookAtChestItems(Camera cam)
		{
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_0202: 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_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			Container val = ResolveLookAtChest(cam);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Inventory inventory = val.GetInventory();
			if (inventory == null)
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine(Localization.instance.Localize(val.m_name));
			List<ItemData> allItems = inventory.GetAllItems();
			if (allItems == null || allItems.Count == 0)
			{
				stringBuilder.AppendLine("(empty)");
			}
			else
			{
				Dictionary<string, int> dictionary = new Dictionary<string, int>();
				List<string> list = new List<string>();
				foreach (ItemData item in allItems)
				{
					string text = Localization.instance.Localize(item.m_shared.m_name);
					if (!dictionary.ContainsKey(text))
					{
						dictionary[text] = 0;
						list.Add(text);
					}
					dictionary[text] += item.m_stack;
				}
				foreach (string item2 in list)
				{
					stringBuilder.AppendLine($"{item2} x{dictionary[item2]}");
				}
			}
			string text2 = stringBuilder.ToString().TrimEnd('\r', '\n');
			Vector3 val2 = Utils.WorldToScreenPointScaled(cam, ((Component)val).transform.position + Vector3.up * 0.8f);
			if (!(val2.z < 0f))
			{
				if (s_chestItemsStyle == null)
				{
					GUIStyle val3 = new GUIStyle(GUI.skin.label)
					{
						fontSize = 15,
						alignment = (TextAnchor)7,
						wordWrap = false,
						fixedHeight = 0f,
						stretchHeight = true
					};
					val3.normal.textColor = Color.white;
					s_chestItemsStyle = val3;
				}
				float num = 240f;
				GUIContent val4 = new GUIContent(text2);
				float num2 = s_chestItemsStyle.CalcHeight(val4, num);
				GUI.Label(new Rect(val2.x - num / 2f, (float)Screen.height - val2.y - num2 - 6f, num, num2), val4, s_chestItemsStyle);
			}
		}

		private static void DrawLookAtNature(Camera cam, bool trees)
		{
			//IL_001a: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			if (ReadLookAtNature(cam, trees, out var prefab, out var cur, out var max))
			{
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					fontStyle = (FontStyle)1
				};
				val.normal.textColor = new Color(1f, 1f, 0.6f);
				GUIStyle val2 = val;
				float num = 340f;
				float num2 = 18f;
				float num3 = (float)Screen.width / 2f + 24f;
				float num4 = (float)Screen.height / 2f - 30f - 2f * num2;
				GUI.Label(new Rect(num3, num4, num, num2), prefab, val2);
				num4 += num2;
				GUI.Label(new Rect(num3, num4, num, num2), $"HP: {cur:0} / {max:0}", val2);
			}
		}

		private static bool ReadLookAtNature(Camera cam, bool trees, out string prefab, out float cur, out float max)
		{
			//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_008e: Unknown result type (might be due to invalid IL or missing references)
			prefab = "";
			cur = 0f;
			max = 0f;
			GameObject val = GetHoverGO();
			if ((Object)(object)val == (Object)null && (Object)(object)cam != (Object)null)
			{
				Ray val2 = cam.ScreenPointToRay(new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f));
				int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "piece", "piece_nonsolid", "Default_small" });
				RaycastHit val3 = default(RaycastHit);
				if (Physics.Raycast(val2, ref val3, 100f, mask))
				{
					val = ((Component)((RaycastHit)(ref val3)).collider).gameObject;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			if (trees)
			{
				TreeBase componentInParent = val.GetComponentInParent<TreeBase>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					ReadSimpleHealth((Component)(object)componentInParent, componentInParent.m_health, out cur, out max);
					prefab = Utils.GetPrefabName(((Component)componentInParent).gameObject);
					return true;
				}
				TreeLog componentInParent2 = val.GetComponentInParent<TreeLog>();
				if ((Object)(object)componentInParent2 != (Object)null)
				{
					ReadSimpleHealth((Component)(object)componentInParent2, componentInParent2.m_health, out cur, out max);
					prefab = Utils.GetPrefabName(((Component)componentInParent2).gameObject);
					return true;
				}
				return false;
			}
			MineRock5 componentInParent3 = val.GetComponentInParent<MineRock5>();
			if ((Object)(object)componentInParent3 != (Object)null)
			{
				ReadMineRock5(componentInParent3, out cur, out max);
				prefab = Utils.GetPrefabName(((Component)componentInParent3).gameObject);
				return true;
			}
			MineRock componentInParent4 = val.GetComponentInParent<MineRock>();
			if ((Object)(object)componentInParent4 != (Object)null)
			{
				ReadMineRock(componentInParent4, out cur, out max);
				prefab = Utils.GetPrefabName(((Component)componentInParent4).gameObject);
				return true;
			}
			Destructible componentInParent5 = val.GetComponentInParent<Destructible>();
			if ((Object)(object)componentInParent5 != (Object)null)
			{
				ReadSimpleHealth((Component)(object)componentInParent5, componentInParent5.m_health, out cur, out max);
				prefab = Utils.GetPrefabName(((Component)componentInParent5).gameObject);
				return true;
			}
			return false;
		}

		private static void ReadSimpleHealth(Component c, float defHealth, out float cur, out float max)
		{
			max = defHealth;
			cur = defHealth;
			ZNetView component = c.GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO() != null)
			{
				float num = component.GetZDO().GetFloat(ZDOVars.s_health, defHealth);
				cur = ((num >= float.MaxValue) ? max : num);
			}
		}

		private static void ReadMineRock(MineRock mr, out float cur, out float max)
		{
			cur = 0f;
			max = 0f;
			ZNetView component = ((Component)mr).GetComponent<ZNetView>();
			int num = ((s_mineRockAreas?.GetValue(mr) is Array array) ? array.Length : 0);
			float health = mr.GetHealth();
			for (int i = 0; i < num; i++)
			{
				max += health;
				float num2 = (((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO() != null) ? component.GetZDO().GetFloat("Health" + i, health) : health);
				cur += Mathf.Clamp((num2 >= float.MaxValue) ? health : num2, 0f, health);
			}
		}

		private static void ReadMineRock5(MineRock5 mr, out float cur, out float max)
		{
			cur = 0f;
			max = 0f;
			ICollection collection = s_mineRock5Areas?.GetValue(mr) as ICollection;
			int num = collection?.Count ?? 0;
			float health = mr.m_health;
			max = (float)num * health;
			if (collection == null)
			{
				return;
			}
			foreach (object item in collection)
			{
				FieldInfo field = item.GetType().GetField("m_health");
				float num2 = health;
				try
				{
					if (field != null)
					{
						num2 = (float)field.GetValue(item);
					}
				}
				catch
				{
				}
				cur += Mathf.Clamp((num2 >= float.MaxValue) ? health : num2, 0f, health);
			}
		}
	}
	public static class FreeCam
	{
		public static bool s_enabled = false;

		private static float s_yaw;

		private static float s_pitch;

		private static float s_originalPlaceDistance = 8f;

		private const float s_buildCameraPlaceDistance = 100f;

		public static void Toggle()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (s_enabled || !((Object)(object)Player.m_localPlayer == (Object)null))
			{
				s_enabled = !s_enabled;
				if (s_enabled && (Object)(object)Player.m_localPlayer != (Object)null)
				{
					Quaternion rotation = ((Component)((Character)Player.m_localPlayer).m_eye).transform.rotation;
					s_pitch = ((Quaternion)(ref rotation)).eulerAngles.x;
					s_yaw = ((Quaternion)(ref rotation)).eulerAngles.y;
					s_originalPlaceDistance = Player.m_localPlayer.m_maxPlaceDistance;
					Player.m_localPlayer.m_maxPlaceDistance = 100f;
				}
				else if (!s_enabled && (Object)(object)Player.m_localPlayer != (Object)null)
				{
					Player.m_localPlayer.m_maxPlaceDistance = s_originalPlaceDistance;
				}
				if ((Object)(object)Player.m_localPlayer != (Object)null)
				{
					((Character)Player.m_localPlayer).Message((MessageType)1, s_enabled ? "Freecam: ON" : "Freecam: OFF", 0, (Sprite)null, false);
				}
			}
		}

		public static void UpdateBuildCamera(float dt, ref GameCamera instance)
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			if (!Console.IsVisible() && !Hud.IsPieceSelectionVisible())
			{
				s_yaw += PlayerController.m_mouseSens * Input.GetAxis("Mouse X");
				s_yaw += ZInput.GetJoyRightStickX() * 110f * dt;
				float num = (PlayerController.m_invertMouse ? (-1f) : 1f) * (PlayerController.m_mouseSens * Input.GetAxis("Mouse Y"));
				num -= ZInput.GetJoyRightStickY() * 110f * dt;
				s_pitch = Mathf.Clamp(s_pitch - num, -89f, 89f);
				((Component)instance).transform.rotation = Quaternion.Euler(0f, s_yaw, 0f) * Quaternion.Euler(s_pitch, 0f, 0f);
				Vector3 val = Vector3.zero;
				if (ZInput.GetButton("Left"))
				{
					val -= Vector3.right;
				}
				if (ZInput.GetButton("Right"))
				{
					val += Vector3.right;
				}
				if (ZInput.GetButton("Forward"))
				{
					val += Vector3.forward;
				}
				if (ZInput.GetButton("Backward"))
				{
					val -= Vector3.forward;
				}
				if (ZInput.GetButton("Jump") || ZInput.GetButton("JoyJump"))
				{
					val += Vector3.up;
				}
				if (ZInput.GetButton("Crouch") || ZInput.GetButton("JoyCrouch"))
				{
					val -= Vector3.up;
				}
				((Vector3)(ref val)).Normalize();
				val += Vector3.right * ZInput.GetJoyLeftStickX();
				val += -Vector3.forward * ZInput.GetJoyLeftStickY();
				float num2 = (ZInput.GetButton("Run") ? ((Character)Player.m_localPlayer).m_runSpeed : ((Character)Player.m_localPlayer).m_walkSpeed);
				Transform transform = ((Component)instance).transform;
				transform.position += ((Component)instance).transform.TransformVector(val * dt * num2 * 3f);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "Update")]
	internal static class FreeCam_PlayerUpdate
	{
		private static bool Prefix(Player __instance)
		{
			if (!FreeCam.s_enabled || (Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			try
			{
				if ((bool)__instance.CallMethod("TakeInput"))
				{
					if (Input.GetKeyDown((KeyCode)49) || ZInput.GetButtonDown("Hotbar1"))
					{
						__instance.UseHotbarItem(1);
					}
					if (Input.GetKeyDown((KeyCode)50) || ZInput.GetButtonDown("Hotbar2"))
					{
						__instance.UseHotbarItem(2);
					}
					if (Input.GetKeyDown((KeyCode)51) || ZInput.GetButtonDown("Hotbar3"))
					{
						__instance.UseHotbarItem(3);
					}
					if (Input.GetKeyDown((KeyCode)52) || ZInput.GetButtonDown("Hotbar4"))
					{
						__instance.UseHotbarItem(4);
					}
					if (Input.GetKeyDown((KeyCode)53) || ZInput.GetButtonDown("Hotbar5"))
					{
						__instance.UseHotbarItem(5);
					}
					if (Input.GetKeyDown((KeyCode)54) || ZInput.GetButtonDown("Hotbar6"))
					{
						__instance.UseHotbarItem(6);
					}
					if (Input.GetKeyDown((KeyCode)55) || ZInput.GetButtonDown("Hotbar7"))
					{
						__instance.UseHotbarItem(7);
					}
					if (Input.GetKeyDown((KeyCode)56) || ZInput.GetButtonDown("Hotbar8"))
					{
						__instance.UseHotbarItem(8);
					}
					if (ZInput.GetButtonDown("Hide") || ZInput.GetButtonDown("JoyHide"))
					{
						ItemData fieldValue = __instance.GetFieldValue<ItemData>("m_rightItem");
						ItemData fieldValue2 = __instance.GetFieldValue<ItemData>("m_leftItem");
						if ((fieldValue != null || fieldValue2 != null) && !(bool)__instance.CallMethod("InAttack"))
						{
							((Humanoid)__instance).HideHandItems(false, true);
						}
					}
					if ((bool)__instance.CallMethod("InPlaceMode"))
					{
						__instance.CallMethod("UpdatePlacement", true, Time.deltaTime);
					}
				}
			}
			catch
			{
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerController), "TakeInput")]
	internal static class FreeCam_StopMovement
	{
		private static bool Prefix(ref bool __result)
		{
			if (!FreeCam.s_enabled)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
	internal static class FreeCam_UpdateCamera
	{
		private static bool Prefix(float dt, GameCamera __instance)
		{
			if (!FreeCam.s_enabled)
			{
				return true;
			}
			FreeCam.UpdateBuildCamera(dt, ref __instance);
			return false;
		}
	}
	[HarmonyPatch(typeof(Player), "GetStealthFactor")]
	internal static class GhostAI_StealthPatch
	{
		private static void Postfix(Player __instance, ref float __result)
		{
			if (GhostAI.s_enabled && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				__result = 0f;
			}
		}
	}
	public static class GhostAI
	{
		public static bool s_enabled = false;

		private static readonly FieldInfo s_playerNView = typeof(Player).GetField("m_nview", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_monsterTarget = typeof(MonsterAI).GetField("m_targetCreature", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly MethodInfo s_setAlerted = typeof(BaseAI).GetMethod("SetAlerted", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static float s_aggroTimer = 0f;

		public static void Toggle()
		{
			s_enabled = !s_enabled;
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				((Character)Player.m_localPlayer).Message((MessageType)1, s_enabled ? "Ghost Mode ON — mobs cannot see or hear you" : "Ghost Mode OFF", 0, (Sprite)null, false);
			}
		}

		public static void Update()
		{
			try
			{
				UpdateInner();
			}
			catch
			{
			}
		}

		private static void UpdateInner()
		{
			if (!s_enabled)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			object? obj = s_playerNView?.GetValue(localPlayer);
			ZNetView val = (ZNetView)((obj is ZNetView) ? obj : null);
			if ((Object)(object)val == (Object)null || !val.IsValid())
			{
				return;
			}
			ZDO zDO = val.GetZDO();
			if (zDO != null)
			{
				zDO.Set(ZDOVars.s_stealth, 0f);
				zDO.Set(ZDOVars.s_noise, 0f);
				s_aggroTimer += Time.deltaTime;
				if (s_aggroTimer >= 0.5f)
				{
					s_aggroTimer = 0f;
					ClearNearbyAggro(localPlayer);
				}
			}
		}

		private static void ClearNearbyAggro(Player player)
		{
			if (s_monsterTarget == null)
			{
				return;
			}
			MonsterAI[] array = Object.FindObjectsOfType<MonsterAI>();
			foreach (MonsterAI val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				ZNetView component = ((Component)val).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid() || !component.IsOwner())
				{
					continue;
				}
				try
				{
					object? value = s_monsterTarget.GetValue(val);
					if ((Object)((value is Character) ? value : null) == (Object)(object)player)
					{
						s_monsterTarget.SetValue(val, null);
						s_setAlerted?.Invoke(val, new object[1] { false });
					}
				}
				catch
				{
				}
			}
		}
	}
	internal static class Inv
	{
		public static bool Any
		{
			get
			{
				if (!Plugin.Invisible)
				{
					return Plugin.InvisibleFull;
				}
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(Character), "AddNoise")]
	public class Invis_Noise
	{
		private static bool Prefix(Character __instance)
		{
			if (!Inv.Any)
			{
				return true;
			}
			return (Object)(object)__instance != (Object)(object)Player.m_localPlayer;
		}
	}
	[HarmonyPatch(typeof(BaseAI), "CanSenseTarget", new Type[] { typeof(Character) })]
	public class Invis_Sense
	{
		private static void Postfix(Character target, ref bool __result)
		{
			if (Inv.Any && (Object)(object)target == (Object)(object)Player.m_localPlayer)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(BaseAI), "CanHearTarget", new Type[] { typeof(Character) })]
	public class Invis_Hear
	{
		private static void Postfix(Character target, ref bool __result)
		{
			if (Inv.Any && (Object)(object)target == (Object)(object)Player.m_localPlayer)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(BaseAI), "CanSeeTarget", new Type[] { typeof(Character) })]
	public class Invis_See
	{
		private static void Postfix(Character target, ref bool __result)
		{
			if (Inv.Any && (Object)(object)target == (Object)(object)Player.m_localPlayer)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "LateUpdate")]
	public class Invis_Renderers
	{
		private static bool s_was;

		private static void Postfix(Player __instance)
		{
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			if (Plugin.InvisibleFull)
			{
				s_was = true;
				Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>();
				foreach (Renderer obj in componentsInChildren)
				{
					obj.enabled = false;
					obj.shadowCastingMode = (ShadowCastingMode)0;
				}
				Light[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<Light>();
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					((Behaviour)componentsInChildren2[i]).enabled = false;
				}
			}
			else if (s_was)
			{
				s_was = false;
				Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>();
				foreach (Renderer obj2 in componentsInChildren)
				{
					obj2.enabled = true;
					obj2.shadowCastingMode = (ShadowCastingMode)1;
				}
				Light[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<Light>();
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					((Behaviour)componentsInChildren2[i]).enabled = true;
				}
			}
		}
	}
	[HarmonyPatch(typeof(FootStep), "OnFoot", new Type[] { typeof(Transform) })]
	public class Invis_Footstep
	{
		private static bool Prefix(FootStep __instance)
		{
			if (!Inv.Any || (Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Character component = ((Component)__instance).GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				return !((Object)(object)component == (Object)(object)Player.m_localPlayer);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(FootStep), "OnLand")]
	public class Invis_Land
	{
		private static bool Prefix(FootStep __instance)
		{
			if (!Inv.Any || (Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Character component = ((Component)__instance).GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				return !((Object)(object)component == (Object)(object)Player.m_localPlayer);
			}
			return true;
		}
	}
	public static class ItemGiver
	{
		private class Entry
		{
			public GameObject prefab;

			public ItemDrop drop;

			public GUIContent gui;

			public int variant;
		}

		private static readonly List<Entry> s_items = new List<Entry>();

		private static List<Entry> s_filtered = new List<Entry>();

		private static int s_builtCount = -1;

		private static int s_selected;

		private static string s_qty = "1";

		private static string s_quality = "1";

		private static string s_search = "";

		private static string s_prevSearch = "\0";

		private static bool s_noCrafter;

		private static Vector2 s_scroll;

		private static readonly Dictionary<int, Texture2D> s_atlasCache = new Dictionary<int, Texture2D>();

		private static readonly Dictionary<Sprite, Texture2D> s_spriteCache = new Dictionary<Sprite, Texture2D>();

		private static void Build()
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			if ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_items == null)
			{
				return;
			}
			s_items.Clear();
			foreach (GameObject item in ObjectDB.instance.m_items)
			{
				try
				{
					if ((Object)(object)item == (Object)null)
					{
						continue;
					}
					ItemDrop component = item.GetComponent<ItemDrop>();
					if (component?.m_itemData?.m_shared == null)
					{
						continue;
					}
					Sprite[] icons = component.m_itemData.m_shared.m_icons;
					if (icons == null || icons.Length == 0)
					{
						continue;
					}
					for (int i = 0; i < icons.Length; i++)
					{
						try
						{
							if (!((Object)(object)icons[i] == (Object)null))
							{
								GUIContent gui = new GUIContent((Texture)(object)TextureFromSprite(icons[i]), Localization.instance.Localize(component.m_itemData.m_shared.m_name + ((i > 0) ? (" Variant " + i) : "")));
								s_items.Add(new Entry
								{
									prefab = item,
									drop = component,
									gui = gui,
									variant = i
								});
							}
						}
						catch
						{
						}
					}
				}
				catch
				{
				}
			}
			s_builtCount = ObjectDB.instance.m_items.Count;
			s_prevSearch = "\0";
			s_filtered = s_items;
		}

		private static void Filter()
		{
			if (!(s_search == s_prevSearch))
			{
				s_prevSearch = s_search;
				string q = (s_search ?? "").ToLower();
				s_filtered = (string.IsNullOrEmpty(q) ? s_items : s_items.Where((Entry i) => Localization.instance.Localize(i.drop.m_itemData.m_shared.m_name).ToLower().Contains(q)).ToList());
				if (s_selected >= s_filtered.Count)
				{
					s_selected = 0;
				}
			}
		}

		public static void DrawGUI()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			if ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_items == null || ObjectDB.instance.m_items.Count == 0)
			{
				GUILayout.Label("Enter a world to load items.", Array.Empty<GUILayoutOption>());
				return;
			}
			if (s_items.Count == 0 || ObjectDB.instance.m_items.Count != s_builtCount)
			{
				Build();
			}
			Filter();
			s_search = GUILayout.TextField(s_search, Array.Empty<GUILayoutOption>());
			s_scroll = GUILayout.BeginScrollView(s_scroll, GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(220f) });
			GUIStyle val = new GUIStyle(GUI.skin.button)
			{
				fixedWidth = 70f,
				fixedHeight = 70f,
				imagePosition = (ImagePosition)1
			};
			GUIContent[] array = s_filtered.Select((Entry i) => i.gui).ToArray();
			if (array.Length != 0)
			{
				s_selected = Mathf.Clamp(s_selected, 0, array.Length - 1);
				s_selected = GUILayout.SelectionGrid(s_selected, array, 4, val, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndScrollView();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Qty", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
			s_qty = GUILayout.TextField(s_qty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
			GUILayout.Label("Quality", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(55f) });
			s_quality = GUILayout.TextField(s_quality, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Toggle(!s_noCrafter, "Crafted by me", GUI.skin.button, Array.Empty<GUILayoutOption>()))
			{
				s_noCrafter = false;
			}
			if (GUILayout.Toggle(s_noCrafter, "No craft (no crafter)", GUI.skin.button, Array.Empty<GUILayoutOption>()))
			{
				s_noCrafter = true;
			}
			GUILayout.EndHorizontal();
			if (GUILayout.Button("GIVE ITEM", Array.Empty<GUILayoutOption>()) && s_selected >= 0 && s_selected < s_filtered.Count && (Object)(object)Player.m_localPlayer != (Object)null && int.TryParse(s_qty, out var result) && int.TryParse(s_quality, out var result2))
			{
				Entry entry = s_filtered[s_selected];
				Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
				long num = (s_noCrafter ? 0 : Player.m_localPlayer.GetPlayerID());
				string text = (s_noCrafter ? "" : Player.m_localPlayer.GetPlayerName());
				inventory.AddItem(((Object)entry.prefab).name, result, result2, entry.variant, num, text, false, false);
				((Character)Player.m_localPlayer).Message((MessageType)1, $"Gave {result}x {((Object)entry.prefab).name}", 0, (Sprite)null, false);
			}
		}

		private static Texture2D TextureFromSprite(Sprite sprite, bool resize = true)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_0095: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			Rect val = sprite.rect;
			if (((Rect)(ref val)).width == (float)((Texture)sprite.texture).width)
			{
				return sprite.texture;
			}
			if (s_spriteCache.TryGetValue(sprite, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			int instanceID = ((Object)sprite.texture).GetInstanceID();
			if (!s_atlasCache.TryGetValue(instanceID, out var value2))
			{
				value2 = DuplicateTexture(sprite.texture);
				s_atlasCache.Add(instanceID, value2);
			}
			val = sprite.textureRect;
			int num = Mathf.Clamp(Mathf.CeilToInt(((Rect)(ref val)).x), 0, ((Texture)value2).width - 1);
			val = sprite.textureRect;
			int num2 = Mathf.Clamp(Mathf.CeilToInt(((Rect)(ref val)).y), 0, ((Texture)value2).height - 1);
			val = sprite.textureRect;
			int num3 = Mathf.Clamp(Mathf.CeilToInt(((Rect)(ref val)).width), 1, ((Texture)value2).width - num);
			val = sprite.textureRect;
			int num4 = Mathf.Clamp(Mathf.CeilToInt(((Rect)(ref val)).height), 1, ((Texture)value2).height - num2);
			Texture2D val2 = new Texture2D(num3, num4);
			val2.SetPixels(value2.GetPixels(num, num2, num3, num4));
			val2.Apply();
			if (resize && (((Texture)val2).width > 200 || ((Texture)val2).height > 200))
			{
				val2.Reinitialize(60, 60);
			}
			s_spriteCache[sprite] = val2;
			return val2;
		}

		private static Texture2D DuplicateTexture(Texture2D source)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			RenderTexture temporary = RenderTexture.GetTemporary(((Texture)source).width, ((Texture)source).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1);
			Graphics.Blit((Texture)(object)source, temporary);
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(((Texture)source).width, ((Texture)source).height);
			val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0);
			val.Apply();
			RenderTexture.active = active;
			RenderTexture.ReleaseTemporary(temporary);
			return val;
		}
	}
	public static class MapReveal
	{
		public static bool s_enabled = false;

		private static bool s_applied = false;

		private static readonly FieldInfo f_fog = typeof(Minimap).GetField("m_fogTexture", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo f_explored = typeof(Minimap).GetField("m_explored", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		public static void Update()
		{
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				s_applied = false;
			}
			else if (s_enabled && !s_applied)
			{
				Reveal();
				s_applied = true;
			}
			else if (!s_enabled && s_applied)
			{
				Restore();
				s_applied = false;
			}
		}

		private static Texture2D Fog()
		{
			object? obj = f_fog?.GetValue(Minimap.instance);
			return (Texture2D)((obj is Texture2D) ? obj : null);
		}

		private static void Reveal()
		{
			Texture2D val = Fog();
			if (!((Object)(object)val == (Object)null))
			{
				Color32[] pixels = val.GetPixels32();
				for (int i = 0; i < pixels.Length; i++)
				{
					pixels[i].r = 0;
				}
				val.SetPixels32(pixels);
				val.Apply();
			}
		}

		private static void Restore()
		{
			Texture2D val = Fog();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			BitArray bitArray = f_explored?.GetValue(Minimap.instance) as BitArray;
			Color32[] pixels = val.GetPixels32();
			if (bitArray != null && bitArray.Count == pixels.Length)
			{
				for (int i = 0; i < pixels.Length; i++)
				{
					pixels[i].r = (byte)((!bitArray[i]) ? byte.MaxValue : 0);
				}
			}
			else
			{
				for (int j = 0; j < pixels.Length; j++)
				{
					pixels[j].r = byte.MaxValue;
				}
			}
			val.SetPixels32(pixels);
			val.Apply();
		}
	}
	[HarmonyPatch(typeof(Game), "UpdateRespawn")]
	public class DisableStartShoutPatch
	{
		private static void Prefix(Game __instance)
		{
			if (Plugin.DisableStartShout)
			{
				__instance.SetFieldValue("m_firstSpawn", value: false);
			}
		}
	}
	public static class MobSpawner
	{
		public static bool s_placeMode = false;

		public static int s_stars = 0;

		private static string[] s_names;

		private static string[] s_filtered = new string[0];

		private static int s_idx;

		private static string s_search = "";

		private static string s_selected = "";

		private static int s_dest = 0;

		private static readonly string[] s_destModes = new string[3] { "Crosshair", "Map Pin", "Player" };

		private static string s_count = "1";

		private static Vector2 s_scroll;

		private static string s_status = "";

		private static readonly List<PinData> s_pins = new List<PinData>();

		private static string[] s_pinLabels = null;

		private static int s_pinIdx;

		private static int s_playerIdx;

		private static void EnsureList()
		{
			if (s_names != null || (Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			List<string> list = new List<string>();
			foreach (GameObject prefab in ZNetScene.instance.m_prefabs)
			{
				if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<Character>() != (Object)null && (Object)(object)prefab.GetComponent<Player>() == (Object)null)
				{
					list.Add(((Object)prefab).name);
				}
			}
			list.Sort(StringComparer.OrdinalIgnoreCase);
			s_names = list.ToArray();
			s_filtered = s_names;
		}

		private static void Refilter()
		{
			if (s_names == null)
			{
				s_filtered = new string[0];
				return;
			}
			if (string.IsNullOrEmpty(s_search))
			{
				s_filtered = s_names;
				return;
			}
			List<string> list = new List<string>();
			string[] array = s_names;
			foreach (string text in array)
			{
				if (text.IndexOf(s_search, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					list.Add(text);
				}
			}
			s_filtered = list.ToArray();
		}

		private static void ScanPins()
		{
			s_pins.Clear();
			s_pinIdx = 0;
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				s_pinLabels = new string[1] { "(no minimap)" };
				return;
			}
			List<PinData> list = typeof(Minimap).GetField("m_pins", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(Minimap.instance) as List<PinData>;
			List<string> list2 = new List<string>();
			if (list != null)
			{
				foreach (PinData item in list)
				{
					if (item != null)
					{
						s_pins.Add(item);
						string arg = (string.IsNullOrEmpty(item.m_name) ? ((object)Unsafe.As<PinType, PinType>(ref item.m_type)/*cast due to .constrained prefix*/).ToString() : item.m_name);
						list2.Add($"{arg} ({item.m_pos.x:0},{item.m_pos.z:0})");
					}
				}
			}
			if (list2.Count == 0)
			{
				list2.Add("(no pins placed)");
			}
			s_pinLabels = list2.ToArray();
		}

		public static void DrawGUI()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			EnsureList();
			if (s_names == null || s_names.Length == 0)
			{
				GUILayout.Label("Enter a world to load creatures.", Array.Empty<GUILayoutOption>());
				return;
			}
			Refilter();
			s_search = GUILayout.TextField(s_search, Array.Empty<GUILayoutOption>());
			s_scroll = GUILayout.BeginScrollView(s_scroll, GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(160f) });
			if (s_filtered.Length != 0)
			{
				s_idx = Mathf.Clamp(s_idx, 0, s_filtered.Length - 1);
				s_idx = GUILayout.SelectionGrid(s_idx, s_filtered, 1, Array.Empty<GUILayoutOption>());
				s_selected = s_filtered[s_idx];
			}
			GUILayout.EndScrollView();
			GUILayout.Label((s_stars == 0) ? "Level: 0 stars (normal)" : $"Level: {s_stars} star(s)", Array.Empty<GUILayoutOption>());
			s_stars = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)s_stars, 0f, 50f, Array.Empty<GUILayoutOption>()));
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Count", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
			s_count = GUILayout.TextField(s_count, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
			GUILayout.EndHorizontal();
			GUILayout.Label("Destination:", Array.Empty<GUILayoutOption>());
			s_dest = GUILayout.SelectionGrid(s_dest, s_destModes, 3, Array.Empty<GUILayoutOption>());
			if (s_dest == 0)
			{
				if (GUILayout.Button(s_placeMode ? "Place Mode: ON (middle-click)" : "Place Mode: OFF", Array.Empty<GUILayoutOption>()))
				{
					s_placeMode = !s_placeMode;
				}
				GUILayout.Label("Middle-click places at crosshair. Right-click stops.", Array.Empty<GUILayoutOption>());
			}
			else if (s_dest == 1)
			{
				if (GUILayout.Button("Scan Map Pins", Array.Empty<GUILayoutOption>()))
				{
					ScanPins();
				}
				if (s_pinLabels != null && s_pinLabels.Length != 0)
				{
					s_pinIdx = GUILayout.SelectionGrid(Mathf.Clamp(s_pinIdx, 0, s_pinLabels.Length - 1), s_pinLabels, 1, Array.Empty<GUILayoutOption>());
				}
				if (GUILayout.Button("SPAWN AT PIN", Array.Empty<GUILayoutOption>()))
				{
					SpawnAtPin();
				}
			}
			else
			{
				List<Player> allPlayers = Player.GetAllPlayers();
				List<string> list = new List<string>();
				foreach (Player item in allPlayers)
				{
					if ((Object)(object)item != (Object)null)
					{
						list.Add(item.GetPlayerName());
					}
				}
				if (list.Count > 0)
				{
					s_playerIdx = GUILayout.SelectionGrid(Mathf.Clamp(s_playerIdx, 0, list.Count - 1), list.ToArray(), 1, Array.Empty<GUILayoutOption>());
				}
				if (GUILayout.Button("SPAWN ON PLAYER", Array.Empty<GUILayoutOption>()))
				{
					SpawnOnPlayer(allPlayers);
				}
			}
			if (s_status != "")
			{
				GUILayout.Label(s_status, Array.Empty<GUILayoutOption>());
			}
		}

		private static int Count()
		{
			if (!int.TryParse(s_count, out var result) || result <= 0)
			{
				return 1;
			}
			return result;
		}

		private static void SpawnAtPin()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (s_pinIdx < 0 || s_pinIdx >= s_pins.Count)
			{
				s_status = "No pin (Scan first)";
				return;
			}
			Vector3 pos = s_pins[s_pinIdx].m_pos;
			if ((Object)(object)ZoneSystem.instance != (Object)null)
			{
				float groundHeight = ZoneSystem.instance.GetGroundHeight(pos);
				if (groundHeight > pos.y)
				{
					pos.y = groundHeight;
				}
			}
			int num = SpawnMany(pos);
			s_status = $"Spawned {num}x {s_selected} at pin";
		}

		private static void SpawnOnPlayer(List<Player> players)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (s_playerIdx < 0 || s_playerIdx >= players.Count || (Object)(object)players[s_playerIdx] == (Object)null)
			{
				s_status = "No player";
				return;
			}
			int num = SpawnMany(((Component)players[s_playerIdx]).transform.position);
			s_status = $"Spawned {num}x {s_selected} on {players[s_playerIdx].GetPlayerName()}";
		}

		private static int SpawnMany(Vector3 center)
		{
			//IL_000a: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			int num = Count();
			for (int i = 0; i < num; i++)
			{
				Spawn(center + Random.insideUnitSphere * 1.5f + Vector3.up);
			}
			return num;
		}

		public static void Update()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!s_placeMode || s_dest != 0 || (Object)(object)Player.m_localPlayer == (Object)null)
				{
					return;
				}
				RaycastHit hit;
				if (Input.GetKeyDown((KeyCode)324))
				{
					s_placeMode = false;
				}
				else if (Input.GetKeyDown((KeyCode)325) && Raycast(out hit))
				{
					for (int i = 0; i < Count(); i++)
					{
						Spawn(((RaycastHit)(ref hit)).point);
					}
				}
			}
			catch
			{
			}
		}

		public static void DrawCrosshairLabel()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (s_placeMode && s_dest == 0 && !string.IsNullOrEmpty(s_selected) && !((Object)(object)Player.m_localPlayer == (Object)null))
			{
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
				val.normal.textColor = new Color(1f, 1f, 0.6f);
				GUIStyle val2 = val;
				string text = ((s_stars > 0) ? $"Placing {s_selected} level {s_stars}" : ("Placing " + s_selected));
				GUI.Label(new Rect((float)Screen.width / 2f - 230f, (float)Screen.height / 2f + 24f, 460f, 22f), text, val2);
			}
		}

		private static bool Raycast(out RaycastHit hit)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			hit = default(RaycastHit);
			Camera mainCamera = Utils.GetMainCamera();
			if ((Object)(object)mainCamera == (Object)null)
			{
				return false;
			}
			Ray val = mainCamera.ScreenPointToRay(new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f));
			int mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "terrain", "piece", "piece_nonsolid", "Default_small" });
			return Physics.Raycast(val, ref hit, 300f, mask);
		}

		private static void Spawn(Vector3 pos)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNetScene.instance == (Object)null || string.IsNullOrEmpty(s_selected))
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab(s_selected);
			if ((Object)(object)prefab == (Object)null)
			{
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(prefab, pos, Quaternion.identity);
			if (s_stars > 0 && (Object)(object)val != (Object)null)
			{
				Character component = val.GetComponent<Character>();
				if ((Object)(object)component != (Object)null)
				{
					component.SetLevel(s_stars + 1);
				}
			}
		}
	}
	internal static class Gate
	{
		public static bool ActiveFor(Character c)
		{
			if ((Object)(object)c != (Object)null && (Object)(object)c == (Object)(object)Player.m_localPlayer && (Object)(object)ZNet.instance != (Object)null)
			{
				return ZNet.instance.LocalPlayerIsAdminOrHost();
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Player), "UseStamina")]
	internal static class Patch_UseStamina
	{
		private static bool Prefix(Player __instance)
		{
			if (!Plugin.InfiniteStamina || !Gate.ActiveFor((Character)(object)__instance))
			{
				return true;
			}
			((Character)__instance).AddStamina(((Character)__instance).GetMaxStamina());
			return false;
		}
	}
	[HarmonyPatch(typeof(Character), "UpdateWalking")]
	internal static class Patch_UpdateWalking
	{
		private static float _speed;

		private static float _walk;

		private static float _run;

		private static float _crouch;

		private static float _swim;

		private static bool _scaled;

		private static void Prefix(Character __instance)
		{
			_scaled = false;
			if (Plugin.SpeedEnabled && !(Plugin.SpeedMultiplier <= 1f) && Gate.ActiveFor(__instance))
			{
				_speed = __instance.m_speed;
				_walk = __instance.m_walkSpeed;
				_run = __instance.m_runSpeed;
				_crouch = __instance.m_crouchSpeed;
				_swim = __instance.m_swimSpeed;
				float speedMultiplier = Plugin.SpeedMultiplier;
				__instance.m_speed *= speedMultiplier;
				__instance.m_walkSpeed *= speedMultiplier;
				__instance.m_runSpeed *= speedMultiplier;
				__instance.m_crouchSpeed *= speedMultiplier;
				__instance.m_swimSpeed *= speedMultiplier;
				_scaled = true;
			}
		}

		private static void Postfix(Character __instance)
		{
			if (_scaled)
			{
				__instance.m_speed = _speed;
				__instance.m_walkSpeed = _walk;
				__instance.m_runSpeed = _run;
				__instance.m_crouchSpeed = _crouch;
				__instance.m_swimSpeed = _swim;
				_scaled = false;
			}
		}
	}
	public static class Feat
	{
		public static bool NoEitr;

		public static bool NoEncumbered;

		public static bool AirJump;

		public static bool WalkOnWater;

		public static bool SilentFly;

		public static float FlySpeedMult = 1f;

		public static bool FoodNeverRunsOut;

		public static bool NoClip;

		private const BindingFlags F = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly FieldInfo s_swimTimer = typeof(Character).GetField("m_swimTimer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_lastGroundNormal = typeof(Character).GetField("m_lastGroundNormal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_lastGroundTouch = typeof(Character).GetField("m_lastGroundTouch", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_maxAirAltitude = typeof(Character).GetField("m_maxAirAltitude", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_cashedInLiquidDepth = typeof(Character).GetField("m_cashedInLiquidDepth", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly Type s_foodType = typeof(Player).GetNestedType("Food", BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_foodsField = typeof(Player).GetField("m_foods", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_foodTime = s_foodType?.GetField("m_time", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_foodItem = s_foodType?.GetField("m_item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly MethodInfo s_takeInput = typeof(Player).GetMethod("TakeInput", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static GameObject s_waterPlatform;

		private static bool s_walkOnWaterWasOn;

		private static bool s_silentFlyWasOn;

		private static readonly HashSet<Collider> s_noClipIgnored = new HashSet<Collider>();

		private static bool s_noClipWasOn;

		private static int s_noClipMask;

		private static bool LocalTakesInput()
		{
			try
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null || s_takeInput == null)
				{
					return true;
				}
				return (bool)s_takeInput.Invoke(localPlayer, null);
			}
			catch
			{
				return true;
			}
		}

		public static void Update()
		{
			try
			{
				UpdateInner();
			}
			catch
			{
			}
		}

		private static void UpdateInner()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			UpdateNoClip(localPlayer);
			UpdateWalkOnWater(localPlayer);
			UpdateAirJump(localPlayer);
			if (!SilentFly && s_silentFlyWasOn)
			{
				Rigidbody component = ((Component)localPlayer).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.useGravity = true;
				}
				s_silentFlyWasOn = false;
			}
			if (SilentFly)
			{
				s_silentFlyWasOn = true;
			}
			UpdateFood(localPlayer);
		}

		private static void UpdateWalkOnWater(Player player)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (WalkOnWater && (Object)(object)ZoneSystem.instance != (Object)null)
			{
				float liquidLevel = ((Character)player).GetLiquidLevel();
				float num = ((liquidLevel > -5000f) ? liquidLevel : ZoneSystem.instance.m_waterLevel);
				Vector3 position = ((Component)player).transform.position;
				if ((Object)(object)s_waterPlatform == (Object)null)
				{
					s_waterPlatform = GameObject.CreatePrimitive((PrimitiveType)3);
					((Object)s_waterPlatform).name = "AT_WaterPlatform";
					s_waterPlatform.transform.localScale = new Vector3(30f, 0.2f, 30f);
					Object.Destroy((Object)(object)s_waterPlatform.GetComponent<MeshRenderer>());
					s_waterPlatform.layer = LayerMask.NameToLayer("Default");
				}
				s_waterPlatform.transform.position = new Vector3(position.x, num - 0.1f, position.z);
				s_waterPlatform.SetActive(true);
				if (position.y < num + 1f)
				{
					s_swimTimer?.SetValue(player, 1f);
					s_cashedInLiquidDepth?.SetValue(player, 0f);
				}
				s_walkOnWaterWasOn = true;
			}
			else if (s_walkOnWaterWasOn)
			{
				if ((Object)(object)s_waterPlatform != (Object)null)
				{
					Object.Destroy((Object)(object)s_waterPlatform);
					s_waterPlatform = null;
				}
				s_walkOnWaterWasOn = false;
			}
		}

		private static void UpdateAirJump(Player player)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (AirJump && !((Character)player).IsOnGround() && LocalTakesInput() && ZInput.GetButtonDown("Jump"))
			{
				s_lastGroundTouch?.SetValue(player, 0f);
				s_lastGroundNormal?.SetValue(player, Vector3.up);
				s_maxAirAltitude?.SetValue(player, ((Component)player).transform.position.y);
				((Character)player).Jump(false);
			}
		}

		private static void UpdateFood(Player player)
		{
			if (!FoodNeverRunsOut || s_foodsField == null || s_foodTime == null || s_foodItem == null || !(s_foodsField.GetValue(player) is IList list))
			{
				return;
			}
			foreach (object item in list)
			{
				object? value = s_foodItem.GetValue(item);
				ItemData val = (ItemData)((value is ItemData) ? value : null);
				if (val != null)
				{
					s_foodTime.SetValue(item, val.m_shared.m_foodBurnTime);
				}
			}
		}

		private static void UpdateNoClip(Player player)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			CapsuleCollider component = ((Component)player).GetComponent<CapsuleCollider>();
			if (NoClip)
			{
				if ((Object)(object)component != (Object)null)
				{
					if (s_noClipMask == 0)
					{
						s_noClipMask = LayerMask.GetMask(new string[7] { "piece", "piece_nonsolid", "Default", "static_solid", "Default_small", "blocker", "vehicle" });
					}
					Collider[] array = Physics.OverlapSphere(((Component)player).transform.position, 8f, s_noClipMask, (QueryTriggerInteraction)1);
					foreach (Collider val in array)
					{
						if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)component) && s_noClipIgnored.Add(val))
						{
							Physics.IgnoreCollision((Collider)(object)component, val, true);
						}
					}
				}
				s_noClipWasOn = true;
			}
			else
			{
				if (!s_noClipWasOn)
				{
					return;
				}
				foreach (Collider item in s_noClipIgnored)
				{
					if ((Object)(object)item != (Object)null && (Object)(object)component != (Object)null)
					{
						Physics.IgnoreCollision((Collider)(object)component, item, false);
					}
				}
				s_noClipIgnored.Clear();
				s_noClipWasOn = false;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "RPC_UseEitr")]
	public class NoEitr_Use
	{
		private static readonly FieldInfo s_eitr = typeof(Player).GetField("m_eitr", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_maxEitr = typeof(Player).GetField("m_maxEitr", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static void Postfix(Player __instance, float v)
		{
			if (Feat.NoEitr && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && v != 0f && !(s_eitr == null) && !(s_maxEitr == null))
			{
				float num = (float)s_eitr.GetValue(__instance) + v;
				float num2 = (float)s_maxEitr.GetValue(__instance);
				if (num > num2)
				{
					num = num2;
				}
				s_eitr.SetValue(__instance, num);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "HaveEitr")]
	public class NoEitr_Have
	{
		private static void Postfix(Player __instance, ref bool __result)
		{
			if (Feat.NoEitr && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "GetMaxEitr")]
	public class NoEitr_Max
	{
		private static void Postfix(Player __instance, ref float __result)
		{
			if (Feat.NoEitr && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && __result <= 0f)
			{
				__result = 100f;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "IsEncumbered")]
	internal static class NoEncumbered_Patch
	{
		private static void Postfix(ref bool __result)
		{
			if (Feat.NoEncumbered)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(Character), "Jump")]
	public static class AirJump_Patch
	{
		private const BindingFlags F = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly FieldInfo s_lastGroundTouch = typeof(Character).GetField("m_lastGroundTouch", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_lastGroundNormal = typeof(Character).GetField("m_lastGroundNormal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_maxAirAltitude = typeof(Character).GetField("m_maxAirAltitude", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static void Prefix(Character __instance)
		{
			//IL_003c: 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)
			if (Feat.AirJump && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				s_lastGroundTouch?.SetValue(__instance, 0f);
				s_lastGroundNormal?.SetValue(__instance, Vector3.up);
				s_maxAirAltitude?.SetValue(__instance, ((Component)__instance).transform.position.y);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "UpdateMotion")]
	internal static class SilentFly_UpdateMotion
	{
		private static readonly MethodInfo s_updateDebugFly = typeof(Character).GetMethod("UpdateDebugFly", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly FieldInfo s_zanim = typeof(Character).GetField("m_zanim", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo s_run = typeof(Character).GetField("m_run", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private const float BASE_FLY_SPEED = 20f;

		private static readonly int s_inWater = ZSyncAnimation.GetHash("inWater");

		private static readonly int s_onGround = ZSyncAnimation.GetHash("onGround");

		private static readonly int s_flying = ZSyncAnimation.GetHash("flying");

		private static readonly int s_falling = ZSyncAnimation.GetHash("falling");

		private static readonly int s_forwardSpeed = ZSyncAnimation.GetHash("forward_speed");

		private static readonly int s_sidewaySpeed = ZSyncAnimation.GetHash("sideway_speed");

		private static bool Prefix(Character __instance, float dt)
		{
			if (!Feat.SilentFly || (Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			if (__instance.IsDead() || __instance.IsDebugFlying() || s_updateDebugFly == null)
			{
				return true;
			}
			float num = 20f * Feat.FlySpeedMult;
			bool flag = s_run != null && (bool)s_run.GetValue(__instance);
			Character.m_debugFlySpeed = Mathf.Max(1, Mathf.RoundToInt(flag ? (num / 2.5f) : num));
			s_updateDebugFly.Invoke(__instance, new object[1] { dt });
			object? obj = s_zanim?.GetValue(__instance);
			ZSyncAnimation val = (ZSyncAnimation)((obj is ZSyncAnimation) ? obj : null);
			if ((Object)(object)val != (Object)null)
			{
				val.SetBool(s_inWater, false);
				val.SetBool(s_onGround, false);
				val.SetBool(s_flying, false);
				val.SetBool(s_falling, false);
				val.SetFloat(s_forwardSpeed, 0f);
				val.SetFloat(s_sidewaySpeed, 0f);
			}
			return false;
		}
	}
	[BepInPlugin("klx.valheim.admintool", "Powerful Admin Tool", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private enum Rebind
		{
			None,
			InvisFull,
			InvisPartial,
			Freecam
		}

		private enum Tab
		{
			Main,
			ESP,
			Map,
			Items,
			Mobs,
			Building
		}

		public const string GUID = "klx.valheim.admintool";

		public const string NAME = "Powerful Admin Tool";

		public const string VERSION = "1.1.0";

		public static bool InfiniteStamina;

		public static bool SpeedEnabled;

		public static float SpeedMultiplier = 1f;

		public static bool Invisible;

		public static bool InvisibleFull;

		public static bool RemoveAnything;

		public static bool EspPlayers;

		public static bool EspMobs;

		public static bool EspLookStructure;

		public static bool EspLookChest;

		public static bool EspLookTree;

		public static bool EspLookRock;

		public static bool EspPlayerList;

		public static bool DisableStartShout;

		private Harmony _harmony;

		private bool _menuOpen;

		private Rect _window = new Rect(40f, 40f, 460f, 380f);

		private ConfigEntry<KeyCode> _toggleKey;

		private ConfigEntry<KeyCode> _invisKey;

		private ConfigEntry<KeyCode> _invisPartialKey;

		private ConfigEntry<KeyCode> _freecamKey;

		private Rebind _rebinding;

		public static bool MenuOpen;

		private Tab _tab;

		private Vector2 _mainScroll;

		private Vector2 _healScroll;

		private string _healAmount = "100";

		private void Awake()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			_toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleMenuKey", (KeyCode)277, "Opens/closes the admin menu.");
			_invisKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "InvisibilityFullKey", (KeyCode)282, "Toggles Invisibility (Full).");
			_invisPartialKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "InvisibilityPartialKey", (KeyCode)284, "Toggles Invisibility (Partial).");
			_freecamKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "FreecamKey", (KeyCode)283, "Toggles Freecam.");
			_harmony = new Harmony("klx.valheim.admintool");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Powerful Admin Tool 1.1.0 loaded.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private static bool IsAdmin()
		{
			if ((Object)(object)ZNet.instance != (Object)null)
			{
				return ZNet.instance.LocalPlayerIsAdminOrHost();
			}
			return false;
		}

		private void Update()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAdmin())
			{
				if (_menuOpen)
				{
					_menuOpen = false;
					SetMouseCapture(capture: true);
				}
				return;
			}
			if (Input.GetKeyDown(_toggleKey.Value))
			{
				_menuOpen = !_menuOpen;
				_rebinding = Rebind.None;
				SetMouseCapture(!_menuOpen);
			}
			if (_rebinding == Rebind.None)
			{
				if (Input.GetKeyDown(_invisKey.Value))
				{
					InvisibleFull = !InvisibleFull;
				}
				if (Input.