Decompiled source of DojoArenaKT v1.0.0

BepInEx/BloodstonePlugins/DojoArenaKT.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bloodstone.API;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using ProjectM;
using ProjectM.Gameplay.Systems;
using ProjectM.Network;
using ProjectM.Shared;
using Stunlock.Core;
using Stunlock.Localization;
using Stunlock.Network;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DojoArenaKT")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("The Dojo: Arena Plugin by KT")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0")]
[assembly: AssemblyProduct("DojoArenaKT")]
[assembly: AssemblyTitle("DojoArenaKT")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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 DojoArenaKT
{
	public static class Color
	{
		public static string White = ColorString("#ffffffff");

		public static string Black = ColorString("#000000ff");

		public static string Gray = ColorString("#404040ff");

		public static string Orange = ColorString("#c98332ff");

		public static string Yellow = ColorString("#e7ed74");

		public static string Green = ColorString("#56ad3bff");

		public static string Teal = ColorString("#3b8dadff");

		public static string Blue = ColorString("#3444a8ff");

		public static string Purple = ColorString("#8b3691ff");

		public static string Pink = ColorString("#b53c8fff");

		public static string Red = ColorString("#ff0000ff");

		public static string SoftRed = ColorString("#b53c40ff");

		public static string Clear = "<clear>";

		public static string CloseTag = "</color>";

		public static string ColorString(string input)
		{
			return "<color=" + input + ">";
		}

		public static string ProcessMessage(string input)
		{
			StringBuilder stringBuilder = new StringBuilder();
			string[] array = input.Split(Clear);
			foreach (string value in array)
			{
				stringBuilder.Append(value);
				string input2 = stringBuilder.ToString();
				int num = Regex.Matches(input2, "<color=.*?>").Count - Regex.Matches(input2, "<\\/color>").Count;
				if (num > 0)
				{
					for (int j = 0; j < num; j++)
					{
						stringBuilder.Append(CloseTag);
					}
				}
			}
			return stringBuilder.ToString();
		}
	}
	public static class Database
	{
		public static class BuffGUID
		{
			public static PrefabGUID AB_Interact_GetInside_Owner_Buff_Stone = new PrefabGUID(569692162);

			public static PrefabGUID AB_Interact_GetInside_Owner_Buff_Base = new PrefabGUID(381160212);

			public static PrefabGUID AB_ExitCoffin_Travel_Phase_Stone = new PrefabGUID(-162820429);

			public static PrefabGUID AB_ExitCoffin_Travel_Phase_Base = new PrefabGUID(-997204628);

			public static PrefabGUID AB_Interact_TombCoffinSpawn_Travel = new PrefabGUID(722466953);

			public static PrefabGUID AB_Interact_WaypointSpawn_Travel = new PrefabGUID(-66432447);

			public static PrefabGUID AB_Interact_WoodenCoffinSpawn_Travel = new PrefabGUID(-1705977973);

			public static PrefabGUID AB_Interact_StoneCoffinSpawn_Travel = new PrefabGUID(-1276482574);

			public static PrefabGUID WolfStygian = new PrefabGUID(-1158884666);

			public static PrefabGUID WolfNormal = new PrefabGUID(-351718282);

			public static PrefabGUID BatForm = new PrefabGUID(1205505492);

			public static PrefabGUID NormalForm = new PrefabGUID(1352541204);

			public static PrefabGUID RatForm = new PrefabGUID(902394170);

			public static PrefabGUID DownedBuff = new PrefabGUID(-1992158531);

			public static PrefabGUID BloodSight = new PrefabGUID(1199823151);

			public static PrefabGUID InCombat = new PrefabGUID(581443919);

			public static PrefabGUID InCombat_PvP = new PrefabGUID(697095869);

			public static PrefabGUID OutofCombat = new PrefabGUID(897325455);

			public static PrefabGUID BloodMoon = new PrefabGUID(-560523291);

			public static PrefabGUID Severe_GarlicDebuff = new PrefabGUID(1582196539);

			public static PrefabGUID General_GarlicDebuff = new PrefabGUID(-1701323826);

			public static PrefabGUID Buff_VBlood_Perk_Moose = new PrefabGUID(-1464851863);

			public static PrefabGUID PerkMoose = new PrefabGUID(-1464851863);

			public static PrefabGUID SiegeGolem_T01 = new PrefabGUID(-148535031);

			public static PrefabGUID SiegeGolem_T02 = new PrefabGUID(914043867);

			public static PrefabGUID LevelUp_Buff = new PrefabGUID(-1133938228);

			public static PrefabGUID AB_Undead_BishopOfShadows_ShadowSoldier_Minion_Buff = new PrefabGUID(450215391);

			public static PrefabGUID Pig_Transform_Debuff = new PrefabGUID(1356064917);
		}

		public static Dictionary<string, WaypointData> globalWaypoint = new Dictionary<string, WaypointData>();

		public static JsonSerializerOptions JsonOptions = new JsonSerializerOptions
		{
			WriteIndented = false,
			IncludeFields = false
		};
	}
	internal static class EntityExtensions
	{
		public static bool HasData<T>(this Entity entity) where T : new()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = G.EntityManager;
			return ((EntityManager)(ref entityManager)).HasComponent<T>(entity);
		}

		public static T GetData<T>(this Entity entity) where T : new()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = G.EntityManager;
			return ((EntityManager)(ref entityManager)).GetComponentData<T>(entity);
		}

		public static void SetData<T>(this Entity entity, T component) where T : new()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = VWorld.Server.EntityManager;
			((EntityManager)(ref entityManager)).SetComponentData<T>(entity, component);
		}

		public static NativeArray<ComponentType> GetComponentTypes(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = G.EntityManager;
			return ((EntityManager)(ref entityManager)).GetComponentTypes(entity, (Allocator)2);
		}

		public static string GetPrefabName(this PrefabGUID prefabGuid)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return ((PrefabCollectionSystem_Base)VWorld.Server.GetExistingSystem<PrefabCollectionSystem>()).PrefabGuidToNameDictionary[prefabGuid];
			}
			catch
			{
				return "Unknown";
			}
		}

		public static string GetPrefabName(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return entity.GetData<PrefabGUID>().GetPrefabName();
			}
			catch
			{
				return "Unknown";
			}
		}

		public static PrefabGUID GetPrefabGUID(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return entity.GetData<PrefabGUID>();
			}
			catch
			{
				return new PrefabGUID(0);
			}
		}

		public static Guid ToSystemGuid(this Guid il2CppGuid)
		{
			return Guid.Parse(((object)(Guid)(ref il2CppGuid)).ToString());
		}

		public static void Dump(this Entity target)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			try
			{
				Output.Log(target.GetPrefabName() + " [" + target.GetPrefabGUID().GuidHash + "]" + Environment.NewLine, (LogLevel)4);
			}
			catch
			{
			}
			Enumerator<ComponentType> enumerator = target.GetComponentTypes().GetEnumerator();
			while (enumerator.MoveNext())
			{
				ComponentType current = enumerator.Current;
				try
				{
					EntityManager entityManager = G.EntityManager;
					MethodInfo val = ((EntityManager)(ref entityManager)).BoxIl2CppObject().GetIl2CppType().GetMethod("GetComponentData")
						.MakeGenericMethod((Type[])(object)new Type[1] { ((ComponentType)(ref current)).GetManagedType() });
					Object[] array = (Object[])(object)new Object[1] { ((Entity)(ref target)).BoxIl2CppObject() };
					entityManager = G.EntityManager;
					object obj2 = ((MethodBase)val).Invoke(((EntityManager)(ref entityManager)).BoxIl2CppObject(), Il2CppReferenceArray<Object>.op_Implicit(array));
					Output.Log(((Object)((ComponentType)(ref current)).GetManagedType()).ToString() + ": " + JsonConvert.SerializeObject((Object)obj2), (LogLevel)4);
				}
				catch
				{
				}
			}
		}

		public static void Destroy(this Entity target)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			DestroyUtility.CreateDestroyEvent(G.EntityManager, target, (DestroyReason)0, (DestroyDebugReason)32);
		}

		public static void Teleport(this Entity target, float3 position)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0030: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_006c: 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_0074: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = G.EntityManager;
			if (((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(target))
			{
				entityManager = G.EntityManager;
				Entity userEntity = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(target).UserEntity;
				FromCharacter val = default(FromCharacter);
				val.User = userEntity;
				val.Character = target;
				FromCharacter val2 = val;
				entityManager = G.EntityManager;
				Entity val3 = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[2]
				{
					ComponentType.ReadWrite<FromCharacter>(),
					ComponentType.ReadWrite<PlayerTeleportDebugEvent>()
				});
				entityManager = G.EntityManager;
				((EntityManager)(ref entityManager)).SetComponentData<FromCharacter>(val3, val2);
				entityManager = G.EntityManager;
				((EntityManager)(ref entityManager)).SetComponentData<PlayerTeleportDebugEvent>(val3, new PlayerTeleportDebugEvent
				{
					Position = position,
					Target = (TeleportTarget)0
				});
			}
		}
	}
	public static class Entities
	{
	}
	public class Event
	{
		public static Dictionary<Events, List<MethodInfo>> Subscribers = new Dictionary<Events, List<MethodInfo>>();

		public static void Fire(Events eventID, object[] arguments = null)
		{
			if (!Subscribers.ContainsKey(eventID))
			{
				return;
			}
			foreach (MethodInfo item in Subscribers[eventID])
			{
				try
				{
					item.Invoke(null, arguments);
				}
				catch (Exception exception)
				{
					Output.LogError("FireEvent-" + Enum.GetName(eventID) + "-" + item.Name, exception);
				}
			}
		}

		public static void RegisterEvents()
		{
			if (!G.MethodsWithAttributes.ContainsKey(typeof(EventSubscriberAttribute)))
			{
				return;
			}
			List<(MethodInfo Method, Attribute Attribute)> list = G.MethodsWithAttributes[typeof(EventSubscriberAttribute)];
			list.Sort(delegate((MethodInfo Method, Attribute Attribute) tupl1, (MethodInfo Method, Attribute Attribute) tupl2)
			{
				EventSubscriberAttribute obj = (EventSubscriberAttribute)tupl1.Attribute;
				EventSubscriberAttribute eventSubscriberAttribute = (EventSubscriberAttribute)tupl2.Attribute;
				return obj.Priority.CompareTo(eventSubscriberAttribute.Priority);
			});
			foreach (var item2 in list)
			{
				MethodInfo item = item2.Method;
				Events subscribedEvent = ((EventSubscriberAttribute)item2.Attribute).SubscribedEvent;
				if (!Subscribers.ContainsKey(subscribedEvent))
				{
					Subscribers.Add(subscribedEvent, new List<MethodInfo>());
				}
				Subscribers[subscribedEvent].Add(item);
			}
		}
	}
	public enum Events
	{
		Preload,
		Load,
		Unload,
		BootstrapStart,
		BootstrapQuit
	}
	public class EventSubscriberAttribute : Attribute
	{
		public Events SubscribedEvent;

		public int Priority;

		public EventSubscriberAttribute(Events subscribedEvent, int priority = 0)
		{
			SubscribedEvent = subscribedEvent;
			Priority = priority;
		}
	}
	public static class G
	{
		public static Dictionary<string, (string Name, PrefabGUID PrefabGUID)> PrefabNameLookup = new Dictionary<string, (string, PrefabGUID)>();

		public static Dictionary<Type, List<(MethodInfo Method, Attribute Attribute)>> MethodsWithAttributes = new Dictionary<Type, List<(MethodInfo, Attribute)>>();

		private static World _serverWorld;

		private static EntityCommandBufferSystem _bufferSystem;

		private static ServerBootstrapSystem _bootstrapSystem;

		private static DebugEventsSystem _debugEvents;

		private static GameDataSystem _gameData;

		private static PrefabCollectionSystem _prefabSystem;

		private static AdminAuthSystem _adminSystem;

		public static float3 defaultSpawnLocation = new float3(-2002.5f, 5f, -2797.5f);

		public static bool IsServer => Application.productName == "VRisingServer";

		public static World World
		{
			get
			{
				if (_serverWorld != null)
				{
					return _serverWorld;
				}
				_serverWorld = GetWorld("Server") ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?");
				return _serverWorld;
			}
		}

		public static EntityManager EntityManager => World.EntityManager;

		public static EntityCommandBufferSystem BufferSystem
		{
			get
			{
				if (_bufferSystem == null)
				{
					_bufferSystem = World.GetOrCreateSystem<EntityCommandBufferSystem>();
				}
				return _bufferSystem;
			}
		}

		public static ServerBootstrapSystem BootstrapSystem
		{
			get
			{
				if (_bootstrapSystem == null)
				{
					_bootstrapSystem = World.GetOrCreateSystem<ServerBootstrapSystem>();
				}
				return _bootstrapSystem;
			}
		}

		public static DebugEventsSystem DebugSystem
		{
			get
			{
				if (_debugEvents == null)
				{
					_debugEvents = World.GetOrCreateSystem<DebugEventsSystem>();
				}
				return _debugEvents;
			}
		}

		public static GameDataSystem GameData
		{
			get
			{
				if (_gameData == null)
				{
					_gameData = World.GetOrCreateSystem<GameDataSystem>();
				}
				return _gameData;
			}
		}

		public static PrefabCollectionSystem PrefabSystem
		{
			get
			{
				if (_prefabSystem == null)
				{
					_prefabSystem = World.GetOrCreateSystem<PrefabCollectionSystem>();
				}
				return _prefabSystem;
			}
		}

		public static AdminAuthSystem AdminSystem
		{
			get
			{
				if (_adminSystem == null)
				{
					_adminSystem = World.GetOrCreateSystem<AdminAuthSystem>();
				}
				return _adminSystem;
			}
		}

		public static float3 SpawnLocation
		{
			get
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				if (Database.globalWaypoint.TryGetValue("spawn", out var value))
				{
					return new float3(value.LocationX, value.LocationY, value.LocationZ);
				}
				return defaultSpawnLocation;
			}
		}

		private static World GetWorld(string name)
		{
			Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
			while (enumerator.MoveNext())
			{
				World current = enumerator.Current;
				if (current.Name == name)
				{
					return current;
				}
			}
			return null;
		}

		public static void SetupAttributedMethodList()
		{
			MethodInfo[] array = (from m in Assembly.GetExecutingAssembly().GetTypes().SelectMany((Type t) => t.GetMethods())
				where m.GetCustomAttributes(inherit: false).Length != 0
				select m).ToArray();
			foreach (MethodInfo methodInfo in array)
			{
				foreach (CustomAttributeData customAttribute in methodInfo.CustomAttributes)
				{
					try
					{
						if (!MethodsWithAttributes.ContainsKey(customAttribute.AttributeType))
						{
							MethodsWithAttributes.Add(customAttribute.AttributeType, new List<(MethodInfo, Attribute)>());
						}
						MethodsWithAttributes[customAttribute.AttributeType].Add((methodInfo, methodInfo.GetCustomAttribute(customAttribute.AttributeType, inherit: false)));
					}
					catch
					{
					}
				}
			}
		}

		[EventSubscriber(Events.Load, 0)]
		public static void PopulatePrefabLookup()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<string, PrefabGUID> enumerator = ((PrefabCollectionSystem_Base)PrefabSystem).SpawnableNameToPrefabGuidDictionary.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<string, PrefabGUID> current = enumerator.Current;
				PrefabNameLookup[current.Key.ToLower()] = (current.Key, current.Value);
			}
		}
	}
	public static class Item
	{
		private static ManagedItemData itemDataEmpty;

		public static PrefabGUID FromName(string name)
		{
			//IL_001c: 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)
			if (G.PrefabNameLookup.TryGetValue(name.ToLower(), out (string, PrefabGUID) value))
			{
				return value.Item2;
			}
			return new PrefabGUID(0);
		}

		public static ManagedItemData GetData(PrefabGUID prefabGUID)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return G.GameData.ManagedDataRegistry.GetOrDefault<ManagedItemData>(prefabGUID, (ManagedItemData)null);
			}
			catch
			{
			}
			return itemDataEmpty;
		}

		public static string GetName(PrefabGUID prefabGUID)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			LocalizationKey name = GetData(prefabGUID).Name;
			return ((object)(LocalizationKey)(ref name)).ToString();
		}
	}
	public class SpellModData
	{
		public string PrefabName { get; set; }

		public int PrefabGUID { get; set; }

		public string Group { get; set; }

		public string AbilityName { get; set; }
	}
	public struct SpellModConfig
	{
		public int GUID { get; set; }

		public string Name { get; set; }
	}
	public class Jewel
	{
		internal Dictionary<int, string> spellModsInternal;

		public string PrefabName { get; set; }

		public int PrefabGUID { get; set; }

		public int AbilityPrefabGUID { get; set; }

		public string AbilityPrefabName { get; set; }

		public string AbilityGroup { get; set; }

		public string AbilityName { get; set; }

		public Dictionary<int, SpellModConfig> SpellMods { get; set; }
	}
	public static class Jewels
	{
		public const string ConfigFile = "BepInEx/Arena/jewels.json";

		public static Dictionary<int, Jewel> List = new Dictionary<int, Jewel>();

		public static Dictionary<string, int> SpellKeywords = new Dictionary<string, int>();

		public static string SpellKeywordsJoined;

		[EventSubscriber(Events.Load, 0)]
		public static void LoadConfig()
		{
			if (!File.Exists("BepInEx/Arena/jewels.json"))
			{
				File.WriteAllText("BepInEx/Arena/jewels.json", JsonSerializer.Serialize(List, new JsonSerializerOptions
				{
					WriteIndented = true
				}));
			}
			List = JsonSerializer.Deserialize<Dictionary<int, Jewel>>(File.ReadAllText("BepInEx/Arena/jewels.json"));
			List<string> list = new List<string>();
			foreach (KeyValuePair<int, Jewel> item in List)
			{
				item.Deconstruct(out var key, out var value);
				int value2 = key;
				string input = value.PrefabName.Split('_').Last();
				input = Regex.Replace(input, "(?<=[a-zA-Z])(?=[A-Z])", " ");
				SpellKeywords[input] = value2;
				list.Add(input);
			}
			SpellKeywordsJoined = string.Join(", ", list);
			Output.Log("Loaded Jewel Configuration successfully.", (LogLevel)4);
		}

		public static void GenerateDebugConfig()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<int, Jewel> dictionary = new Dictionary<int, Jewel>();
			List<SpellModData> list = new List<SpellModData>();
			string text = "";
			Dictionary<string, HashSet<int>> dictionary2 = new Dictionary<string, HashSet<int>>();
			List<SpellModData> list2 = new List<SpellModData>();
			Enumerator<PrefabGUID, string> enumerator = ((PrefabCollectionSystem_Base)G.PrefabSystem).PrefabGuidToNameDictionary.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<PrefabGUID, string> current = enumerator.Current;
				PrefabGUID key = current.Key;
				string value = current.Value;
				if (value.StartsWith("SpellMod_"))
				{
					text = text + $"{key.GuidHash,-15} {value}" + Environment.NewLine;
				}
				if (value.StartsWith("SpellMod_") && !value.StartsWith("SpellMod_Weapon_") && !value.Contains("DefaultCurve") && !value.Contains("_Shared_Weapon_"))
				{
					string[] array = value.Replace("SpellMod_Shared_", "").Replace("SpellMod_", "").Split('_');
					SpellModData item = new SpellModData
					{
						PrefabName = value,
						PrefabGUID = key.GuidHash,
						Group = array[0],
						AbilityName = ((array.Length >= 3) ? array[1] : array[0])
					};
					list.Add(item);
				}
				else if (value.StartsWith("Item_Jewel") && value.Contains("_T03_"))
				{
					NativeHashMap<PrefabGUID, Entity> guidToEntityMap = ((PrefabCollectionSystem_Base)G.PrefabSystem).PrefabLookupMap.GuidToEntityMap;
					JewelInstance data = guidToEntityMap[key].GetData<JewelInstance>();
					int guidHash = data.OverrideAbilityType.GuidHash;
					string text2 = data.OverrideAbilityType.GetPrefabName().Replace("AB_", "").Replace("_AbilityGroup", "");
					string[] array2 = text2.Split('_');
					Debug.Assert(array2.Length != 0 && array2.Length < 3);
					string text3 = array2[0];
					string text4 = ((array2.Length >= 2) ? array2[1] : array2[0]);
					Jewel jewel = new Jewel
					{
						PrefabGUID = key.GuidHash,
						PrefabName = value,
						AbilityPrefabGUID = guidHash,
						AbilityPrefabName = text2,
						AbilityGroup = text3,
						AbilityName = text4,
						spellModsInternal = new Dictionary<int, string>()
					};
					dictionary[key.GuidHash] = jewel;
					string key2 = text3.ToLower();
					string key3 = text4.ToLower();
					if (!dictionary2.ContainsKey(key2))
					{
						dictionary2[key2] = new HashSet<int>();
					}
					if (!dictionary2.ContainsKey(key3))
					{
						dictionary2[key3] = new HashSet<int>();
					}
					dictionary2[key2].Add(jewel.PrefabGUID);
					dictionary2[key3].Add(jewel.PrefabGUID);
				}
			}
			foreach (SpellModData item2 in list)
			{
				new HashSet<Jewel>();
				bool flag = false;
				if (dictionary2.ContainsKey(item2.Group.ToLower()) && item2.PrefabName.Contains("_Shared_"))
				{
					foreach (int item3 in dictionary2[item2.Group.ToLower()])
					{
						dictionary[item3].spellModsInternal[item2.PrefabGUID] = item2.PrefabName;
					}
					flag = true;
				}
				if (dictionary2.ContainsKey(item2.AbilityName.ToLower()))
				{
					foreach (int item4 in dictionary2[item2.AbilityName.ToLower()])
					{
						dictionary[item4].spellModsInternal[item2.PrefabGUID] = item2.PrefabName;
					}
					flag = true;
				}
				if (!flag)
				{
					list2.Add(item2);
				}
			}
			foreach (KeyValuePair<int, Jewel> item5 in dictionary)
			{
				item5.Deconstruct(out var key4, out var value2);
				Jewel jewel2 = value2;
				jewel2.SpellMods = new Dictionary<int, SpellModConfig>();
				int num = 1;
				foreach (KeyValuePair<int, string> item6 in jewel2.spellModsInternal)
				{
					item6.Deconstruct(out key4, out var value3);
					int gUID = key4;
					string name = value3;
					jewel2.SpellMods[num] = new SpellModConfig
					{
						GUID = gUID,
						Name = name
					};
					num++;
				}
			}
			string contents = JsonSerializer.Serialize(dictionary, new JsonSerializerOptions
			{
				WriteIndented = true
			});
			File.WriteAllText("BepInEx/Arena/generated_jewel_data.txt", contents);
			File.WriteAllText("BepInEx/Arena/generated_oddonesout_jewel_data.txt", JsonSerializer.Serialize(list2, new JsonSerializerOptions
			{
				WriteIndented = true
			}));
			File.WriteAllText("BepInEx/Arena/generated_all_spellmods.txt", text);
			Output.Log("Debug config generated for Jewels.", (LogLevel)4);
		}
	}
	internal static class ListExtensions
	{
		private static Random rng = new Random();

		public static void Shuffle<T>(this IList<T> list)
		{
			int num = list.Count;
			while (num > 1)
			{
				num--;
				int index = rng.Next(num + 1);
				T value = list[index];
				list[index] = list[num];
				list[num] = value;
			}
		}
	}
	public static class Output
	{
		public static ManualLogSource Logger;

		public static void Log(object messageObject, LogLevel logLevel = 4, string LogType = "CompleteLog")
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = messageObject.ToString();
				Logger.Log(logLevel, (object)text);
				Logs.Write(text, LogType);
			}
			catch (Exception ex)
			{
				Console.WriteLine("Failed to execute Output.Log '" + messageObject.ToString() + "' with Error: " + ex.ToString());
			}
		}

		public static void LogError(string identifier, object exception, string additionalInfo = null)
		{
			try
			{
				string text = "Runtime Exception '" + identifier + "': " + Environment.NewLine + exception.ToString() + Environment.NewLine + ((additionalInfo == null) ? "No additional information." : ("Additional Information: " + additionalInfo));
				Logger.LogError((object)text);
				Logs.Write(text, "ErrorLog");
			}
			catch (Exception ex)
			{
				Console.WriteLine("Failed to execute Output.LogError '" + identifier.ToString() + "' with Error: " + ex.ToString());
			}
		}

		public static void Dump(Entity ent)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			ent.Dump();
		}

		public static void SendMessage(User user, object message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			ServerChatUtils.SendSystemMessageToClient(G.BufferSystem.CreateCommandBuffer(), user, Color.ProcessMessage(message.ToString()));
		}

		public static void SendMessage(Player player, object message)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			SendMessage(player.User, message);
		}

		public static void SendMessage(Entity playerCharacterEntity, object message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			Player player = Player.FromCharacter(playerCharacterEntity);
			if (player.IsValid)
			{
				SendMessage(player, message);
			}
		}
	}
	public class Player
	{
		public static Dictionary<ulong, Player> List = new Dictionary<ulong, Player>();

		public static Player Invalid = new Player();

		public bool IsValid;

		public string InvalidReason = "Player is invalid";

		public Entity Character;

		public Entity UserEntity;

		private static MethodInfo _respawnMethod = null;

		public ulong SteamID64 { get; private set; }

		public User User => UserEntity.GetData<User>();

		public bool IsAdmin => User.IsAdmin;

		public string LongName => $"[{SteamID64}] {CharacterData.Name}";

		public string Name
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				PlayerCharacter characterData = CharacterData;
				return ((object)(FixedString64)(ref characterData.Name)).ToString();
			}
		}

		public PlayerCharacter CharacterData => Character.GetData<PlayerCharacter>();

		private static MethodInfo RespawnMethod
		{
			get
			{
				if (_respawnMethod == (MethodInfo)null)
				{
					_respawnMethod = ((IEnumerable<MethodInfo>)((Object)G.BootstrapSystem).GetIl2CppType().GetMethods()).First((MethodInfo x) => ((MemberInfo)x).Name.Contains("RespawnCharacter") && ((MethodBase)x).GetParametersCount() == 6);
				}
				return _respawnMethod;
			}
		}

		public bool CheckValidity()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (IsValid)
			{
				EntityManager entityManager = G.EntityManager;
				if (((EntityManager)(ref entityManager)).Exists(Character))
				{
					entityManager = G.EntityManager;
					if (((EntityManager)(ref entityManager)).Exists(UserEntity))
					{
						return User.PlatformId == SteamID64;
					}
				}
			}
			return false;
		}

		public static Player FromUserEntity(Entity userEntity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return FromUser(userEntity.GetData<User>());
		}

		public static Player FromUser(User user)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return FromCharacter(user.LocalCharacter._Entity);
		}

		public static Player FromCharacter(Entity characterEntity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_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)
			EntityManager entityManager = G.EntityManager;
			if (!((EntityManager)(ref entityManager)).Exists(characterEntity))
			{
				return Invalid;
			}
			if (!characterEntity.HasData<PlayerCharacter>())
			{
				return Invalid;
			}
			Entity userEntity = characterEntity.GetData<PlayerCharacter>().UserEntity;
			ulong platformId = userEntity.GetData<User>().PlatformId;
			if (List.ContainsKey(platformId))
			{
				Player player = List[platformId];
				if (player.CheckValidity())
				{
					return player;
				}
				player.IsValid = false;
			}
			Player player2 = new Player();
			player2.SteamID64 = platformId;
			player2.Character = characterEntity;
			player2.UserEntity = userEntity;
			player2.IsValid = true;
			List[platformId] = player2;
			return player2;
		}

		public void Respawn()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			LocalToWorld data = Character.GetData<LocalToWorld>();
			Respawn(((LocalToWorld)(ref data)).Position);
		}

		public void Respawn(float3 spawnLocation)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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)
			EntityCommandBuffer val = G.BufferSystem.CreateCommandBuffer();
			Object val2 = ((Entity)(ref UserEntity)).BoxIl2CppObject();
			((MethodBase)RespawnMethod).Invoke((Object)(object)G.BootstrapSystem, Il2CppReferenceArray<Object>.op_Implicit((Object[])(object)new Object[6]
			{
				((EntityCommandBuffer)(ref val)).BoxIl2CppObject(),
				val2,
				(Object)new Nullable<float3>(spawnLocation),
				((Entity)(ref Character)).BoxIl2CppObject(),
				val2,
				Object.op_Implicit(-1)
			}));
			FullyRestore();
		}

		public void Message(object message)
		{
			Output.SendMessage(this, message);
		}

		public T GetData<T>() where T : new()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return Character.GetData<T>();
		}

		public void SetData<T>(T component) where T : new()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Character.SetData(component);
		}

		public bool RemoveItem(PrefabGUID prefabGUID, int amount)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return InventoryUtilitiesServer.TryRemoveItem(G.EntityManager, Character, prefabGUID, amount);
		}

		public List<(PrefabGUID, NetworkedEntity)> GetEquipment()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			List<(PrefabGUID, NetworkedEntity)> list = new List<(PrefabGUID, NetworkedEntity)>();
			try
			{
				Equipment data = Character.GetData<Equipment>();
				if (data.ArmorChestSlotId.GuidHash != 0)
				{
					list.Add((data.ArmorChestSlotId, data.ArmorChestSlotEntity));
				}
				if (data.ArmorHeadgearSlotId.GuidHash != 0)
				{
					list.Add((data.ArmorHeadgearSlotId, data.ArmorHeadgearSlotEntity));
				}
				if (data.ArmorLegsSlotId.GuidHash != 0)
				{
					list.Add((data.ArmorLegsSlotId, data.ArmorLegsSlotEntity));
				}
				if (data.ArmorFootgearSlotId.GuidHash != 0)
				{
					list.Add((data.ArmorFootgearSlotId, data.ArmorFootgearSlotEntity));
				}
				if (data.ArmorGlovesSlotId.GuidHash != 0)
				{
					list.Add((data.ArmorGlovesSlotId, data.ArmorGlovesSlotEntity));
				}
				if (data.CloakSlotId.GuidHash != 0)
				{
					list.Add((data.CloakSlotId, data.CloakSlotEntity));
				}
				if (data.GrimoireSlotId.GuidHash != 0)
				{
					list.Add((data.GrimoireSlotId, data.GrimoireSlotEntity));
				}
				if (data.WeaponSlotId.GuidHash != 0)
				{
					list.Add((data.WeaponSlotId, data.WeaponSlotEntity));
				}
			}
			catch (Exception exception)
			{
				Output.LogError("GetPlayerEquipment", exception, $"SteamID={SteamID64}, Name={Name}");
			}
			return list;
		}

		public int CountItems(PrefabGUID item)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			Enumerator<InventoryBuffer> enumerator = GetInventory().GetEnumerator();
			while (enumerator.MoveNext())
			{
				InventoryBuffer current = enumerator.Current;
				if (current.ItemType == item)
				{
					num += current.Amount;
				}
			}
			return num;
		}

		public DynamicBuffer<InventoryBuffer> GetInventory()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EntityManager entityManager = G.EntityManager;
				DynamicBuffer<InventoryInstanceElement> buffer = ((EntityManager)(ref entityManager)).GetBuffer<InventoryInstanceElement>(Character);
				entityManager = G.EntityManager;
				return ((EntityManager)(ref entityManager)).GetBuffer<InventoryBuffer>(buffer[0].ExternalInventoryEntity._Entity);
			}
			catch
			{
			}
			return default(DynamicBuffer<InventoryBuffer>);
		}

		public void GiveEquipItem(PrefabGUID prefabGUID)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			GiveDebugEvent val = default(GiveDebugEvent);
			val.Amount = 1;
			val.PrefabGuid = prefabGUID;
			GiveDebugEvent val2 = val;
			G.DebugSystem.GiveEvent(User.Index, ref val2);
		}

		public AddItemResponse GiveItem(PrefabGUID itemGUID, int amount)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			AddItemSettings val = default(AddItemSettings);
			val.ItemDataMap = G.GameData.ItemHashLookupMap;
			val.EntityManager = G.EntityManager;
			val.DropRemainder = false;
			val.EquipIfPossible = false;
			val.OnlyCheckOneSlot = false;
			val.OnlyFillEmptySlots = false;
			return InventoryUtilitiesServer.TryAddItem(val, Character, itemGUID, amount);
		}

		public AddItemResponse GiveItemAtSlot(PrefabGUID itemGUID, int amount, int slotID)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			AddItemSettings val = default(AddItemSettings);
			val.ItemDataMap = G.GameData.ItemHashLookupMap;
			val.EntityManager = G.EntityManager;
			val.DropRemainder = false;
			val.EquipIfPossible = false;
			val.OnlyCheckOneSlot = false;
			val.OnlyFillEmptySlots = false;
			val.StartIndex = new Nullable_Unboxed<int>
			{
				has_value = NativeBoolean.op_Implicit(true),
				value = slotID
			};
			return InventoryUtilitiesServer.TryAddItem(val, Character, itemGUID, amount);
		}

		public void FullyRestore()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			SetHealth(100f);
			ResetCooldowns();
			RemoveBuff(Database.BuffGUID.InCombat_PvP);
		}

		public void SetHealth(float healthPercentage, float maxRecoveryHealth = 100f)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			try
			{
				healthPercentage = Math.Clamp(healthPercentage, 0f, 100f);
				maxRecoveryHealth = Math.Clamp(maxRecoveryHealth, 0f, 100f);
				Health data = Character.GetData<Health>();
				data.Value = healthPercentage / 100f * ModifiableFloat.op_Implicit(data.MaxHealth);
				data.MaxRecoveryHealth = maxRecoveryHealth / 100f * ModifiableFloat.op_Implicit(data.MaxHealth);
				Character.SetData<Health>(data);
			}
			catch
			{
			}
		}

		public void ResetCooldowns()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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)
			EntityManager entityManager = G.EntityManager;
			DynamicBuffer<AbilityGroupSlotBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<AbilityGroupSlotBuffer>(Character);
			for (int i = 0; i < buffer.Length; i++)
			{
				Entity entity = buffer[i].GroupSlotEntity._Entity;
				entityManager = G.EntityManager;
				Entity entity2 = ((EntityManager)(ref entityManager)).GetComponentData<AbilityGroupSlot>(entity).StateEntity._Entity;
				if (entity2.GetPrefabGUID().GuidHash != 0)
				{
					entityManager = G.EntityManager;
					DynamicBuffer<AbilityStateBuffer> buffer2 = ((EntityManager)(ref entityManager)).GetBuffer<AbilityStateBuffer>(entity2);
					for (int j = 0; j < buffer2.Length; j++)
					{
						Entity entity3 = buffer2[j].StateEntity._Entity;
						entityManager = G.EntityManager;
						AbilityCooldownState componentData = ((EntityManager)(ref entityManager)).GetComponentData<AbilityCooldownState>(entity3);
						componentData.CooldownEndTime = 0.0;
						entityManager = G.EntityManager;
						((EntityManager)(ref entityManager)).SetComponentData<AbilityCooldownState>(entity3, componentData);
					}
				}
			}
		}

		public void RemoveBuff(PrefabGUID buffGUID)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Entity val = default(Entity);
			if (BuffUtility.TryGetBuff(G.EntityManager, Character, buffGUID, ref val))
			{
				DestroyUtility.CreateDestroyEvent(G.EntityManager, val, (DestroyReason)0, (DestroyDebugReason)13);
			}
		}

		public static Player FromName(string searchName, bool requiresOnline = true)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			string text = searchName.ToLower();
			int num = 0;
			Player player = new Player();
			Player result = player;
			EntityManager entityManager = G.EntityManager;
			EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
			Enumerator<Entity> enumerator = ((EntityQuery)(ref val)).ToEntityArray((Allocator)2).GetEnumerator();
			while (enumerator.MoveNext())
			{
				User data = enumerator.Current.GetData<User>();
				if (requiresOnline && !data.IsConnected)
				{
					continue;
				}
				string text2 = ((object)(FixedString64)(ref data.CharacterName)).ToString().ToLower();
				if (text2.Contains(text))
				{
					num++;
					result = FromCharacter(data.LocalCharacter._Entity);
					if (text2 == text)
					{
						break;
					}
				}
			}
			if (num == 0)
			{
				player.InvalidReason = "Specified player not found";
				return player;
			}
			if (num > 1)
			{
				player.InvalidReason = "Multiple players matching criteria found";
				return player;
			}
			return result;
		}

		public void Kick()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			User user = User;
			int index = user.Index;
			UserEntity.GetData<NetworkId>();
			EntityManager entityManager = G.EntityManager;
			Entity entity = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.ReadOnly<NetworkEventType>(),
				ComponentType.ReadOnly<SendEventToUser>(),
				ComponentType.ReadOnly<KickEvent>()
			});
			KickEvent component = new KickEvent
			{
				PlatformId = user.PlatformId
			};
			entity.SetData<SendEventToUser>(new SendEventToUser
			{
				UserIndex = index
			});
			entity.SetData<NetworkEventType>(new NetworkEventType
			{
				EventId = NetworkEvents.EventId_KickEvent,
				IsAdminEvent = false,
				IsDebugEvent = false
			});
			entity.SetData<KickEvent>(component);
		}

		public bool CanTarget(Player target)
		{
			return true;
		}

		public void Ban()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			KickBanSystem_Server existingSystem = G.World.GetExistingSystem<KickBanSystem_Server>();
			existingSystem._RemoteBanList.Add(SteamID64);
			existingSystem._LocalBanList.Add(SteamID64);
			User user = User;
			int index = user.Index;
			EntityManager entityManager = G.EntityManager;
			Entity entity = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.ReadOnly<NetworkEventType>(),
				ComponentType.ReadOnly<SendEventToUser>(),
				ComponentType.ReadOnly<BanEvent>()
			});
			BanEvent component = new BanEvent
			{
				PlatformId = user.PlatformId,
				Unban = false
			};
			entity.SetData<SendEventToUser>(new SendEventToUser
			{
				UserIndex = index
			});
			entity.SetData<NetworkEventType>(new NetworkEventType
			{
				EventId = NetworkEvents.EventId_KickEvent,
				IsAdminEvent = false,
				IsDebugEvent = false
			});
			entity.SetData<BanEvent>(component);
			existingSystem._RemoteBanList.Save();
			existingSystem._LocalBanList.Save();
		}

		public void Unban()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			User user = User;
			int index = user.Index;
			KickBanSystem_Server existingSystem = G.World.GetExistingSystem<KickBanSystem_Server>();
			existingSystem._RemoteBanList.Remove(SteamID64);
			existingSystem._LocalBanList.Remove(SteamID64);
			EntityManager entityManager = G.EntityManager;
			Entity entity = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.ReadOnly<NetworkEventType>(),
				ComponentType.ReadOnly<SendEventToUser>(),
				ComponentType.ReadOnly<BanEvent>()
			});
			BanEvent component = new BanEvent
			{
				PlatformId = user.PlatformId,
				Unban = true
			};
			entity.SetData<SendEventToUser>(new SendEventToUser
			{
				UserIndex = index
			});
			entity.SetData<NetworkEventType>(new NetworkEventType
			{
				EventId = NetworkEvents.EventId_KickEvent,
				IsAdminEvent = false,
				IsDebugEvent = false
			});
			entity.SetData<BanEvent>(component);
			existingSystem._RemoteBanList.Save();
			existingSystem._LocalBanList.Save();
		}
	}
	public static class Resources
	{
		public static string GetString(string resourceName)
		{
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string x) => x.Contains(resourceName), "");
				if (Utility.IsNullOrWhiteSpace(text))
				{
					return string.Empty;
				}
				using Stream stream = executingAssembly.GetManifestResourceStream(text);
				using StreamReader streamReader = new StreamReader(stream);
				return streamReader.ReadToEnd();
			}
			catch
			{
				return "Error loading resource " + resourceName;
			}
		}
	}
	[HarmonyPatch(typeof(SunSystem), "OnUpdate")]
	public static class Time
	{
		public static Dictionary<string, Timer> ActiveTimers = new Dictionary<string, Timer>();

		public static List<Timer> AnonymousTimers = new List<Timer>();

		private static bool FirstTick = true;

		public static Stopwatch internalClock { get; private set; } = new Stopwatch();


		public static TimeSpan Elapsed => internalClock.Elapsed;

		[HarmonyPrefix]
		private static void Prefix(SunSystem __instance)
		{
			if (FirstTick)
			{
				internalClock.Start();
				Event.Fire(Events.Load);
				FirstTick = false;
			}
			else if (internalClock.IsRunning)
			{
				HandleTimers();
			}
		}

		private static void HandleTimers()
		{
			List<string> list = new List<string>();
			foreach (var (item, timer2) in ActiveTimers)
			{
				try
				{
					timer2.Tick();
					if (timer2.RepetitionsLeft == 0)
					{
						list.Add(item);
					}
				}
				catch (Exception exception)
				{
					if (timer2.DestroyOnError)
					{
						list.Add(item);
					}
					Output.LogError("TimerTickError-" + timer2.Identifier, exception, $"DestroyOnError={timer2.DestroyOnError}; interval={timer2.Interval.TotalMilliseconds}ms; RepetitionsLeft={timer2.RepetitionsLeft}");
				}
			}
			foreach (string item2 in list)
			{
				Timer.Destroy(item2);
			}
			foreach (Timer anonymousTimer in AnonymousTimers)
			{
				try
				{
					anonymousTimer.Tick();
				}
				catch (Exception exception2)
				{
					Output.LogError("TimerTickError-" + anonymousTimer.Identifier, exception2, $"DestroyOnError={anonymousTimer.DestroyOnError}; interval={anonymousTimer.Interval.TotalMilliseconds}ms; RepetitionsLeft={anonymousTimer.RepetitionsLeft}");
					if (anonymousTimer.DestroyOnError)
					{
						anonymousTimer.RepetitionsLeft = 0;
					}
				}
			}
			AnonymousTimers.RemoveAll((Timer x) => x.RepetitionsLeft == 0);
		}
	}
	public class Timer
	{
		public TimeSpan Interval;

		public int RepetitionsLeft;

		public bool DestroyOnError = true;

		private static int AnonymousCounter = 1;

		private TimeSpan NextTick;

		public Action OnTick { get; private set; }

		public string Identifier { get; private set; }

		public static Timer Create(string identifier, TimeSpan interval, Action onTick, int repetitions = -1)
		{
			Timer timer = new Timer();
			timer.Identifier = identifier;
			timer.Interval = interval;
			timer.OnTick = onTick;
			timer.RepetitionsLeft = repetitions;
			timer.NextTick = Time.Elapsed + timer.Interval;
			Destroy(identifier);
			Time.ActiveTimers.Add(identifier, timer);
			return timer;
		}

		public static Timer Create(string identifier, double intervalInSeconds, Action onTick, int repetitions = -1)
		{
			return Create(identifier, TimeSpan.FromSeconds(intervalInSeconds), onTick, repetitions);
		}

		public static Timer CreateAnonymous(TimeSpan interval, Action onTick, int repetitions = -1)
		{
			Timer timer = new Timer();
			timer.Identifier = "AnonymousTimer" + AnonymousCounter;
			timer.Interval = interval;
			timer.OnTick = onTick;
			timer.RepetitionsLeft = repetitions;
			timer.NextTick = Time.Elapsed + timer.Interval;
			Time.AnonymousTimers.Add(timer);
			AnonymousCounter++;
			return timer;
		}

		public void Tick()
		{
			if (RepetitionsLeft != 0 && Time.Elapsed >= NextTick)
			{
				NextTick += Interval;
				if (RepetitionsLeft > 0)
				{
					RepetitionsLeft--;
				}
				OnTick();
			}
		}

		public static void Destroy(string identifier)
		{
			if (Time.ActiveTimers.ContainsKey(identifier))
			{
				Time.ActiveTimers.Remove(identifier);
			}
		}
	}
	public static class Delay
	{
		public static void Action(TimeSpan delay, Action action)
		{
			Timer.CreateAnonymous(delay, action, 1);
		}

		public static void Action(double delayInSeconds, Action action)
		{
			Action(TimeSpan.FromSeconds(delayInSeconds), action);
		}
	}
	internal static class VectorExtensions
	{
		public static double Distance(this float3 pos1, float3 pos2)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			return Math.Sqrt(Math.Pow(pos1.x - pos2.x, 2.0) + Math.Pow(pos1.z - pos2.z, 2.0));
		}
	}
	public class BuildConfig
	{
		public const string PackageID = "DojoArenaKT";

		public const string Name = "DojoArenaKT";

		public const string Version = "indev1.13";
	}
	[BepInPlugin("DojoArenaKT", "DojoArenaKT", "indev1.13")]
	[Reloadable]
	public class Main : BasePlugin
	{
		public static Main Plugin;

		public static Harmony harmony;

		public const string Folder = "BepInEx/Arena/";

		public static bool FirstTimeLoaded;

		[EventSubscriber(Events.Load, 9001)]
		public static void WelcomeMessage()
		{
			ConsoleManager.SetConsoleTitle("Welcome to The Dojo: Arena - by KT & Paps");
			ConsoleManager.ConsoleStream?.Write(Environment.NewLine);
			int num = 0;
			ConsoleColor[] array = new ConsoleColor[6]
			{
				ConsoleColor.Red,
				ConsoleColor.Yellow,
				ConsoleColor.Green,
				ConsoleColor.Blue,
				ConsoleColor.Blue,
				ConsoleColor.Magenta
			};
			string @string = Resources.GetString("WelcomeMessage");
			for (int i = 0; i < @string.Length; i++)
			{
				char value = @string[i];
				ConsoleManager.SetConsoleColor(array[num]);
				ConsoleManager.ConsoleStream?.Write(value);
				ConsoleManager.SetConsoleColor(ConsoleColor.Gray);
				if (value.ToString() == Environment.NewLine)
				{
					num = 0;
				}
				num++;
				if (num == array.Length)
				{
					num = 0;
				}
			}
		}

		public override void Load()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			CultureInfo.CurrentCulture = new CultureInfo("en-US", useUserOverride: false);
			Stopwatch stopwatch = new Stopwatch();
			stopwatch.Start();
			Plugin = this;
			Output.Logger = ((BasePlugin)this).Log;
			harmony = new Harmony("DojoArenaKT");
			harmony.PatchAll(Assembly.GetExecutingAssembly());
			G.SetupAttributedMethodList();
			Event.RegisterEvents();
			Event.Fire(Events.Preload);
			Version version = default(Version);
			Harmony.VersionInfo(ref version);
			Output.Log($"Arena-{"indev1.13"}/Harmony{version.ToString()} loaded in {Math.Round(stopwatch.Elapsed.TotalSeconds, 2)} seconds.", (LogLevel)4);
			Output.Log("Developed by Killing Torcher & Paps", (LogLevel)4);
			stopwatch.Stop();
		}

		public override bool Unload()
		{
			Event.Fire(Events.Unload);
			((BasePlugin)this).Config.Clear();
			harmony.UnpatchSelf();
			return true;
		}

		[EventSubscriber(Events.BootstrapStart, 0)]
		public static void ServerStarted()
		{
			FirstTimeLoaded = true;
			Output.Log("Server has started.", (LogLevel)4);
		}

		[EventSubscriber(Events.BootstrapQuit, 0)]
		public static void GoodbyeMessage()
		{
			Time.internalClock.Stop();
			Output.Log($"Server shutting down gracefully after {Math.Floor(Time.internalClock.Elapsed.TotalSeconds)} seconds of operation!", (LogLevel)4);
		}
	}
	[HarmonyPatch(typeof(DeathEventListenerSystem), "OnUpdate")]
	public class DeathEventListener
	{
		[HarmonyPostfix]
		public static void Postfix(DeathEventListenerSystem __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			EntityQuery deathEventQuery = __instance._DeathEventQuery;
			Enumerator<DeathEvent> enumerator = ((EntityQuery)(ref deathEventQuery)).ToComponentDataArray<DeathEvent>((Allocator)2).GetEnumerator();
			while (enumerator.MoveNext())
			{
				DeathEvent current = enumerator.Current;
				try
				{
					Player player = Player.FromCharacter(current.Died);
					if (player.IsValid)
					{
						player.Respawn();
					}
				}
				catch (Exception exception)
				{
					Output.LogError("DeathEventListenerPostfix", exception);
				}
			}
		}
	}
	[HarmonyPatch(typeof(VampireDownedServerEventSystem), "OnUpdate")]
	public class VampireDownedServerEventSystem_Patch
	{
		public static void Postfix(VampireDownedServerEventSystem __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
			EntityQuery _OnUpdate_LambdaJob0_entityQuery = __instance.__OnUpdate_LambdaJob0_entityQuery;
			Enumerator<Entity> enumerator = ((EntityQuery)(ref _OnUpdate_LambdaJob0_entityQuery)).ToEntityArray((Allocator)2).GetEnumerator();
			Entity characterEntity = default(Entity);
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				try
				{
					if (VampireDownedServerEventSystem.TryFindRootOwner(current, 1, entityManager, ref characterEntity))
					{
						_ = Player.FromCharacter(characterEntity).IsValid;
					}
				}
				catch (Exception exception)
				{
					Output.LogError("VampireDownedServerEvent", exception, ((object)(Entity)(ref current)).ToString());
				}
			}
		}
	}
	[HarmonyPatch(typeof(GameBootstrap), "Start")]
	public static class GameBootstrapStart
	{
		[HarmonyPrefix]
		public static void Postfix()
		{
			Event.Fire(Events.BootstrapStart);
		}
	}
	[HarmonyPatch(typeof(GameBootstrap), "OnApplicationQuit")]
	public static class GameBootstrapQuit
	{
		public static void Prefix()
		{
			Event.Fire(Events.BootstrapQuit);
		}
	}
	[HarmonyPatch(typeof(PlaceTileModelSystem), "OnUpdate")]
	public static class BuildingPermissions
	{
		[HarmonyPrefix]
		public static bool Prefix(PlaceTileModelSystem __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EntityQuery val = __instance._DismantleTileQuery;
				NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray((Allocator)2);
				if (val2.Length > 0)
				{
					Enumerator<Entity> enumerator = val2.GetEnumerator();
					while (enumerator.MoveNext())
					{
						Entity current = enumerator.Current;
						Player player = Player.FromCharacter(current.GetData<FromCharacter>().Character);
						if (!player.IsAdmin)
						{
							player.Message(Color.Red + "Non-admins are not allowed to dismantle buildings.");
							current.Destroy();
							return false;
						}
					}
				}
				val = __instance._BuildTileQuery;
				NativeArray<Entity> val3 = ((EntityQuery)(ref val)).ToEntityArray((Allocator)2);
				if (val3.Length > 0)
				{
					Enumerator<Entity> enumerator = val3.GetEnumerator();
					while (enumerator.MoveNext())
					{
						Entity current2 = enumerator.Current;
						Player player2 = Player.FromCharacter(current2.GetData<FromCharacter>().Character);
						if (!player2.IsAdmin)
						{
							player2.Message(Color.Red + "Non-admins are not allowed to build.");
							current2.Destroy();
							return false;
						}
					}
				}
				val = __instance._MoveTileQuery;
				NativeArray<Entity> val4 = ((EntityQuery)(ref val)).ToEntityArray((Allocator)2);
				if (val4.Length > 0)
				{
					Enumerator<Entity> enumerator = val4.GetEnumerator();
					while (enumerator.MoveNext())
					{
						Entity current3 = enumerator.Current;
						Player player3 = Player.FromCharacter(current3.GetData<FromCharacter>().Character);
						if (!player3.IsAdmin)
						{
							player3.Message(Color.Red + "Non-admins are not allowed to move buildings.");
							current3.Destroy();
							return false;
						}
					}
				}
				val = __instance._BuildWallpaperQuery;
				NativeArray<Entity> val5 = ((EntityQuery)(ref val)).ToEntityArray((Allocator)2);
				if (val5.Length > 0)
				{
					Enumerator<Entity> enumerator = val5.GetEnumerator();
					while (enumerator.MoveNext())
					{
						Entity current4 = enumerator.Current;
						Player player4 = Player.FromCharacter(current4.GetData<FromCharacter>().Character);
						if (!player4.IsAdmin)
						{
							player4.Message(Color.Red + "Non-admins are not allowed to change wallpapers.");
							current4.Destroy();
							return false;
						}
					}
				}
			}
			catch (Exception exception)
			{
				Output.LogError("DismantleTileOverrides", exception);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ChatMessageSystem), "OnUpdate")]
	public class ChatMessage
	{
		[HarmonyPrefix]
		public static bool Prefix(ChatMessageSystem __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EntityQuery _ChatMessageJob_entityQuery = __instance.__ChatMessageJob_entityQuery;
				Enumerator<Entity> enumerator = ((EntityQuery)(ref _ChatMessageJob_entityQuery)).ToEntityArray((Allocator)2).GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					Player player = Player.FromCharacter(current.GetData<FromCharacter>().Character);
					ChatMessageEvent data = current.GetData<ChatMessageEvent>();
					if (!PlayerChatMessage(player, data))
					{
						current.Destroy();
						return false;
					}
				}
			}
			catch (Exception exception)
			{
				Output.LogError("ChatMessagePatch-Prefix", exception);
			}
			return true;
		}

		public static bool PlayerChatMessage(Player player, ChatMessageEvent message)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if (!player.IsValid)
			{
				return false;
			}
			string text = ((object)(FixedString512)(ref message.MessageText)).ToString();
			Output.Log($"[{player.SteamID64}] [{Enum.GetName<ChatMessageType>(message.MessageType)}] {player.CharacterData.Name}: {text}", (LogLevel)8, "ChatLog");
			if (text.Length == 0)
			{
				return false;
			}
			try
			{
				if (Command.InterceptCommand(player, text))
				{
					return false;
				}
			}
			catch (Exception exception)
			{
				Output.LogError("Command.InterceptCommand", exception, $"Message from {player.LongName} with text '{text}'");
			}
			return true;
		}
	}
	public static class Command
	{
		public static Dictionary<string, CommandAttribute> Lookup = new Dictionary<string, CommandAttribute>();

		public static List<CommandAttribute> SortedList = new List<CommandAttribute>();

		public const string UnknownCommand = "Error: Unknown command. Use <color=#ffffffff>.help</color> for a list of commands.";

		public const string Error = "Fatal Error: There was a fatal exception during your use of that command. Please notify a developer.";

		public const string PermissionCheckFailed = "Error: You do not have permission to run this command.";

		public static bool ValidateCommandMethod(CommandAttribute attribute)
		{
			ParameterInfo[] parameters = attribute.Method.GetParameters();
			switch (parameters.Length)
			{
			case 0:
				attribute.Parameters = CommandParameters.None;
				return true;
			case 1:
				if (parameters[0].ParameterType == typeof(Player))
				{
					attribute.Parameters = CommandParameters.Player;
					return true;
				}
				return false;
			case 2:
				if (parameters[0].ParameterType != typeof(Player))
				{
					return false;
				}
				if (parameters[1].ParameterType == typeof(List<string>))
				{
					attribute.Parameters = CommandParameters.PlayerAndArgs;
					return true;
				}
				if (parameters[1].ParameterType == typeof(string))
				{
					attribute.Parameters = CommandParameters.PlayerAndFullArgText;
					return true;
				}
				return false;
			default:
				return false;
			}
		}

		[EventSubscriber(Events.Load, 0)]
		public static void RegisterCommands()
		{
			if (!G.MethodsWithAttributes.ContainsKey(typeof(CommandAttribute)))
			{
				return;
			}
			foreach (var item2 in G.MethodsWithAttributes[typeof(CommandAttribute)])
			{
				MethodInfo item = item2.Method;
				CommandAttribute commandAttribute = (CommandAttribute)item2.Attribute;
				commandAttribute.Method = item;
				commandAttribute.Name = commandAttribute.Name.ToLower().Replace(" ", "");
				string name = commandAttribute.Name;
				if (string.IsNullOrWhiteSpace(name))
				{
					continue;
				}
				if (!ValidateCommandMethod(commandAttribute))
				{
					Output.LogError("Command-ValidationFailed", "Command " + name + " has failed method validation and may be inappropriately defined.", "MethodName = " + item.Name);
					continue;
				}
				if (Lookup.ContainsKey(name))
				{
					Output.LogError("Command-NameTaken", "The command name '" + name + "' was already taken in lookup by a pre-existing command!", $"Method={commandAttribute.Method.Name}, Usage={commandAttribute.Usage}, Desc={commandAttribute.Description}");
					continue;
				}
				Lookup.Add(name, commandAttribute);
				SortedList.Add(commandAttribute);
				if (commandAttribute.Aliases == null)
				{
					continue;
				}
				string[] aliases = commandAttribute.Aliases;
				foreach (string text in aliases)
				{
					if (Lookup.ContainsKey(text))
					{
						Output.LogError("Command-AliasTaken", $"Command '{name}'s alternative alias '{text}' in lookup by a pre-existing command!", $"Method={commandAttribute.Method.Name}, Usage={commandAttribute.Usage}, Desc={commandAttribute.Description}");
					}
					else
					{
						Lookup.Add(text, commandAttribute);
					}
				}
			}
			SortedList.Sort((CommandAttribute x, CommandAttribute y) => x.Name.CompareTo(y.Name));
		}

		public static void RunCommand(Player player, CommandAttribute command, List<string> parsedArgs, string chatMessage)
		{
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				object obj = null;
				object[] array = null;
				switch (command.Parameters)
				{
				case CommandParameters.None:
					array = null;
					break;
				case CommandParameters.Player:
				{
					object[] array3 = new Player[1] { player };
					array = array3;
					break;
				}
				case CommandParameters.PlayerAndArgs:
					array = new object[2] { player, parsedArgs };
					break;
				case CommandParameters.PlayerAndFullArgText:
				{
					string[] array2 = chatMessage.Trim().Split(' ');
					string text = "";
					if (array2.Length >= 2)
					{
						text = string.Join(' ', array2.Skip(1));
					}
					array = new object[2]
					{
						player,
						text.Trim()
					};
					break;
				}
				default:
					throw new Exception("CommandParameters are invalid. Command may not be properly defined or something may have gone wrong.");
				}
				obj = command.Method.Invoke(null, array);
				string logType = "ChatLog";
				if (command.AdminOnly)
				{
					logType = "AdminLog";
				}
				Output.Log(player.LongName + " executed command: " + chatMessage, (LogLevel)4, logType);
				if (obj != null && obj is string && !string.IsNullOrWhiteSpace((string)obj))
				{
					player.Message(obj);
				}
			}
			catch (Exception exception)
			{
				Output.LogError("Command-ExecutionError", exception, $"Player {player.CharacterData.Name} tried to run '{command.Name}' unsucessfully.");
				player.Message("Fatal Error: There was a fatal exception during your use of that command. Please notify a developer.");
			}
		}

		public static bool InterceptCommand(Player player, string chatMessage)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			char c = chatMessage[0];
			if (chatMessage.Length < 2)
			{
				return false;
			}
			if (!player.CheckValidity())
			{
				return false;
			}
			if (c != '.' && c != '!')
			{
				return false;
			}
			List<string> list = Parse(chatMessage.Remove(0, 1));
			string key = list[0].ToLower();
			list.RemoveAt(0);
			if (!Lookup.ContainsKey(key))
			{
				player.Message("Error: Unknown command. Use <color=#ffffffff>.help</color> for a list of commands.");
				Output.Log(player.LongName + " tried to run non-existent command: " + chatMessage, (LogLevel)4, "AdminLog");
				return true;
			}
			CommandAttribute commandAttribute = Lookup[key];
			if (commandAttribute.AdminOnly && !player.User.IsAdmin)
			{
				player.Message("Error: You do not have permission to run this command.");
				Output.Log(player.LongName + " failed a permission check trying to run: " + chatMessage, (LogLevel)2, "AdminLog");
				return true;
			}
			RunCommand(player, commandAttribute, list, chatMessage);
			return true;
		}

		public static List<string> Parse(string commandText)
		{
			List<string> list = new List<string>();
			char c = ' ';
			int num = 0;
			int num2 = -1;
			bool flag = false;
			StringBuilder stringBuilder = new StringBuilder();
			foreach (char c2 in commandText)
			{
				if (flag)
				{
					if (c2 == ' ' && c == '"' && num2 != num - 1)
					{
						string item = stripQuotes(stringBuilder.ToString());
						list.Add(item);
						stringBuilder.Clear();
						flag = false;
					}
					else
					{
						stringBuilder.Append(c2);
					}
				}
				else if (c2 == ' ' && stringBuilder.Length > 0)
				{
					list.Add(stringBuilder.ToString());
					stringBuilder.Clear();
				}
				else if (c2 != ' ')
				{
					if (c2 == '"')
					{
						flag = true;
						num2 = num;
					}
					stringBuilder.Append(c2);
				}
				num++;
				c = c2;
			}
			if (stringBuilder.Length > 0)
			{
				string text = stringBuilder.ToString();
				if (c == '"' && flag && num2 != num - 1)
				{
					text = stripQuotes(text);
				}
				list.Add(text);
			}
			return list;
		}

		private static string stripQuotes(string quotedString)
		{
			int length = quotedString.Length;
			if (length > 2 && quotedString[0] == '"' && quotedString[length - 1] == '"')
			{
				return quotedString.Remove(length - 1, 1).Remove(0, 1);
			}
			return quotedString;
		}
	}
	public enum CommandParameters
	{
		Invalid,
		None,
		Player,
		PlayerAndArgs,
		PlayerAndFullArgText
	}
	public class CommandAttribute : Attribute
	{
		public string Name = "";

		public string Usage = "";

		public string Description = "";

		public string[] Aliases;

		public bool