Decompiled source of Valheim Admin Tool v0.5.8

ValheimAdminTool.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OptionalAuga;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;
using ValheimAdminTool.Patches;
using ValheimAdminTool.Protocol;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Valheim Admin Tool")]
[assembly: AssemblyDescription("A 2D admin menu mod for Valheim.")]
[assembly: AssemblyCompany("icecub")]
[assembly: AssemblyProduct("Valheim Admin Tool")]
[assembly: AssemblyCopyright("")]
[assembly: ComVisible(false)]
[assembly: Guid("e851069a-4938-47f0-9c1a-7e16b9bf622c")]
[assembly: AssemblyFileVersion("0.5.8")]
[assembly: InternalsVisibleTo("VAT.Invisibility")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.5.8.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 OptionalAuga
{
	internal static class AugaTheme
	{
		private static Type _api;

		private static Type _restyler;

		private static Type _options;

		private static bool _warned;

		internal static bool Enabled
		{
			get
			{
				if (!Chainloader.PluginInfos.TryGetValue("randyknapp.mods.auga", out var value))
				{
					return false;
				}
				Assembly assembly = ((object)value.Instance).GetType().Assembly;
				if ((object)_api == null)
				{
					_api = assembly.GetType("Auga.API");
				}
				if ((object)_restyler == null)
				{
					_restyler = assembly.GetType("Auga.AugaPanelRestyler");
				}
				if ((object)_options == null)
				{
					_options = assembly.GetType("Auga.RestyleOptions");
				}
				return _api != null;
			}
		}

		internal static Color Body => new Color(0.918f, 0.882f, 0.851f);

		internal static Color Muted => new Color(0.639f, 0.588f, 0.537f);

		internal static Color Surface => new Color(0.18f, 0.149f, 0.125f, 0.96f);

		internal static Color Input => new Color(0.094f, 0.078f, 0.063f, 0.95f);

		internal static Color Accent => new Color(0.914f, 0.659f, 0f);

		private static void Try(Action action)
		{
			try
			{
				action();
			}
			catch (Exception ex)
			{
				if (!_warned)
				{
					_warned = true;
					Debug.LogWarning((object)("[OptionalAugaUI] Native decoration unavailable: " + ex.GetType().Name));
				}
			}
		}

		internal static void Panel(RectTransform root)
		{
			if (!Enabled)
			{
				return;
			}
			Try(delegate
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Expected O, but got Unknown
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: 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_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: 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)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				MethodInfo? method = _api.GetMethod("Panel_Create");
				object[] obj = new object[4] { root, null, null, null };
				Rect rect = root.rect;
				obj[1] = ((Rect)(ref rect)).size;
				obj[2] = "Auga decoration";
				obj[3] = true;
				GameObject val = (GameObject)method.Invoke(null, obj);
				if (Object.op_Implicit((Object)(object)val))
				{
					RectTransform val2 = (RectTransform)val.transform;
					val2.anchorMin = Vector2.zero;
					val2.anchorMax = Vector2.one;
					Vector2 offsetMin = (val2.offsetMax = Vector2.zero);
					val2.offsetMin = offsetMin;
					((Transform)val2).SetAsFirstSibling();
					Graphic[] componentsInChildren = val.GetComponentsInChildren<Graphic>(true);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].raycastTarget = false;
					}
					Image component = ((Component)root).GetComponent<Image>();
					if (Object.op_Implicit((Object)(object)component))
					{
						((Graphic)component).color = Color.clear;
					}
				}
			});
		}

		internal static void Text(TMP_Text text, bool title = false)
		{
			if (!Enabled || _restyler == null)
			{
				return;
			}
			Try(delegate
			{
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Expected O, but got Unknown
				text.alignment = (TextAlignmentOptions)514;
				if (title && _options != null)
				{
					object obj = Activator.CreateInstance(_options);
					_options.GetField("TitleFontSize").SetValue(obj, text.fontSize);
					_restyler.GetMethod("StyleTitle").Invoke(null, new object[2] { text, obj });
				}
				else
				{
					TMP_FontAsset val = (TMP_FontAsset)_restyler.GetProperty("RegularFont").GetValue(null);
					if (Object.op_Implicit((Object)(object)val))
					{
						text.font = val;
						text.fontSharedMaterial = ((TMP_Asset)val).material;
					}
				}
			});
		}

		internal static void Button(Button button, TMP_Text label)
		{
			if (!Enabled)
			{
				return;
			}
			Try(delegate
			{
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Expected O, but got Unknown
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: 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_007c: 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_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_0148: Unknown result type (might be due to invalid IL or missing references)
				Button val = (Button)_api.GetMethod("SmallButton_Create").Invoke(null, new object[3]
				{
					((Component)button).transform,
					"Auga button decoration",
					""
				});
				if (Object.op_Implicit((Object)(object)val))
				{
					((UnityEventBase)val.onClick).RemoveAllListeners();
					((Behaviour)val).enabled = false;
					RectTransform val2 = (RectTransform)((Component)val).transform;
					val2.anchorMin = Vector2.zero;
					val2.anchorMax = Vector2.one;
					Vector2 offsetMin = (val2.offsetMax = Vector2.zero);
					val2.offsetMin = offsetMin;
					((Transform)val2).SetAsFirstSibling();
					TMP_Text[] componentsInChildren = ((Component)val).GetComponentsInChildren<TMP_Text>(true);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						((Component)componentsInChildren[i]).gameObject.SetActive(false);
					}
					Graphic[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Graphic>(true);
					for (int i = 0; i < componentsInChildren2.Length; i++)
					{
						componentsInChildren2[i].raycastTarget = false;
					}
					Image component = ((Component)button).GetComponent<Image>();
					if (Object.op_Implicit((Object)(object)component))
					{
						((Graphic)component).color = Color.clear;
					}
					if (Object.op_Implicit((Object)(object)((Selectable)val).targetGraphic))
					{
						((Selectable)button).targetGraphic = ((Selectable)val).targetGraphic;
					}
					((Selectable)button).colors = ((Selectable)val).colors;
					if (Object.op_Implicit((Object)(object)label))
					{
						((Graphic)label).color = Body;
						label.fontStyle = (FontStyles)16;
						label.alignment = (TextAlignmentOptions)514;
						object? obj = _restyler?.GetProperty("BoldFont")?.GetValue(null);
						TMP_FontAsset val3 = (TMP_FontAsset)((obj is TMP_FontAsset) ? obj : null);
						if (Object.op_Implicit((Object)(object)val3))
						{
							label.font = val3;
							label.fontSharedMaterial = ((TMP_Asset)val3).material;
						}
						label.transform.SetAsLastSibling();
					}
				}
			});
		}

		internal static void Toggle(Toggle toggle)
		{
			if (Enabled && !(_restyler == null))
			{
				Try(delegate
				{
					_restyler.GetMethod("RestyleToggleInPlace").Invoke(null, new object[1] { toggle });
				});
			}
		}

		internal static void LegacyText(Text text, bool heading = false)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			if (Enabled)
			{
				text.alignment = (TextAnchor)4;
				((Graphic)text).color = (Color)(heading ? Accent : new Color(Body.r, Body.g, Body.b, ((Graphic)text).color.a));
				object? obj = _restyler?.GetProperty(heading ? "BoldFont" : "RegularFont")?.GetValue(null);
				TMP_FontAsset val = (TMP_FontAsset)((obj is TMP_FontAsset) ? obj : null);
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.sourceFontFile))
				{
					text.font = val.sourceFontFile;
				}
			}
		}

		internal static void LegacyButton(Button button)
		{
			if (Enabled)
			{
				Button(button, null);
				Text[] componentsInChildren = ((Component)button).GetComponentsInChildren<Text>(true);
				foreach (Text obj in componentsInChildren)
				{
					LegacyText(obj);
					((Component)obj).transform.SetAsLastSibling();
				}
			}
		}

		internal static void Slider(Slider slider)
		{
			if (Enabled && !(_restyler == null))
			{
				Try(delegate
				{
					_restyler.GetMethod("RestyleSliderInPlace").Invoke(null, new object[1] { slider });
				});
			}
		}
	}
}
namespace ValheimAdminTool
{
	internal sealed class AdminAccessState
	{
		private string nonce = string.Empty;

		private float started;

		private float toolsSeen;

		private float guardSeen;

		private bool toolsAdmin;

		private bool guardAdmin;

		internal float Now { get; set; }

		internal bool Connected { get; private set; }

		internal bool Host { get; private set; }

		internal bool ToolsPresent { get; private set; }

		internal bool GuardPresent { get; private set; }

		internal bool Discovering
		{
			get
			{
				if (Connected && !Host && !GuardPresent)
				{
					return Now - started < 5f;
				}
				return false;
			}
		}

		internal bool Allowed
		{
			get
			{
				if (Connected)
				{
					if (!Host)
					{
						if (!Discovering)
						{
							if (GuardPresent)
							{
								if (guardAdmin)
								{
									return Now - guardSeen <= 10f;
								}
								return false;
							}
							return true;
						}
						return false;
					}
					return true;
				}
				return false;
			}
		}

		internal bool ServerTools
		{
			get
			{
				if (Allowed)
				{
					if (!Host)
					{
						if (ToolsPresent && toolsAdmin)
						{
							return Now - toolsSeen <= 10f;
						}
						return false;
					}
					return true;
				}
				return false;
			}
		}

		internal bool LocalResets
		{
			get
			{
				if (Allowed && !Host)
				{
					return !ToolsPresent;
				}
				return false;
			}
		}

		internal bool ResourceResets
		{
			get
			{
				if (!ServerTools)
				{
					return LocalResets;
				}
				return true;
			}
		}

		internal void Begin(string sessionNonce, bool host, float now)
		{
			Reset();
			nonce = sessionNonce;
			Connected = true;
			Host = host;
			float num = (Now = now);
			started = num;
		}

		internal bool Receive(bool guard, int version, string sessionNonce, bool admin, float now)
		{
			if (!Connected || Host || nonce != sessionNonce)
			{
				return false;
			}
			Now = now;
			if (guard)
			{
				GuardPresent = true;
				guardAdmin = version == 1 && admin;
				guardSeen = now;
			}
			else
			{
				ToolsPresent = true;
				toolsAdmin = version == 1 && admin;
				toolsSeen = now;
			}
			return true;
		}

		internal void Reset()
		{
			bool flag = (GuardPresent = (toolsAdmin = (guardAdmin = false)));
			bool flag3 = (ToolsPresent = flag);
			bool connected = (Host = flag3);
			Connected = connected;
			nonce = string.Empty;
			float num = (Now = 0f);
			started = (toolsSeen = (guardSeen = num));
		}
	}
	internal static class AdminActions
	{
		private static bool requestedInstantCrafting;

		private static readonly Dictionary<Collider, bool> SavedNoClipColliderStates = new Dictionary<Collider, bool>();

		private static readonly MethodInfo GetSkillMethod = AccessTools.Method(typeof(Skills), "GetSkill", new Type[1] { typeof(SkillType) }, (Type[])null);

		private static readonly MethodInfo RebalanceSkillsMethod = AccessTools.Method(typeof(Skills), "RebalanceSkills", new Type[1] { typeof(SkillType) }, (Type[])null);

		private static readonly MethodInfo TameMethod = AccessTools.Method(typeof(Tameable), "Tame", (Type[])null, (Type[])null);

		private static readonly FieldRef<Skill, float> SkillLevelRef = AccessTools.FieldRefAccess<Skill, float>("m_level");

		private static readonly FieldRef<Skill, float> SkillAccumulatorRef = AccessTools.FieldRefAccess<Skill, float>("m_accumulator");

		private static readonly FieldRef<Skills, bool> UseSkillCapRef = AccessTools.FieldRefAccess<Skills, bool>("m_useSkillCap");

		private static readonly FieldRef<Player, int> ComfortLevelRef = AccessTools.FieldRefAccess<Player, int>("m_comfortLevel");

		private static bool requestedUnlimitedStamina;

		private static bool requestedUnlimitedEitr;

		private static bool requestedNoCarryLimit;

		private static bool requestedBuildEverywhere;

		private static bool requestedNoStructuralDamage;

		private static bool requestedDisableItemLoss;

		private static bool requestedDisableFoodLoss;

		private static bool requestedDisableStatusLoss;

		private static bool requestedDisableSkillLoss;

		private static bool requestedEnableWindInBack;

		private static bool requestedEnableShipSpeedHack;

		private static bool ownedGodMode;

		private static bool ownedDebugMode;

		private static bool ownedFlyMode;

		private static bool ownedNoClipMode;

		private static bool ownedFreeCamMode;

		private static bool ownedGhostMode;

		private static bool ownedNoBuildCost;

		private static readonly FieldInfo DevCommandsField = typeof(Terminal).GetField("m_cheat", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? throw new MissingFieldException("Terminal", "m_cheat");

		private static bool ownedDevCommands;

		private static bool requestedDisableDurabilityLoss;

		private static bool requestedDisableFoodDegradation;

		private static bool requestedForgeAlwaysSucceed;

		private static bool requestedMoonGravity;

		private static bool requestedSuperKnockback;

		private static bool requestedBouncyMode;

		private static bool requestedPartyHits;

		private static bool requestedInfiniteJumps;

		private static bool requestedMapTeleport;

		private static bool requestedUnrestrictedPortals;

		internal static bool InstantCrafting
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedInstantCrafting;
				}
				return false;
			}
		}

		internal static bool UnlimitedStamina
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedUnlimitedStamina;
				}
				return false;
			}
			private set
			{
				requestedUnlimitedStamina = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool UnlimitedEitr
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedUnlimitedEitr;
				}
				return false;
			}
			private set
			{
				requestedUnlimitedEitr = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool NoCarryLimit
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedNoCarryLimit;
				}
				return false;
			}
			private set
			{
				requestedNoCarryLimit = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool BuildEverywhere
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedBuildEverywhere;
				}
				return false;
			}
			private set
			{
				requestedBuildEverywhere = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool NoStructuralDamage
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedNoStructuralDamage;
				}
				return false;
			}
			private set
			{
				requestedNoStructuralDamage = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool DisableItemLoss
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedDisableItemLoss;
				}
				return false;
			}
			private set
			{
				requestedDisableItemLoss = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool DisableFoodLoss
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedDisableFoodLoss;
				}
				return false;
			}
			private set
			{
				requestedDisableFoodLoss = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool DisableStatusLoss
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedDisableStatusLoss;
				}
				return false;
			}
			private set
			{
				requestedDisableStatusLoss = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool DisableSkillLoss
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedDisableSkillLoss;
				}
				return false;
			}
			private set
			{
				requestedDisableSkillLoss = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool EnableWindInBack
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedEnableWindInBack;
				}
				return false;
			}
			private set
			{
				requestedEnableWindInBack = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool EnableShipSpeedHack
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedEnableShipSpeedHack;
				}
				return false;
			}
			private set
			{
				requestedEnableShipSpeedHack = value && AdminNetworkAccess.Allowed;
			}
		}

		internal static bool DisableDurabilityLoss
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedDisableDurabilityLoss;
				}
				return false;
			}
		}

		internal static bool DisableFoodDegradation
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedDisableFoodDegradation;
				}
				return false;
			}
		}

		internal static bool ForgeAlwaysSucceed
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedForgeAlwaysSucceed;
				}
				return false;
			}
		}

		internal static bool MoonGravity
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedMoonGravity;
				}
				return false;
			}
		}

		internal static bool SuperKnockback
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedSuperKnockback;
				}
				return false;
			}
		}

		internal static bool BouncyMode
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedBouncyMode;
				}
				return false;
			}
		}

		internal static bool PartyHits
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedPartyHits;
				}
				return false;
			}
		}

		internal static bool InfiniteJumps
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedInfiniteJumps;
				}
				return false;
			}
		}

		internal static bool MapTeleport
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedMapTeleport;
				}
				return false;
			}
		}

		internal static bool UnrestrictedPortals
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return requestedUnrestrictedPortals;
				}
				return false;
			}
		}

		public static void OnInstantCraftingToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedInstantCrafting = enabled;
			}
		}

		internal static void ResetInstantCrafting()
		{
			requestedInstantCrafting = false;
		}

		internal static bool NoClipActiveFor(Character character)
		{
			if (ownedNoClipMode && AdminNetworkAccess.Allowed && (Object)(object)character == (Object)(object)Player.m_localPlayer)
			{
				return character.IsOwner();
			}
			return false;
		}

		internal static void ResetActiveCheats()
		{
			AdminWardOverride.Reset();
			ResetMapTeleport();
			ResetUnrestrictedPortals();
			AdminPoi.Reset();
			ResetInstantCrafting();
			ResetForgeAlwaysSucceed();
			AdminEnvironment.ResetLocal();
			ResetFoodDegradation();
			ResetDurabilityLoss();
			ResetInfiniteJumps();
			ResetFun();
			AdminSpeeds.Reset();
			AdminCarryWeight.Reset();
			if (ownedGodMode)
			{
				OnGodModeToggled(enabled: false);
			}
			if (ownedDebugMode)
			{
				OnDebugModeToggled(enabled: false);
			}
			if (ownedFlyMode)
			{
				OnFlyModeToggled(enabled: false);
			}
			if (ownedNoClipMode)
			{
				OnNoClipModeToggled(enabled: false);
			}
			if (ownedFreeCamMode)
			{
				OnFreeCamModeToggled(enabled: false);
			}
			if (ownedGhostMode)
			{
				OnGhostModeToggled(enabled: false);
			}
			if (ownedNoBuildCost)
			{
				OnNoBuildCostToggled(enabled: false);
			}
			requestedUnlimitedStamina = false;
			requestedUnlimitedEitr = false;
			requestedNoCarryLimit = false;
			requestedBuildEverywhere = false;
			requestedNoStructuralDamage = false;
			requestedDisableItemLoss = false;
			requestedDisableFoodLoss = false;
			requestedDisableStatusLoss = false;
			requestedDisableSkillLoss = false;
			requestedEnableWindInBack = false;
			requestedEnableShipSpeedHack = false;
			RestoreColliders();
			EnvManSetTargetWindPatch.RestoreAllShipForces();
			PlayerOnDeathPatch.ClearSnapshots();
		}

		public static void OnGodModeToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				ownedGodMode = enabled;
				Player? localPlayer = GetLocalPlayer();
				if (localPlayer != null)
				{
					localPlayer.SetGodMode(enabled);
				}
			}
		}

		public static void OnUnlimitedStaminaToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				UnlimitedStamina = enabled;
			}
		}

		public static void OnUnlimitedEitrToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				UnlimitedEitr = enabled;
			}
		}

		public static void OnFlyModeToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				ownedFlyMode = enabled;
				SetDebugFly(enabled);
			}
		}

		public static void OnNoClipModeToggled(bool enabled)
		{
			if (enabled && !AdminNetworkAccess.Allowed)
			{
				return;
			}
			bool flag = ownedNoClipMode;
			if (enabled && flag)
			{
				return;
			}
			ownedNoClipMode = enabled;
			Player localPlayer = GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			SetDebugFly(enabled);
			if (enabled)
			{
				AdminNoClipLiquids.Detach(localPlayer);
				SavedNoClipColliderStates.Clear();
				Collider[] componentsInChildren = ((Component)localPlayer).GetComponentsInChildren<Collider>();
				foreach (Collider val in componentsInChildren)
				{
					SavedNoClipColliderStates[val] = val.enabled;
					val.enabled = false;
				}
			}
			else
			{
				if (flag)
				{
					AdminNoClipLiquids.Detach(localPlayer);
				}
				RestoreColliders();
			}
		}

		private static void RestoreColliders()
		{
			foreach (KeyValuePair<Collider, bool> savedNoClipColliderState in SavedNoClipColliderStates)
			{
				if ((Object)(object)savedNoClipColliderState.Key != (Object)null)
				{
					savedNoClipColliderState.Key.enabled = savedNoClipColliderState.Value;
				}
			}
			SavedNoClipColliderStates.Clear();
		}

		public static void OnFreeCamModeToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				ownedFreeCamMode = enabled;
				if (!((Object)(object)GameCamera.instance == (Object)null) && GameCamera.InFreeFly() != enabled)
				{
					GameCamera.instance.ToggleFreeFly();
				}
			}
		}

		public static void OnGhostModeToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				ownedGhostMode = enabled;
				Player? localPlayer = GetLocalPlayer();
				if (localPlayer != null)
				{
					localPlayer.SetGhostMode(enabled);
				}
			}
		}

		public static void OnNoCarryLimitToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				NoCarryLimit = enabled;
			}
		}

		public static void OnNoBuildCostToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				ownedNoBuildCost = enabled;
				Player? localPlayer = GetLocalPlayer();
				if (localPlayer != null)
				{
					localPlayer.SetNoPlacementCost(enabled);
				}
			}
		}

		public static void OnBuildEverywhereToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				BuildEverywhere = enabled;
			}
		}

		public static void OnNoStructuralDamageToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				NoStructuralDamage = enabled;
			}
		}

		public static void OnDisableItemLossToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				DisableItemLoss = enabled;
			}
		}

		public static void OnDisableFoodLossToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				DisableFoodLoss = enabled;
			}
		}

		public static void OnDisableStatusLossToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				DisableStatusLoss = enabled;
			}
		}

		public static void OnDisableSkillLossToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				DisableSkillLoss = enabled;
			}
		}

		public static void OnEnableWindInBackToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				EnableWindInBack = enabled;
			}
		}

		public static void OnEnableShipSpeedHackToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				EnableShipSpeedHack = enabled;
				if (!enabled)
				{
					EnvManSetTargetWindPatch.RestoreLocalShipSailForce();
				}
			}
		}

		public static void OnQuickHealClicked()
		{
			if (AdminNetworkAccess.Allowed)
			{
				Player localPlayer = GetLocalPlayer();
				if (localPlayer != null)
				{
					((Character)localPlayer).SetHealth(((Character)localPlayer).GetMaxHealth());
				}
			}
		}

		public static void OnGiveOneHourRestedClicked()
		{
			if (AdminNetworkAccess.Allowed)
			{
				Player localPlayer = GetLocalPlayer();
				if (!((Object)(object)localPlayer == (Object)null))
				{
					int num = ComfortLevelRef.Invoke(localPlayer);
					ComfortLevelRef.Invoke(localPlayer) = 53;
					((Character)localPlayer).GetSEMan().AddStatusEffect(SEMan.s_statusEffectRested, true, 0, 0f, (short)(-1));
					ComfortLevelRef.Invoke(localPlayer) = num;
				}
			}
		}

		public static void OnExploreMapClicked()
		{
			if (AdminNetworkAccess.Allowed)
			{
				Minimap instance = Minimap.instance;
				if (instance != null)
				{
					instance.ExploreAll();
				}
			}
		}

		public static void OnShowWorldSeedClicked()
		{
			if (AdminNetworkAccess.Allowed)
			{
				World val = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetWorld() : null);
				if (val == null || string.IsNullOrEmpty(val.m_seedName))
				{
					AdminNetworkAccess.ShowMessage("World seed is not available. Enter a world first.");
				}
				else
				{
					AdminNetworkAccess.ShowMessage("World seed: " + val.m_seedName);
				}
			}
		}

		public static void OnResetMapClicked()
		{
			if (AdminNetworkAccess.Allowed)
			{
				AdminPoi.Reset();
				Minimap instance = Minimap.instance;
				if (instance != null)
				{
					instance.Reset();
				}
			}
		}

		public static void OnRevealPoiClicked()
		{
			if (AdminNetworkAccess.Allowed)
			{
				AdminPoi.Toggle();
			}
		}

		public static void OnBossPowerClicked(string statusEffectName)
		{
			if (AdminNetworkAccess.Allowed)
			{
				Player localPlayer = GetLocalPlayer();
				if ((Object)(object)localPlayer == (Object)null)
				{
					ShowCenterMessage("Player is not ready yet.");
					return;
				}
				((Character)localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode(statusEffectName), true, 0, 0f, (short)(-1));
				ShowCenterMessage("Boss power activated.");
			}
		}

		public static void OnRunSkillChanged(int value)
		{
			SetSkill((SkillType)102, value);
		}

		public static void OnBowsSkillChanged(int value)
		{
			SetSkill((SkillType)8, value);
		}

		public static void OnSwordsSkillChanged(int value)
		{
			SetSkill((SkillType)1, value);
		}

		public static void OnCraftingSkillChanged(int value)
		{
			SetSkill((SkillType)107, value);
		}

		public static void OnFistsSkillChanged(int value)
		{
			SetSkill((SkillType)11, value);
		}

		public static void OnAxesSkillChanged(int value)
		{
			SetSkill((SkillType)7, value);
		}

		public static void OnBlockingSkillChanged(int value)
		{
			SetSkill((SkillType)6, value);
		}

		public static void OnClubsSkillChanged(int value)
		{
			SetSkill((SkillType)3, value);
		}

		public static void OnFarmingSkillChanged(int value)
		{
			SetSkill((SkillType)106, value);
		}

		public static void OnSneakSkillChanged(int value)
		{
			SetSkill((SkillType)101, value);
		}

		public static void OnJumpSkillChanged(int value)
		{
			SetSkill((SkillType)100, value);
		}

		public static void OnWoodCuttingSkillChanged(int value)
		{
			SetSkill((SkillType)13, value);
		}

		public static void OnCookingSkillChanged(int value)
		{
			SetSkill((SkillType)105, value);
		}

		public static void OnSwimSkillChanged(int value)
		{
			SetSkill((SkillType)103, value);
		}

		public static void OnKnivesSkillChanged(int value)
		{
			SetSkill((SkillType)2, value);
		}

		public static void OnPickaxesSkillChanged(int value)
		{
			SetSkill((SkillType)12, value);
		}

		public static void OnPolearmsSkillChanged(int value)
		{
			SetSkill((SkillType)4, value);
		}

		public static void OnCrossbowsSkillChanged(int value)
		{
			SetSkill((SkillType)14, value);
		}

		public static void OnResetDungeonsClicked()
		{
			AdminToolRpcs.RequestWorldReset(AdminToolRpcs.WorldResetKind.Dungeons);
		}

		public static void OnResetResourcesClicked()
		{
			AdminToolRpcs.RequestWorldReset(AdminToolRpcs.WorldResetKind.Resources);
		}

		public static void OnRegenerateNatureClicked()
		{
			AdminToolRpcs.RequestWorldReset(AdminToolRpcs.WorldResetKind.Nature);
		}

		public static void OnTeleportToPlayerClicked(string playerName)
		{
			AdminToolRpcs.RequestTool(ServerToolAction.TeleportToPlayer, playerName);
		}

		public static void OnTeleportPlayerToMeClicked(string playerName)
		{
			AdminToolRpcs.RequestTool(ServerToolAction.TeleportPlayerHere, playerName);
		}

		public static void OnKickPlayerClicked(string playerName)
		{
			AdminToolRpcs.RequestTool(ServerToolAction.KickPlayer, playerName);
		}

		public static void OnBanPlayerClicked(string playerName)
		{
			AdminToolRpcs.RequestTool(ServerToolAction.BanPlayer, playerName);
		}

		public static List<string> GetOnlinePlayerNames()
		{
			//IL_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return list;
			}
			foreach (PlayerInfo player in ZNet.instance.GetPlayerList())
			{
				if (!string.IsNullOrWhiteSpace(player.m_name))
				{
					list.Add(player.m_name);
				}
			}
			return (from name in list.Distinct()
				orderby name
				select name).ToList();
		}

		public static List<AdminCreatureInfo> GetSpawnableCreatures()
		{
			return AdminCatalog.GetCreatures();
		}

		public static void SpawnCreature(AdminCreatureInfo? creature, int level, bool tamed)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00ce: 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)
			if (!AdminNetworkAccess.Allowed)
			{
				return;
			}
			Player localPlayer = GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null || creature == null)
			{
				ShowCenterMessage("Select a creature first.");
				return;
			}
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				ShowCenterMessage("Creature database is not ready yet.");
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab(creature.PrefabName);
			if ((Object)(object)prefab == (Object)null)
			{
				ShowCenterMessage("Creature prefab was not found.");
				return;
			}
			if (tamed && (Object)(object)prefab.GetComponent<Tameable>() == (Object)null)
			{
				ShowCenterMessage(creature.DisplayName + " cannot be spawned as tamed.");
				return;
			}
			int num = Mathf.Clamp(level, 1, 3);
			Transform transform = ((Component)localPlayer).transform;
			Vector3 val = transform.position + transform.forward * 3f + Vector3.up * 0.5f;
			GameObject val2 = Object.Instantiate<GameObject>(prefab, val, Quaternion.LookRotation(transform.forward));
			Character component = val2.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				component.SetLevel(num);
			}
			if (tamed)
			{
				Tameable component2 = val2.GetComponent<Tameable>();
				if ((Object)(object)component2 != (Object)null)
				{
					TameMethod.Invoke(component2, null);
				}
			}
			ShowCenterMessage($"Spawned level {num} {creature.DisplayName}.");
		}

		public static bool TryGetSkillLevel(SkillType skillType, out int level)
		{
			//IL_0012: 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_001b: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			level = 0;
			Skills localSkills = GetLocalSkills();
			if ((Object)(object)localSkills == (Object)null || (int)skillType == 0 || (int)skillType == 999)
			{
				return false;
			}
			Skill skill = GetSkill(localSkills, skillType);
			if (skill == null)
			{
				return false;
			}
			level = Mathf.RoundToInt(Mathf.Clamp(SkillLevelRef.Invoke(skill), 0f, 100f));
			return true;
		}

		public static void SetSkill(string name, float value)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			string text = name.Replace(" ", string.Empty);
			if (text.Equals("Fists", StringComparison.OrdinalIgnoreCase))
			{
				text = "Unarmed";
			}
			foreach (SkillType value2 in Enum.GetValues(typeof(SkillType)))
			{
				if (((object)value2/*cast due to .constrained prefix*/).ToString().Equals(text, StringComparison.OrdinalIgnoreCase))
				{
					SetSkill(value2, value);
					break;
				}
			}
		}

		public static void LogPlaceholder(string actionName)
		{
			Plugin.Instance.Log.LogInfo((object)(actionName + " clicked."));
		}

		private static bool TryGetOnlinePlayer(string playerName, out PlayerInfo playerInfo)
		{
			//IL_0001: 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_0037: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			playerInfo = default(PlayerInfo);
			if ((Object)(object)ZNet.instance == (Object)null || string.IsNullOrWhiteSpace(playerName))
			{
				return false;
			}
			foreach (PlayerInfo player in ZNet.instance.GetPlayerList())
			{
				if (player.m_name.Equals(playerName, StringComparison.OrdinalIgnoreCase))
				{
					playerInfo = player;
					return true;
				}
			}
			return false;
		}

		private static Player? GetLoadedPlayerByName(string playerName)
		{
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (allPlayer.GetPlayerName().Equals(playerName, StringComparison.OrdinalIgnoreCase))
				{
					return allPlayer;
				}
			}
			return null;
		}

		public static void SetSkill(SkillType skillType, float value)
		{
			//IL_0017: 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_0020: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (!AdminNetworkAccess.Allowed)
			{
				return;
			}
			Skills localSkills = GetLocalSkills();
			if ((Object)(object)localSkills == (Object)null || (int)skillType == 0 || (int)skillType == 999)
			{
				return;
			}
			Skill skill = GetSkill(localSkills, skillType);
			if (skill != null)
			{
				SkillLevelRef.Invoke(skill) = Mathf.Clamp(value, 0f, 100f);
				SkillAccumulatorRef.Invoke(skill) = 0f;
				if (UseSkillCapRef.Invoke(localSkills))
				{
					RebalanceSkillsMethod.Invoke(localSkills, new object[1] { skillType });
				}
			}
		}

		private static Skill? GetSkill(Skills skills, SkillType skillType)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			object? obj = GetSkillMethod.Invoke(skills, new object[1] { skillType });
			return (Skill?)((obj is Skill) ? obj : null);
		}

		private static Player? GetLocalPlayer()
		{
			return Player.m_localPlayer;
		}

		private static bool TryGetItemCategory(ItemType itemType, out AdminItemCategory category)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected I4, but got Unknown
			switch (itemType - 1)
			{
			case 8:
			case 22:
				category = AdminItemCategory.Ammo;
				return true;
			case 2:
			case 13:
			case 14:
			case 19:
			case 21:
				category = AdminItemCategory.Weapons;
				return true;
			case 3:
				category = AdminItemCategory.Bows;
				return true;
			case 5:
			case 6:
			case 10:
			case 11:
			case 16:
				category = AdminItemCategory.Armor;
				return true;
			case 4:
				category = AdminItemCategory.Shields;
				return true;
			case 18:
				category = AdminItemCategory.Tools;
				return true;
			case 1:
			case 20:
				category = AdminItemCategory.Food;
				return true;
			case 0:
				category = AdminItemCategory.Materials;
				return true;
			case 12:
				category = AdminItemCategory.Trophies;
				return true;
			case 17:
			case 23:
				category = AdminItemCategory.Accessories;
				return true;
			default:
				category = AdminItemCategory.Other;
				return true;
			}
		}

		private static Sprite? TryGetItemIcon(ItemData itemData)
		{
			Sprite[] icons = itemData.m_shared.m_icons;
			int variant = itemData.m_variant;
			if (icons == null || icons.Length == 0)
			{
				return null;
			}
			if (variant < 0 || variant >= icons.Length)
			{
				return icons[0];
			}
			return icons[variant];
		}

		private static void ShowCenterMessage(string message)
		{
			Player localPlayer = GetLocalPlayer();
			if ((Object)(object)localPlayer != (Object)null)
			{
				((Character)localPlayer).Message((MessageType)2, message, 0, (Sprite)null, false);
			}
			else
			{
				Plugin.Instance.Log.LogInfo((object)message);
			}
		}

		private static Skills? GetLocalSkills()
		{
			Player? localPlayer = GetLocalPlayer();
			if (localPlayer == null)
			{
				return null;
			}
			return ((Character)localPlayer).GetSkills();
		}

		private static void SetDebugFly(bool enabled)
		{
			Player localPlayer = GetLocalPlayer();
			if (!((Object)(object)localPlayer == (Object)null) && ((Character)localPlayer).IsDebugFlying() != enabled)
			{
				localPlayer.ToggleDebugFly();
			}
		}

		public static void OnDebugModeToggled(bool enabled)
		{
			if (enabled && !AdminNetworkAccess.Allowed)
			{
				return;
			}
			if (enabled)
			{
				if (!(bool)DevCommandsField.GetValue(null))
				{
					DevCommandsField.SetValue(null, true);
					ownedDevCommands = true;
				}
			}
			else if (ownedDevCommands)
			{
				DevCommandsField.SetValue(null, false);
				ownedDevCommands = false;
			}
			ownedDebugMode = enabled;
			Player.m_debugMode = enabled;
		}

		internal static void TrackNativeDebugFly(Player player, bool enabled)
		{
			if ((Object)(object)player == (Object)(object)Player.m_localPlayer && ownedDebugMode && AdminNetworkAccess.Allowed)
			{
				ownedFlyMode = enabled;
			}
		}

		internal static void TrackNativeDebugBuild(Player player, bool enabled)
		{
			if ((Object)(object)player == (Object)(object)Player.m_localPlayer && ownedDebugMode && AdminNetworkAccess.Allowed)
			{
				ownedNoBuildCost = enabled;
			}
		}

		public static void OnDisableDurabilityLossToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedDisableDurabilityLoss = enabled;
			}
		}

		internal static void ResetDurabilityLoss()
		{
			requestedDisableDurabilityLoss = false;
		}

		public static void OnDisableFoodDegradationToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedDisableFoodDegradation = enabled;
			}
		}

		internal static void ResetFoodDegradation()
		{
			requestedDisableFoodDegradation = false;
		}

		public static void OnForgeAlwaysSucceedToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedForgeAlwaysSucceed = enabled;
			}
		}

		internal static void ResetForgeAlwaysSucceed()
		{
			requestedForgeAlwaysSucceed = false;
		}

		public static void OnMoonGravityToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedMoonGravity = enabled;
			}
		}

		public static void OnSuperKnockbackToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedSuperKnockback = enabled;
			}
		}

		public static void OnBouncyModeToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedBouncyMode = enabled;
				AdminFun.ResetBounce();
			}
		}

		public static void OnPartyHitsToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedPartyHits = enabled;
				if (!enabled)
				{
					AdminPartyHits.Clear();
				}
			}
		}

		internal static void ResetFun()
		{
			requestedMoonGravity = (requestedSuperKnockback = (requestedBouncyMode = (requestedPartyHits = false)));
			AdminFun.Reset();
			AdminPartyHits.Clear();
		}

		internal static List<AdminCheatCommand> CreateCheatCommands()
		{
			List<AdminCheatCommand> list = new List<AdminCheatCommand>
			{
				new AdminCheatCommand("GodMode", "God Mode", "Cheats", () => (Object)(object)Player.m_localPlayer != (Object)null && ((Character)Player.m_localPlayer).InGodMode(), OnGodModeToggled),
				new AdminCheatCommand("DebugMode", "Debug Mode", "Cheats", () => Player.m_debugMode, OnDebugModeToggled),
				new AdminCheatCommand("UnlimitedStamina", "Unlimited Stamina", "Cheats", () => UnlimitedStamina, OnUnlimitedStaminaToggled),
				new AdminCheatCommand("UnlimitedEitr", "Unlimited Eitr", "Cheats", () => UnlimitedEitr, OnUnlimitedEitrToggled),
				new AdminCheatCommand("FlyMode", "Fly Mode", "Cheats", () => (Object)(object)Player.m_localPlayer != (Object)null && Player.m_localPlayer.InDebugFlyMode(), OnFlyModeToggled),
				new AdminCheatCommand("InfiniteJumps", "Infinite Jumps", "Cheats", () => InfiniteJumps, OnInfiniteJumpsToggled),
				new AdminCheatCommand("NoClipMode", "NoClip Mode", "Cheats", () => ownedNoClipMode, OnNoClipModeToggled),
				new AdminCheatCommand("FreeCamMode", "FreeCam Mode", "Cheats", () => GameCamera.InFreeFly(), OnFreeCamModeToggled),
				new AdminCheatCommand("GhostMode", "Ghost Mode", "Cheats", () => (Object)(object)Player.m_localPlayer != (Object)null && ((Character)Player.m_localPlayer).InGhostMode(), OnGhostModeToggled),
				new AdminCheatCommand("NoCarryLimit", "No Carry Limit", "Cheats", () => NoCarryLimit, OnNoCarryLimitToggled),
				new AdminCheatCommand("NoBuildCost", "No Build Cost", "Cheats", () => ownedNoBuildCost, OnNoBuildCostToggled),
				new AdminCheatCommand("BuildEverywhere", "Build Everywhere", "Cheats", () => BuildEverywhere, OnBuildEverywhereToggled),
				new AdminCheatCommand("NoStructuralDamage", "No Structural Damage", "Cheats", () => NoStructuralDamage, OnNoStructuralDamageToggled),
				new AdminCheatCommand("MapTeleport", "Map Teleport", "Cheats", () => MapTeleport, OnMapTeleportToggled),
				new AdminCheatCommand("UnrestrictedPortals", "Unrestricted Portals", "Cheats", () => UnrestrictedPortals, OnUnrestrictedPortalsToggled),
				new AdminCheatCommand("ForgeAlwaysSucceed", "Forge: Always Succeed", "Cheats", () => ForgeAlwaysSucceed, OnForgeAlwaysSucceedToggled),
				new AdminCheatCommand("InstantCrafting", "Instant Crafting", "Cheats", () => InstantCrafting, OnInstantCraftingToggled),
				new AdminCheatCommand("DisableFoodDegradation", "Disable Food Degradation", "Cheats", () => DisableFoodDegradation, OnDisableFoodDegradationToggled),
				new AdminCheatCommand("DisableDurabilityLoss", "Disable Durability Loss", "Cheats", () => DisableDurabilityLoss, OnDisableDurabilityLossToggled),
				new AdminCheatCommand("DisableItemLoss", "Disable Item Loss", "Death protection", () => DisableItemLoss, OnDisableItemLossToggled),
				new AdminCheatCommand("DisableFoodLoss", "Disable Food Loss", "Death protection", () => DisableFoodLoss, OnDisableFoodLossToggled),
				new AdminCheatCommand("DisableStatusLoss", "Disable Status Loss", "Death protection", () => DisableStatusLoss, OnDisableStatusLossToggled),
				new AdminCheatCommand("DisableSkillLoss", "Disable Skill Loss", "Death protection", () => DisableSkillLoss, OnDisableSkillLossToggled),
				new AdminCheatCommand("MoonGravity", "Moon Gravity", "Fun", () => MoonGravity, OnMoonGravityToggled),
				new AdminCheatCommand("SuperKnockback", "Super Knockback", "Fun", () => SuperKnockback, OnSuperKnockbackToggled),
				new AdminCheatCommand("BouncyMode", "Bouncy Mode", "Fun", () => BouncyMode, OnBouncyModeToggled),
				new AdminCheatCommand("PartyHits", "Party Hits", "Fun", () => PartyHits, OnPartyHitsToggled),
				new AdminCheatCommand("WindInBack", "Wind in back", "Ship", () => EnableWindInBack, OnEnableWindInBackToggled),
				new AdminCheatCommand("ShipSpeed", "Speed hack", "Ship", () => EnableShipSpeedHack, OnEnableShipSpeedHackToggled),
				new AdminCheatCommand("QuickHeal", "Quick Heal", "Quick actions", OnQuickHealClicked),
				new AdminCheatCommand("Rested", "Give 1H Rested", "Quick actions", OnGiveOneHourRestedClicked),
				new AdminCheatCommand("ExploreMap", "Explore Map", "Quick actions", OnExploreMapClicked),
				new AdminCheatCommand("RevealPoi", "Reveal / Hide POI", "Quick actions", OnRevealPoiClicked),
				new AdminCheatCommand("ShowWorldSeed", "Show World Seed", "Quick actions", OnShowWorldSeedClicked),
				new AdminCheatCommand("ResetMap", "Reset Map", "Quick actions", OnResetMapClicked),
				new AdminCheatCommand("BossPowerEikthyr", "Eikthyr", "Boss powers", delegate
				{
					OnBossPowerClicked("GP_Eikthyr");
				}),
				new AdminCheatCommand("BossPowerElder", "The Elder", "Boss powers", delegate
				{
					OnBossPowerClicked("GP_TheElder");
				}),
				new AdminCheatCommand("BossPowerBonemass", "Bonemass", "Boss powers", delegate
				{
					OnBossPowerClicked("GP_Bonemass");
				}),
				new AdminCheatCommand("BossPowerModer", "Moder", "Boss powers", delegate
				{
					OnBossPowerClicked("GP_Moder");
				}),
				new AdminCheatCommand("BossPowerYagluth", "Yagluth", "Boss powers", delegate
				{
					OnBossPowerClicked("GP_Yagluth");
				}),
				new AdminCheatCommand("BossPowerQueen", "The Queen", "Boss powers", delegate
				{
					OnBossPowerClicked("GP_Queen");
				}),
				new AdminCheatCommand("BossPowerFader", "Fader", "Boss powers", delegate
				{
					OnBossPowerClicked("GP_Fader");
				}),
				new AdminCheatCommand("WardOverride", "Ward override", "Admin functions", delegate
				{
					AdminWardOverride.Set(!AdminWardOverride.Active);
				}),
				new AdminCheatCommand("RemoveDrops", "Remove Drops", "Tools", AdminToolRpcs.RequestRemoveDrops),
				new AdminCheatCommand("SpawnProtection", "Show spawn protection", "Tools", delegate
				{
					AdminSpawnOverlay.Set(!AdminSpawnOverlay.Active);
				})
			};
			if (AdminInvisibilityModule.Loaded)
			{
				list.Add(new AdminCheatCommand("AdminInvisibility", "Invisible to players", "Admin functions", delegate
				{
					AdminInvisibilityModule.Set(!AdminInvisibilityModule.Active);
				}));
			}
			return list;
		}

		public static List<AdminItemInfo> GetSpawnableItems()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			List<AdminItemInfo> list = new List<AdminItemInfo>();
			if ((Object)(object)ObjectDB.instance == (Object)null)
			{
				return list;
			}
			IEnumerable<GameObject> enumerable = ObjectDB.instance.m_items;
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				enumerable = enumerable.Concat(from name in ZNetScene.instance.GetPrefabNames()
					select ZNetScene.instance.GetPrefab(name));
			}
			foreach (GameObject item in enumerable.Distinct())
			{
				if (!((Object)(object)item == (Object)null))
				{
					ItemDrop component = item.GetComponent<ItemDrop>();
					if (!((Object)(object)component == (Object)null) && TryGetItemCategory(component.m_itemData.m_shared.m_itemType, out var category))
					{
						string displayName = AdminCatalog.DisplayName(component.m_itemData.m_shared.m_name, ((Object)item).name);
						Sprite icon = TryGetItemIcon(component.m_itemData);
						list.Add(new AdminItemInfo(((Object)item).name, displayName, category, icon, component.m_itemData.m_shared.m_maxQuality));
					}
				}
			}
			return (from item in list
				group item by item.PrefabName into @group
				select @group.First() into item
				orderby item.DisplayName
				select item).ToList();
		}

		public static void SpawnItemInWorld(AdminItemInfo? item, int amount, int quality = 1)
		{
			//IL_00d2: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			if (!AdminNetworkAccess.Allowed)
			{
				return;
			}
			Player localPlayer = GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null || item == null)
			{
				ShowCenterMessage("Select an item first.");
				return;
			}
			if ((Object)(object)ObjectDB.instance == (Object)null)
			{
				ShowCenterMessage("Item database is not ready yet.");
				return;
			}
			object obj = ObjectDB.instance.GetItemPrefab(item.PrefabName);
			if (obj == null)
			{
				ZNetScene instance = ZNetScene.instance;
				obj = ((instance != null) ? instance.GetPrefab(item.PrefabName) : null);
			}
			GameObject val = (GameObject)obj;
			ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				ShowCenterMessage("Item prefab was not found.");
				return;
			}
			int num = Mathf.Clamp(amount, 1, 100);
			int num2 = num;
			int num3 = ClampItemQuality(val2.m_itemData, quality);
			int num4 = Mathf.Max(1, val2.m_itemData.m_shared.m_maxStackSize);
			Vector3 val3 = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 2f + Vector3.up;
			while (num2 > 0)
			{
				int num5 = Mathf.Min(num2, num4);
				Vector3 val4 = val3 + Random.insideUnitSphere * 0.35f;
				val4.y = val3.y;
				ItemDrop component = Object.Instantiate<GameObject>(val, val4, Quaternion.identity).GetComponent<ItemDrop>();
				if ((Object)(object)component != (Object)null)
				{
					component.SetQuality(num3);
					component.SetStack(num5);
					RepairItem(component.m_itemData);
					component.Save();
				}
				num2 -= num5;
			}
			ShowCenterMessage($"Spawned {num} x {item.DisplayName} (quality {num3}).");
		}

		public static void SpawnItemInInventory(AdminItemInfo? item, int amount, int quality = 1)
		{
			if (!AdminNetworkAccess.Allowed)
			{
				return;
			}
			Player localPlayer = GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null || item == null)
			{
				ShowCenterMessage("Select an item first.");
				return;
			}
			if ((Object)(object)ObjectDB.instance == (Object)null)
			{
				ShowCenterMessage("Item database is not ready yet.");
				return;
			}
			object obj = ObjectDB.instance.GetItemPrefab(item.PrefabName);
			if (obj == null)
			{
				ZNetScene instance = ZNetScene.instance;
				obj = ((instance != null) ? instance.GetPrefab(item.PrefabName) : null);
			}
			GameObject val = (GameObject)obj;
			ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				ShowCenterMessage("Item prefab was not found.");
				return;
			}
			int num = Mathf.Clamp(amount, 1, 100);
			ItemData val3 = val2.m_itemData.Clone();
			val3.m_dropPrefab = val;
			val3.m_quality = ClampItemQuality(val3, quality);
			val3.m_worldLevel = (byte)Game.m_worldLevel;
			RepairItem(val3);
			Inventory inventory = ((Humanoid)localPlayer).GetInventory();
			if (!CanFitItemQuality(inventory, val3, num))
			{
				ShowCenterMessage("Not enough inventory space.");
				return;
			}
			int num2 = num;
			while (num2 > 0)
			{
				ItemData val4 = val3.Clone();
				val4.m_stack = Mathf.Min(num2, Mathf.Max(1, val4.m_shared.m_maxStackSize));
				int stack = val4.m_stack;
				if (!inventory.AddItem(val4))
				{
					ShowCenterMessage("Could not add all items to inventory.");
					return;
				}
				num2 -= stack;
			}
			ShowCenterMessage($"Added {num} x {item.DisplayName} (quality {val3.m_quality}).");
		}

		private static int ClampItemQuality(ItemData item, int quality)
		{
			return Mathf.Clamp(quality, 1, Mathf.Max(1, item.m_shared.m_maxQuality));
		}

		private static bool CanFitItemQuality(Inventory inventory, ItemData item, int amount)
		{
			if (!inventory.CanAddItem(item, amount))
			{
				return false;
			}
			long num = (long)Mathf.Max(0, inventory.GetEmptySlots()) * (long)Mathf.Max(1, item.m_shared.m_maxStackSize);
			if (item.m_shared.m_maxStackSize > 1)
			{
				foreach (ItemData allItem in inventory.GetAllItems())
				{
					if (allItem.m_shared.m_name == item.m_shared.m_name && allItem.m_quality == item.m_quality && allItem.m_worldLevel == item.m_worldLevel)
					{
						num += Mathf.Max(0, allItem.m_shared.m_maxStackSize - allItem.m_stack);
					}
				}
			}
			return num >= amount;
		}

		private static void RepairItem(ItemData itemData)
		{
			if (itemData.m_shared.m_useDurability)
			{
				itemData.m_durability = itemData.GetMaxDurability();
			}
		}

		public static void OnInfiniteJumpsToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedInfiniteJumps = enabled;
			}
		}

		internal static void ResetInfiniteJumps()
		{
			requestedInfiniteJumps = false;
		}

		public static void OnMapTeleportToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedMapTeleport = enabled;
				AdminMapTeleport.ResetClick();
			}
		}

		private static void ResetMapTeleport()
		{
			requestedMapTeleport = false;
			AdminMapTeleport.ResetClick();
		}

		public static void OnUnrestrictedPortalsToggled(bool enabled)
		{
			if (!enabled || AdminNetworkAccess.Allowed)
			{
				requestedUnrestrictedPortals = enabled;
			}
		}

		internal static void ResetUnrestrictedPortals()
		{
			requestedUnrestrictedPortals = false;
		}
	}
	internal static class AdminCarryWeight
	{
		private static float? maximum;

		private static long character;

		private static int generation;

		internal static float? GetCustom(Player? player)
		{
			if (!AdminNetworkAccess.Allowed || !((Object)(object)player != (Object)null) || !((Object)(object)player == (Object)(object)Player.m_localPlayer) || !((Character)player).IsOwner() || character == 0L || player.GetPlayerID() != character || generation != AdminNetworkAccess.Generation)
			{
				return null;
			}
			return maximum;
		}

		internal static bool TrySet(Player? player, string text, out string message)
		{
			if (!AdminInventory.Ready(player) || player.GetPlayerID() == 0L)
			{
				message = "Carry weight requires a ready local character and permission to use VAT.";
				return false;
			}
			if (!float.TryParse((text ?? "").Trim().Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var result) || float.IsNaN(result) || float.IsInfinity(result) || result < 1f || result > 99999f)
			{
				message = "Enter a weight from 1 to 99999, for example 450 or 450.5.";
				return false;
			}
			maximum = result;
			character = player.GetPlayerID();
			generation = AdminNetworkAccess.Generation;
			message = "Custom carry limit applied. Use Save cheats to restore it next session.";
			return true;
		}

		internal static float Resolve(Player player, float normalLimit)
		{
			if (!AdminNetworkAccess.Allowed || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer || !((Character)player).IsOwner())
			{
				return normalLimit;
			}
			if (AdminActions.NoCarryLimit)
			{
				return 99999f;
			}
			return GetCustom(player) ?? normalLimit;
		}

		internal static void Reset()
		{
			maximum = null;
			character = 0L;
			generation = -1;
		}
	}
	internal static class AdminCatalog
	{
		public static string DisplayName(string token, string fallback)
		{
			string text = ((Localization.instance != null) ? Localization.instance.Localize(token) : token);
			if (!string.IsNullOrWhiteSpace(text) && !text.StartsWith("$"))
			{
				return text;
			}
			return fallback;
		}

		public static List<SkillType> GetSkills()
		{
			Player localPlayer = Player.m_localPlayer;
			Skills val = ((localPlayer != null) ? ((Character)localPlayer).GetSkills() : null);
			return (((Object)(object)val != (Object)null) ? val.m_skills.Select((SkillDef def) => def.m_skill) : Enum.GetValues(typeof(SkillType)).Cast<SkillType>()).Where((SkillType type) => (int)type != 0 && (int)type != 999).Distinct().ToList();
		}

		public unsafe static string SkillName(SkillType type)
		{
			return DisplayName("$skill_" + ((object)(*(SkillType*)(&type))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant(), Regex.Replace(((object)(*(SkillType*)(&type))/*cast due to .constrained prefix*/).ToString(), "([a-z])([A-Z])", "$1 $2"));
		}

		public static List<AdminCreatureInfo> GetCreatures()
		{
			//IL_00bc: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			ZNetScene scene = ZNetScene.instance;
			if ((Object)(object)scene == (Object)null)
			{
				return new List<AdminCreatureInfo>();
			}
			Dictionary<string, Biome> dictionary = new Dictionary<string, Biome>(AdminCreatureBiomes.Memberships);
			IEnumerable<SpawnSystem> enumerable = Object.FindObjectsByType<SpawnSystem>((FindObjectsSortMode)0);
			if ((Object)(object)ZoneSystem.instance != (Object)null && (Object)(object)ZoneSystem.instance.m_zoneCtrlPrefab != (Object)null)
			{
				enumerable = enumerable.Concat(ZoneSystem.instance.m_zoneCtrlPrefab.GetComponents<SpawnSystem>());
			}
			foreach (SpawnSystemList item in enumerable.SelectMany((SpawnSystem system) => system.m_spawnLists).Distinct())
			{
				foreach (SpawnData spawner in item.m_spawners)
				{
					AddSpawn(spawner, spawner.m_biome, dictionary);
				}
			}
			foreach (AltBiome item2 in AltBiomeList.m_altBiomes.Where((AltBiome alt) => alt.m_enabled))
			{
				foreach (SpawnData item3 in item2.m_spawn)
				{
					AddSpawn(item3, (Biome)(item3.m_biome & item2.m_biome), dictionary);
				}
			}
			List<AdminCreatureInfo> list = new List<AdminCreatureInfo>();
			foreach (GameObject item4 in (from name in scene.GetPrefabNames()
				select scene.GetPrefab(name)).Distinct())
			{
				if ((Object)(object)item4 == (Object)null || (Object)(object)item4.GetComponent<Player>() != (Object)null)
				{
					continue;
				}
				Character component = item4.GetComponent<Character>();
				Fish component2 = item4.GetComponent<Fish>();
				if ((Object)(object)component == (Object)null && (Object)(object)component2 == (Object)null && (Object)(object)item4.GetComponent<RandomFlyingBird>() == (Object)null && (Object)(object)item4.GetComponent<Leviathan>() == (Object)null)
				{
					continue;
				}
				string displayName = DisplayName(((Object)(object)component != (Object)null) ? component.m_name : (((Object)(object)component2 != (Object)null) ? component2.m_name : ""), ((Object)item4).name);
				bool canSpawnTamed = (Object)(object)item4.GetComponent<Tameable>() != (Object)null;
				dictionary.TryGetValue(((Object)item4).name, out var value);
				bool flag = false;
				foreach (AdminCreatureBiome value2 in Enum.GetValues(typeof(AdminCreatureBiome)))
				{
					if (Enum.TryParse<Biome>(value2.ToString(), ignoreCase: true, out Biome result) && value2 != AdminCreatureBiome.All && (value & result) != 0)
					{
						list.Add(new AdminCreatureInfo(((Object)item4).name, displayName, value2, canSpawnTamed));
						flag = true;
					}
				}
				if (!flag)
				{
					list.Add(new AdminCreatureInfo(((Object)item4).name, displayName, AdminCreatureBiome.Other, canSpawnTamed));
				}
			}
			return (from creature in list
				orderby creature.DisplayName, creature.PrefabName
				select creature).ToList();
		}

		private static void AddSpawn(SpawnData spawn, Biome mask, Dictionary<string, Biome> memberships)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (spawn.m_enabled && !spawn.m_devDisabled && !((Object)(object)spawn.m_prefab == (Object)null) && (int)mask != 895 && (int)mask != -1)
			{
				AddSpawnPrefab(spawn.m_prefab, mask, memberships, new HashSet<GameObject>());
			}
		}

		private static void AddSpawnPrefab(GameObject prefab, Biome mask, Dictionary<string, Biome> memberships, HashSet<GameObject> visited)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefab == (Object)null || !visited.Add(prefab))
			{
				return;
			}
			memberships.TryGetValue(((Object)prefab).name, out var value);
			memberships[((Object)prefab).name] = (Biome)(value | mask);
			CreatureSpawner[] componentsInChildren = prefab.GetComponentsInChildren<CreatureSpawner>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				AddSpawnPrefab(componentsInChildren[i].m_creaturePrefab, mask, memberships, visited);
			}
			SpawnArea[] componentsInChildren2 = prefab.GetComponentsInChildren<SpawnArea>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				foreach (SpawnData item in componentsInChildren2[i].m_prefabs.Where((SpawnData entry) => entry.m_weight > 0f))
				{
					AddSpawnPrefab(item.m_prefab, mask, memberships, visited);
				}
			}
		}

		public static List<AdminItemInfo> FilterItems(IEnumerable<AdminItemInfo> items, AdminItemCategory category, string query)
		{
			string search = query.Trim();
			return (from item in items
				where (search.Length != 0) ? Matches(item.DisplayName, item.PrefabName, search) : (item.Category == category)
				group item by item.PrefabName into @group
				select @group.First()).ToList();
		}

		public static List<AdminCreatureInfo> FilterCreatures(IEnumerable<AdminCreatureInfo> creatures, AdminCreatureBiome biome, string query)
		{
			string search = query.Trim();
			return (from creature in creatures.Where(delegate(AdminCreatureInfo creature)
				{
					if (search.Length != 0)
					{
						return Matches(creature.DisplayName, creature.PrefabName, search);
					}
					return biome == AdminCreatureBiome.All || creature.Biome == biome;
				})
				group creature by creature.PrefabName into @group
				select @group.First()).ToList();
		}

		private static bool Matches(string displayName, string prefabName, string search)
		{
			if (displayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) < 0)
			{
				return prefabName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0;
			}
			return true;
		}
	}
	internal sealed class AdminCheatCommand
	{
		private readonly Func<bool>? read;

		private readonly Action<bool>? write;

		private readonly Action? action;

		internal string Id { get; }

		internal string Name { get; }

		internal string Group { get; }

		internal bool IsToggle => read != null;

		internal bool Enabled
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return read?.Invoke() ?? false;
				}
				return false;
			}
		}

		internal AdminCheatCommand(string id, string name, string group, Func<bool> read, Action<bool> write)
		{
			Id = id;
			Name = name;
			Group = group;
			this.read = read;
			this.write = write;
		}

		internal AdminCheatCommand(string id, string name, string group, Action action)
		{
			Id = id;
			Name = name;
			Group = group;
			this.action = action;
		}

		internal void Execute()
		{
			if (AdminNetworkAccess.Allowed)
			{
				if (IsToggle)
				{
					write(!Enabled);
					AdminNetworkAccess.ShowMessage(Name + ": " + (Enabled ? "On" : "Off"));
				}
				else
				{
					action();
				}
			}
		}

		internal bool ApplySavedState(bool enabled)
		{
			if (!IsToggle || !AdminNetworkAccess.Allowed)
			{
				return false;
			}
			write(enabled);
			return true;
		}
	}
	internal static class AdminCreatureBiomes
	{
		internal static readonly Dictionary<string, Biome> Memberships = new Dictionary<string, Biome>
		{
			["Abomination"] = (Biome)2,
			["AshCrow"] = (Biome)32,
			["Asksvin"] = (Biome)32,
			["Asksvin_hatchling"] = (Biome)32,
			["Barka"] = (Biome)64,
			["Bat"] = (Biome)4,
			["Bjorn"] = (Biome)8,
			["Bjorn_sleeping"] = (Biome)8,
			["Blob"] = (Biome)2,
			["BlobElite"] = (Biome)2,
			["BlobLava"] = (Biome)32,
			["BlobMork"] = (Biome)64,
			["BlobTar"] = (Biome)16,
			["Boar"] = (Biome)1,
			["Boar_piggy"] = (Biome)1,
			["BogWitchKvastur"] = (Biome)2,
			["Bonemass"] = (Biome)2,
			["BonemawSerpent"] = (Biome)32,
			["Charred_Archer"] = (Biome)63,
			["Charred_Mage"] = (Biome)32,
			["Charred_Melee"] = (Biome)63,
			["Charred_Melee_Dyrnwyn"] = (Biome)32,
			["Charred_Twitcher"] = (Biome)32,
			["Crow"] = (Biome)10,
			["Deathsquito"] = (Biome)16,
			["Deer"] = (Biome)9,
			["Dragon"] = (Biome)4,
			["Draugr"] = (Biome)31,
			["Draugr_Elite"] = (Biome)3,
			["Draugr_Ranged"] = (Biome)3,
			["Dverger"] = (Biome)512,
			["DvergerAshlands"] = (Biome)32,
			["DvergerDeepNorth"] = (Biome)64,
			["DvergerMage"] = (Biome)512,
			["Eikthyr"] = (Biome)1,
			["Elaking"] = (Biome)64,
			["ElakingLantern"] = (Biome)64,
			["ElakingMole"] = (Biome)64,
			["Fader"] = (Biome)32,
			["FallenValkyrie"] = (Biome)32,
			["FallenWarrior"] = (Biome)64,
			["Fenring"] = (Biome)4,
			["Fenring_Cultist"] = (Biome)4,
			["Fenring_Cultist_Hildir"] = (Biome)4,
			["Fish1"] = (Biome)25,
			["Fish10"] = (Biome)64,
			["Fish11"] = (Biome)32,
			["Fish12"] = (Biome)768,
			["Fish2"] = (Biome)25,
			["Fish3"] = (Biome)256,
			["Fish4_cave"] = (Biome)4,
			["Fish5"] = (Biome)8,
			["Fish6"] = (Biome)2,
			["Fish7"] = (Biome)16,
			["Fish8"] = (Biome)256,
			["Fish9"] = (Biome)512,
			["FrozenKing"] = (Biome)64,
			["Ghost"] = (Biome)8,
			["Gjall"] = (Biome)512,
			["Goblin"] = (Biome)29,
			["GoblinArcher"] = (Biome)16,
			["GoblinBrute"] = (Biome)16,
			["GoblinBruteBros"] = (Biome)16,
			["GoblinDeepNorth"] = (Biome)64,
			["GoblinKing"] = (Biome)16,
			["GoblinShaman"] = (Biome)16,
			["Greydwarf"] = (Biome)9,
			["Greydwarf_Elite"] = (Biome)9,
			["Greydwarf_Frozen"] = (Biome)64,
			["Greydwarf_Shaman"] = (Biome)9,
			["Greydwarf_Shaman_Frozen"] = (Biome)64,
			["Greyling"] = (Biome)1,
			["Hare"] = (Biome)512,
			["Hatchling"] = (Biome)4,
			["JotunWarrior"] = (Biome)64,
			["JotunWarriorDualWield"] = (Biome)64,
			["JotunWitch"] = (Biome)64,
			["Leech"] = (Biome)2,
			["Leviathan"] = (Biome)256,
			["LeviathanLava"] = (Biome)32,
			["Lox"] = (Biome)16,
			["Lox_Calf"] = (Biome)16,
			["Moose"] = (Biome)64,
			["Moose_calf"] = (Biome)64,
			["Morgen"] = (Biome)32,
			["Morgen_NonSleeping"] = (Biome)32,
			["Neck"] = (Biome)1,
			["Seagal"] = (Biome)281,
			["Seal"] = (Biome)64,
			["Seal_Pup"] = (Biome)64,
			["Seeker"] = (Biome)543,
			["SeekerBrood"] = (Biome)512,
			["SeekerBrute"] = (Biome)512,
			["SeekerQueen"] = (Biome)512,
			["Serpent"] = (Biome)256,
			["ShadowPerson"] = (Biome)64,
			["Skeleton"] = (Biome)31,
			["Skeleton_DeepNorth"] = (Biome)64,
			["Skeleton_Hildir"] = (Biome)8,
			["Skeleton_Meadows_noarcher"] = (Biome)9,
			["Skeleton_Mountains"] = (Biome)4,
			["Skeleton_Poison"] = (Biome)8,
			["Skeleton_Swamps"] = (Biome)2,
			["StoneGolem"] = (Biome)4,
			["Surtling"] = (Biome)2,
			["Tick"] = (Biome)512,
			["Troll"] = (Biome)8,
			["TrollFrost"] = (Biome)64,
			["Ulv"] = (Biome)4,
			["Unbjorn"] = (Biome)16,
			["Volture"] = (Biome)32,
			["Wolf"] = (Biome)4,
			["Wolf_cub"] = (Biome)4,
			["Wraith"] = (Biome)2,
			["Writhan"] = (Biome)2,
			["gd_king"] = (Biome)8
		};
	}
	internal enum AdminCreatureBiome
	{
		Meadows,
		BlackForest,
		Ocean,
		Swamp,
		Mountain,
		Plains,
		Mistlands,
		Ashlands,
		DeepNorth,
		All,
		Other
	}
	internal sealed class AdminCreatureInfo
	{
		public string PrefabName { get; }

		public string DisplayName { get; }

		public AdminCreatureBiome Biome { get; }

		public bool CanSpawnTamed { get; }

		public AdminCreatureInfo(string prefabName, string displayName, AdminCreatureBiome biome, bool canSpawnTamed)
		{
			PrefabName = prefabName;
			DisplayName = displayName;
			Biome = biome;
			CanSpawnTamed = canSpawnTamed;
		}
	}
	internal static class AdminEnvironment
	{
		private static Player? player;

		private static EnvMan? environment;

		private static bool timeActive;

		private static bool timeFrozen;

		private static double timeStart;

		private static float rawTime;

		private static string weather = string.Empty;

		private static bool weatherFrozen;

		private static double weatherUntil;

		internal static bool LocalTimeActive
		{
			get
			{
				if (Current)
				{
					return timeActive;
				}
				return false;
			}
		}

		internal static bool LocalWeatherActive
		{
			get
			{
				if (Current && weather.Length != 0)
				{
					if (!weatherFrozen)
					{
						return (double)Time.unscaledTime < weatherUntil;
					}
					return true;
				}
				return false;
			}
		}

		private static bool Current
		{
			get
			{
				if (AdminNetworkAccess.Allowed && (Object)(object)player != (Object)null && (Object)(object)player == (Object)(object)Player.m_localPlayer && (Object)(object)environment != (Object)null)
				{
					return (Object)(object)environment == (Object)(object)EnvMan.instance;
				}
				return false;
			}
		}

		internal static string[] WeatherNames
		{
			get
			{
				if (!((Object)(object)EnvMan.instance == (Object)null))
				{
					return (from e in EnvMan.instance.m_environments
						where e != null && !string.IsNullOrEmpty(e.m_name)
						select e.m_name).Distinct().OrderBy<string, string>((string n) => n, StringComparer.OrdinalIgnoreCase).ToArray();
				}
				return Array.Empty<string>();
			}
		}

		internal static string TimeStatus
		{
			get
			{
				if (!LocalTimeActive)
				{
					return "Following world time.";
				}
				if (!timeFrozen)
				{
					return "Local time is running from your chosen time.";
				}
				return "Local time is frozen.";
			}
		}

		internal static string WeatherStatus
		{
			get
			{
				if (!LocalWeatherActive)
				{
					return "Following natural weather.";
				}
				return "Local weather: " + weather + (weatherFrozen ? " (frozen)." : " (one weather period).");
			}
		}

		internal static float LocalDayFraction => ToDisplay(Mathf.Repeat(rawTime + (timeFrozen ? 0f : ((float)(((double)Time.unscaledTime - timeStart) / (double)Math.Max(1L, EnvMan.instance.m_dayLengthSec)))), 1f));

		internal static string EffectiveWeather
		{
			get
			{
				if (!LocalWeatherActive)
				{
					return string.Empty;
				}
				return weather;
			}
		}

		internal static bool ValidWeather(string name)
		{
			if (name != null && name.Length <= 100 && (Object)(object)EnvMan.instance != (Object)null)
			{
				return EnvMan.instance.m_environments.Any((EnvSetup e) => e != null && e.m_name == name);
			}
			return false;
		}

		internal static bool ValidMinute(int minute)
		{
			if (minute >= 0)
			{
				return minute < 1440;
			}
			return false;
		}

		internal static string FormatMinute(int minute)
		{
			return $"{minute / 60:00}:{minute % 60:00}";
		}

		internal static float ToRaw(float displayed)
		{
			if (!(displayed < 0.25f))
			{
				if (!(displayed <= 0.75f))
				{
					return 0.85f + (displayed - 0.75f) * 0.6f;
				}
				return 0.15f + (displayed - 0.25f) * 1.4f;
			}
			return displayed * 0.6f;
		}

		internal static float ToDisplay(float raw)
		{
			if (!(raw < 0.15f))
			{
				if (!(raw <= 0.85f))
				{
					return 0.75f + (raw - 0.85f) / 0.6f;
				}
				return 0.25f + (raw - 0.15f) / 1.4f;
			}
			return raw / 0.6f;
		}

		private static bool BeginLocal()
		{
			if (!AdminNetworkAccess.Allowed || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)EnvMan.instance == (Object)null)
			{
				return false;
			}
			if ((Object)(object)player != (Object)(object)Player.m_localPlayer || (Object)(object)environment != (Object)(object)EnvMan.instance)
			{
				ResetLocal();
			}
			player = Player.m_localPlayer;
			environment = EnvMan.instance;
			return true;
		}

		internal static void SetLocalTime(int minute, bool freeze)
		{
			if (ValidMinute(minute) && BeginLocal())
			{
				timeActive = true;
				timeFrozen = freeze;
				timeStart = Time.unscaledTime;
				rawTime = ToRaw((float)minute / 1440f);
				AdminNetworkAccess.ShowMessage("Local time set to " + FormatMinute(minute) + (freeze ? " (frozen)." : "."));
			}
		}

		internal static void SetLocalWeather(string name, bool freeze)
		{
			if (ValidWeather(name) && BeginLocal())
			{
				weather = name;
				weatherFrozen = freeze;
				weatherUntil = Time.unscaledTime + (float)Math.Max(1L, environment.m_environmentDuration);
				AdminNetworkAccess.ShowMessage("Local weather: " + name + (freeze ? " (frozen)." : " for one weather period."));
			}
		}

		internal static void ResetTime()
		{
			timeActive = false;
		}

		internal static void ResetWeather()
		{
			weather = string.Empty;
		}

		internal static void ResetLocal()
		{
			ResetTime();
			ResetWeather();
			player = null;
			environment = null;
		}

		internal static void Update()
		{
			if (((Object)(object)player != (Object)null || (Object)(object)environment != (Object)null) && !Current)
			{
				ResetLocal();
			}
			if (weather.Length != 0 && !weatherFrozen && (double)Time.unscaledTime >= weatherUntil)
			{
				ResetWeather();
			}
		}
	}
	internal static class AdminEnvironmentNetwork
	{
		private sealed class Session
		{
			internal string Nonce = string.Empty;

			internal float Seen;

			internal float NextReply;

			internal float LastCommand = float.NegativeInfinity;

			internal int Sequence;

			internal bool Compatible;
		}

		private const string Hello = "VAT_Time_Hello_v1";

		private const string State = "VAT_Time_State_v1";

		private const string Command = "VAT_Time_Command_v1";

		private const int Version = 1;

		private const float Lease = 10f;

		private static readonly Dictionary<ZRpc, Session> Peers = new Dictionary<ZRpc, Session>();

		private static readonly MethodInfo SendTime = AccessTools.Method(typeof(ZNet), "SendNetTime", (Type[])null, (Type[])null);

		private static ZNet? network;

		private static ZRpc? server;

		private static ZRpc? freezeOwner;

		private static string nonce = string.Empty;

		private static string ownerNonce = string.Empty;

		private static int sequence;

		private static float nextHello;

		private static float receivedAt = float.NegativeInfinity;

		private static bool serverAdmin;

		private static bool frozen;

		private static bool freezeOnServer;

		private static bool Current
		{
			get
			{
				if ((Object)(object)network != (Object)null)
				{
					return (Object)(object)network == (Object)(object)ZNet.instance;
				}
				return false;
			}
		}

		private static bool Fresh
		{
			get
			{
				if (Current && server != null && server == network.GetServerRPC() && server.IsConnected() && Time.unscaledTime >= receivedAt)
				{
					return Time.unscaledTime - receivedAt <= 10f;
				}
				return false;
			}
		}

		private static bool Host
		{
			get
			{
				if (Current && network.IsServer() && !network.IsDedicated())
				{
					return AdminNetworkAccess.ServerTools;
				}
				return false;
			}
		}

		internal static bool CanChange
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					if (!Host)
					{
						if (Fresh && serverAdmin)
						{
							return AdminNetworkAccess.ServerTools;
						}
						return false;
					}
					return true;
				}
				return false;
			}
		}

		internal static bool TimeFrozen
		{
			get
			{
				if (Current)
				{
					if (!network.IsServer())
					{
						if (Fresh)
						{
							return frozen;
						}
						return false;
					}
					if (freezeOnServer)
					{
						return OwnerValid();
					}
					return false;
				}
				return false;
			}
		}

		internal static string Status
		{
			get
			{
				if (!CanChange)
				{
					return "Global controls require admin rights and VAT 0.4.4+ on the server.";
				}
				if (!TimeFrozen)
				{
					return "Global world time is running.";
				}
				return "Global world time is frozen.";
			}
		}

		internal static void Update()
		{
			ZRpc val = (((Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer()) ? ZNet.instance.GetServerRPC() : null);
			if ((Object)(object)network != (Object)(object)ZNet.instance || server != val)
			{
				Dispose();
				network = ZNet.instance;
				server = val;
				nonce = Guid.NewGuid().ToString("N");
				ZRpc? obj = server;
				if (obj != null)
				{
					obj.Register<int, string, ZPackage>("VAT_Time_State_v1", (Action<ZRpc, int, string, ZPackage>)ReceiveState);
				}
			}
			if (!Current)
			{
				return;
			}
			if (!network.IsServer())
			{
				if (server != null && server.IsConnected() && Time.unscaledTime >= nextHello)
				{
					nextHello = Time.unscaledTime + 3f;
					server.Invoke("VAT_Time_Hello_v1", new object[2] { 1, nonce });
				}
				return;
			}
			HashSet<ZRpc> currentPeers = new HashSet<ZRpc>(from p in network.GetPeers()
				where p.IsReady() && p.m_rpc.IsConnected()
				select p.m_rpc);
			ZRpc[] array = Peers.Keys.Where((ZRpc p) => !currentPeers.Contains(p)).ToArray();
			for (int num = 0; num < array.Length; num++)
			{
				Unregister(array[num]);
			}
			foreach (ZRpc item in currentPeers)
			{
				if (!Peers.TryGetValue(item, out Session value))
				{
					value = (Peers[item] = new Session());
					item.Register<int, string>("VAT_Time_Hello_v1", (Action<ZRpc, int, string>)ReceiveHello);
					item.Register<int, string, ZPackage>("VAT_Time_Command_v1", (Action<ZRpc, int, string, ZPackage>)ReceiveCommand);
				}
				if (value.Nonce.Length != 0 && Time.unscaledTime >= value.NextReply)
				{
					Reply(item, value);
				}
			}
			if (freezeOnServer && !OwnerValid())
			{
				ClearFreeze();
				Broadcast();
			}
		}

		private static bool PeerCurrent(ZRpc rpc)
		{
			if (Current && network.IsServer() && rpc.IsConnected())
			{
				return network.GetPeers().Any((ZNetPeer p) => p.m_rpc == rpc && p.IsReady());
			}
			return false;
		}

		private static bool SessionCurrent(ZRpc rpc, string token)
		{
			if (PeerCurrent(rpc) && Peers.TryGetValue(rpc, out Session value) && value.Compatible && value.Nonce == token && Time.unscaledTime >= value.Seen)
			{
				return Time.unscaledTime - value.Seen <= 10f;
			}
			return false;
		}

		private static bool OwnerValid()
		{
			if (freezeOwner != null)
			{
				if (SessionCurrent(freezeOwner, ownerNonce))
				{
					return ServerPolicyEndpoint.IsAdmin(freezeOwner);
				}
				return false;
			}
			return Host;
		}

		private static void ReceiveHello(ZRpc rpc, int version, string token)
		{
			if (PeerCurrent(rpc) && Peers.TryGetValue(rpc, out Session value) && token != null && token.Length == 32 && Guid.TryParseExact(token, "N", out var _) && (!(value.Nonce == token) || !(Time.unscaledTime - value.Seen < 0.5f)))
			{
				if (value.Nonce != token)
				{
					value.Sequence = 0;
				}
				value.Nonce = token;
				value.Compatible = version == 1;
				value.Seen = Time.unscaledTime;
				Reply(rpc, value);
			}
		}

		private static void Reply(ZRpc rpc, Session s)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			s.NextReply = Time.unscaledTime + 2f;
			if (PeerCurrent(rpc) && ZNet.World != null)
			{
				ZPackage val = new ZPackage();
				val.Write(ZNet.World.m_uid);
				val.Write(s.Compatible && SessionCurrent(rpc, s.Nonce) && ServerPolicyEndpoint.IsAdmin(rpc));
				val.Write(TimeFrozen);
				rpc.Invoke("VAT_Time_State_v1", new object[3] { 1, s.Nonce, val });
			}
		}

		private static void ReceiveState(ZRpc rpc, int version, string token, ZPackage data)
		{
			if (!Current || network.IsServer() || rpc != server || rpc != network.GetServerRPC() || !rpc.IsConnected() || version != 1 || token != nonce || data == null || data.Size() > 64 || ZNet.World == null)
			{
				return;
			}
			try
			{
				if (data.ReadLong() == ZNet.World.m_uid)
				{
					bool num = data.ReadBool();
					bool flag = data.ReadBool();
					serverAdmin = num;
					frozen = flag;
					receivedAt = Time.unscaledTime;
				}
			}
			catch (Exception ex)
			{
				Plugin.Instance.Log.LogWarning((object)("Invalid time state: " + ex.Message));
			}
		}

		internal static void Request(bool resume, int minute, bool freeze)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if (!CanChange)
			{
				AdminNetworkAccess.ShowMessage(Status);
			}
			else if (AdminEnvironment.ValidMinute(minute))
			{
				if (Host)
				{
					Apply(null, string.Empty, resume, minute, freeze);
					return;
				}
				ZPackage val = new ZPackage();
				val.Write(++sequence);
				val.Write(resume);
				val.Write(minute);
				val.Write(freeze);
				server.Invoke("VAT_Time_Command_v1", new object[3] { 1, nonce, val });
			}
		}

		private static void ReceiveCommand(ZRpc rpc, int version, string token, ZPackage data)
		{
			if (version != 1 || !SessionCurrent(rpc, token) || !ServerPolicyEndpoint.IsAdmin(rpc) || data == null || data.Size() > 64)
			{
				return;
			}
			Session session = Peers[rpc];
			if (Time.unscaledTime - session.LastCommand < 0.25f)
			{
				return;
			}
			try
			{
				int num = data.ReadInt();
				bool resume = data.ReadBool();
				int minute = data.ReadInt();
				bool freeze = data.ReadBool();
				if (num > session.Sequence && AdminEnvironment.ValidMinute(minute))
				{
					session.Sequence = num;
					session.LastCommand = Time.unscaledTime;
					Apply(rpc, token, resume, minute, freeze);
				}
			}
			catch (Exception ex)
			{
				Plugin.Instance.Log.LogWarning((object)("Invalid time request: " + ex.Message));
			}
		}

		private static void Apply(ZRpc? requester, string token, bool resume, int minute, bool freeze)
		{
			if (!Current || !network.IsServer() || (Object)(object)EnvMan.instance == (Object)null || SendTime == null)
			{
				return;
			}
			bool num;
			if (requester != null)
			{
				if (!SessionCurrent(requester, token))
				{
					return;
				}
				num = !ServerPolicyEndpoint.IsAdmin(requester);
			}
			else
			{
				num = !Host;
			}
			if (num)
			{
				return;
			}
			if (resume)
			{
				ClearFreeze();
			}
			else
			{
				double num2 = EnvMan.instance.m_dayLengthSec;
				double timeSeconds = network.GetTimeSeconds();
				if (num2 <= 0.0 || double.IsNaN(timeSeconds) || double.IsInfinity(timeSeconds) || timeSeconds < 0.0)
				{
					return;
				}
				double netTime = Math.Floor(timeSeconds / num2) * num2 + (double)AdminEnvironment.ToRaw((float)minute / 1440f) * num2;
				network.SetNetTime(netTime);
				freezeOnServer = freeze;
				freezeOwner = (freeze ? requester : null);
				ownerNonce = (freeze ? token : string.Empty);
			}
			SendTime.Invoke(network, Array.Empty<object>());
			Broadcast();
			string text = (resume ? "Global time resumed." : ("Global time set to " + AdminEnvironment.FormatMinute(minute) + (freeze ? " (frozen)." : ".")));
			if (requester == null)
			{
				AdminNetworkAccess.ShowMessage(text);
				return;
			}
			requester.Invoke("VAT_Message_v1", new object[1] { text });
		}

		private static void Broadcast()
		{
			foreach (KeyValuePair<ZRpc, Session> peer in Peers)
			{
				if (peer.Value.Nonce.Length != 0)
				{
					Reply(peer.Key, peer.Value);
				}
			}
		}

		private static void ClearFreeze()
		{
			freezeOnServer = false;
			freezeOwner = null;
			ownerNonce = string.Empty;
		}

		private static void Unregister(ZRpc rpc)
		{
			rpc.Unregister("VAT_Time_Hello_v1");
			rpc.Unregister("VAT_Time_Command_v1");
			Peers.Remove(rpc);
		}

		internal static void Dispose()
		{
			ZRpc[] array = Peers.Keys.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				Unregister(array[i]);
			}
			ZRpc? obj = server;
			if (obj != null)
			{
				obj.Unregister("VAT_Time_State_v1");
			}
			ClearFreeze();
			server = null;
			network = null;
			nonce = string.Empty;
			serverAdmin = false;
			frozen = false;
			receivedAt = float.NegativeInfinity;
			nextHello = 0f;
			sequence = 0;
		}
	}
	internal sealed class AdminEquipmentSlots
	{
		private const string Guid = "randyknapp.mods.equipmentandquickslots";

		private readonly Type slots;

		internal readonly int BaseRows;

		internal readonly int ExtraRows;

		internal readonly int VisibleRows;

		private AdminEquipmentSlots(Type slots, int rows, int extra, int visible)
		{
			this.slots = slots;
			BaseRows = rows;
			ExtraRows = extra;
			VisibleRows = visible;
		}

		internal static AdminEquipmentSlots? Read(Player player)
		{
			if (!Chainloader.PluginInfos.TryGetValue("randyknapp.mods.equipmentandquickslots", out var _))
			{
				return null;
			}
			Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().Single((Assembly a) => a.GetName().Name == "EquipmentAndQuickSlots");
			Type type = assembly.GetType("EquipmentAndQuickSlots.Slots", throwOnError: true);
			int num = (int)Value("BaseRows");
			int num2 = (int)Value("ExtraRows");
			int num3 = (int)Value("VisibleRows");
			int num4 = (int)Value("FullHeight");
			if (Value("PlayerInventory") != ((Humanoid)player).GetInventory() || num < 1 || num > 9 || num2 < 0 || num2 > 5 || num3 != num + num2 || num4 != num3 + 3 || ((Humanoid)player).GetInventory().GetHeight() != num4)
			{
				throw new InvalidOperationException("EquipmentAndQuickSlots inventory layout is not ready or unsupported.");
			}
			return new AdminEquipmentSlots(type, num, num2, num3);
			object? Value(string name)
			{
				return type.GetProperty(name, BindingFlags.Static | BindingFlags.Public)?.GetValue(null) ?? throw new InvalidOperationException("EquipmentAndQuickSlots API missing: " + name);
			}
		}

		internal bool IsSlot(ItemData item)
		{
			if (item != null)
			{
				return slots.GetMethod("GetItemSlot", new Type[1] { typeof(ItemData) }).Invoke(null, new object[1] { item }) != null;
			}
			return false;
		}

		internal bool CanResize()
		{
			if (HasHook(typeof(Player), "SetInventorySize"))
			{
				return HasHook(typeof(Humanoid), "DropInvalidItems");
			}
			return false;
			bool HasHook(Type owner, string name)
			{
				return Harmony.GetPatchInfo((MethodBase)AccessTools.Method(owner, name, (Type[])null, (Type[])null))?.Prefixes.Any((Patch patch) => patch.PatchMethod.DeclaringType?.Assembly == slots.Assembly) ?? false;
			}
		}
	}
	internal enum AdminEspCategory
	{
		Players,
		Creatures,
		DroppedItems,
		Resources,
		Pickables,
		Dungeons
	}
	internal static class AdminEsp
	{
		private readonly struct EspTarget
		{
			private readonly string searchLabel;

			private readonly string searchPrefab;

			private readonly string searchName;

			public Transform Target { get; }

			public string Label { get; }

			public Color Color { get; }

			public bool DrawBox { get; }

			public EspTarget(Transform target, string label, Color color, bool drawBox, string rawName, string prefabName)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				Target = target;
				Label = label;
				Color = color;
				DrawBox = drawBox;
				searchLabel = AdminEspNames.NormalizeSearch(label);
				searchPrefab = AdminEspNames.NormalizeSearch(prefabName);
				searchName = AdminEspNames.NormalizeSearch(rawName);
			}

			internal bool MatchesSearch(string query)
			{
				if (query.Length != 0 && !AdminEspNames.Contains(searchLabel, query) && !AdminEspNames.Contains(searchPrefab, query))
				{
					return AdminEspNames.Contains(searchName, query);
				}
				return true;
			}
		}

		private const float RefreshInterval = 1.5f;

		private const float MinDrawDistance = 2f;

		private static readonly Dictionary<AdminEspCategory, bool> CategoryStates = new Dictionary<AdminEspCategory, bool>
		{
			[AdminEspCategory.Players] = false,
			[AdminEspCategory.Creatures] = false,
			[AdminEspCategory.DroppedItems] = false,
			[AdminEspCategory.Resources] = false,
			[AdminEspCategory.Pickables] = false,
			[AdminEspCategory.Dungeons] = false
		};

		private static readonly FieldRef<LocationProxy, GameObject> LocationInstanceRef = AccessTools.FieldRefAccess<LocationProxy, GameObject>("m_instance");

		private static readonly List<EspTarget> Targets = new List<EspTarget>();

		private static Texture2D? pixelTexture;

		private static GUIStyle? labelStyle;

		private static float nextRefreshTime;

		private static string searchText = string.Empty;

		private static string searchQuery = string.Empty;

		public static string SearchText
		{
			get
			{
				return searchText;
			}
			set
			{
				searchText = value ?? string.Empty;
				searchQuery = AdminEspNames.NormalizeSearch(searchText);
			}
		}

		public static int MaxDistance { get; set; } = 300;

		public static bool IsEnabled
		{
			get
			{
				if (AdminNetworkAccess.Allowed)
				{
					return CategoryStates.Values.Any((bool enabled) => enabled);
				}
				return false;
			}
		}

		public static bool GetCategoryEnabled(AdminEspCategory category)
		{
			bool value;
			return CategoryStates.TryGetValue(category, out value) && value;
		}

		public static void SetCategoryEnabled(AdminEspCategory category, bool enabled)
		{
			CategoryStates[category] = enabled && AdminNetworkAccess.Allowed;
			InvalidateTargets();
		}

		internal static void Reset()
		{
			AdminEspCategory[] array = CategoryStates.Keys.ToArray();
			foreach (AdminEspCategory key in array)
			{
				CategoryStates[key] = false;
			}
			InvalidateTargets();
		}

		internal static void InvalidateTargets()
		{
			Targets.Clear();
			nextRefreshTime = 0f;
		}

		public static void Update()
		{
			if (IsEnabled && !(Time.time < nextRefreshTime))
			{
				nextRefreshTime = Time.time + 1.5f;
				RefreshTargets();
			}
		}

		public static void Draw()
		{
			//IL_0074: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			if (!IsEnabled || (Object)(object)Camera.main == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			EnsureGuiResources();
			Camera main = Camera.main;
			EspTarget[] array = Targets.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				EspTarget espTarget = array[i];
				if ((Object)(object)espTarget.Target == (Object)null || !espTarget.MatchesSearch(searchQuery))
				{
					continue;
				}
				float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, espTarget.Target.position);
				if (num < 2f || num > (float)MaxDistance)
				{
					continue;
				}
				Vector3 val = main.WorldToScreenPoint(espTarget.Target.position);
				if (!(val.z <= 0f))
				{
					string text = $"{espTarget.Label} [{Mathf.RoundToInt(num)}m]";
					DrawLabel(val, text, espTarget.Color);
					if (espTarget.DrawBox)
					{
						DrawBox(main, espTarget.Target, espTarget.Color);
					}
				}
			}
		}

		private static void RefreshTargets()
		{
			//IL_0020: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_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_00c2: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			Targets.Clear();
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)localPlayer).transform.position;
			if (GetCategoryEnabled(AdminEspCategory.Players) || GetCategoryEnabled(AdminEspCategory.Creatures))
			{
				foreach (Character allCharacter in Character.GetAllCharacters())
				{
					if ((Object)(object)allCharacter == (Object)null)
					{
						continue;
					}
					if (allCharacter.IsPlayer())
					{
						if (GetCategoryEnabled(AdminEspCategory.Pla