VAMP.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Text;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.Gameplay.Systems;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Scripting;
using ProjectM.Shared;
using ProjectM.Shared.Systems;
using ProjectM.Terrain;
using ProjectM.Tiles;
using Stunlock.Core;
using Stunlock.Network;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
using VAMP.Attributes;
using VAMP.Data;
using VAMP.Models;
using VAMP.Patches;
using VAMP.Services;
using VAMP.Structs;
using VAMP.Structs.Settings;
using VAMP.Systems;
using VAMP.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SkyTech6, CrimsonMods")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Versatile API for Modding ProjectM")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0+Branch.master.Sha.c47833f75b00d0d8eaf32f335210e6bd37e67d36.c47833f75b00d0d8eaf32f335210e6bd37e67d36")]
[assembly: AssemblyProduct("VAMP")]
[assembly: AssemblyTitle("VAMP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.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 VAMP
{
	public static class Core
	{
		public static bool hasInitialized = false;

		private static MonoBehaviour monoBehaviour;

		public static World Server { get; } = GetServerWorld() ?? throw new Exception("There is no Server world (yet)...");


		public static EntityManager EntityManager => Server.EntityManager;

		public static SystemService SystemService { get; } = new SystemService(Server);


		public static ServerScriptMapper ServerScriptMapper => SystemService.ServerScriptMapper;

		public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager();

		public static Entity TileModelSpatialLookupSystem { get; private set; }

		public static PlayerService PlayerService { get; private set; }

		public static CastleHeartService CastleHeartService { get; private set; }

		public static CastleTerritoryService CastleTerritoryService { get; private set; }

		public static ClanService ClanService { get; private set; }

		public static ModSystem ModSystem { get; private set; }

		internal static RecordLevelSystem RecordLevelSystem { get; private set; }

		internal static Database Database { get; private set; }

		public static void Initialize()
		{
			//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_0045: Unknown result type (might be due to invalid IL or missing references)
			if (!hasInitialized)
			{
				PlayerService = new PlayerService();
				CastleHeartService = new CastleHeartService();
				CastleTerritoryService = new CastleTerritoryService();
				ClanService = new ClanService();
				ModSystem = new ModSystem();
				TileModelSpatialLookupSystem = EntityUtil.GetEntitiesByComponentTypes<Singleton>((EntityQueryOptions)16)[0];
				hasInitialized = true;
				ServerWipe.WipeDataDetection();
				Database = new Database();
				RecordLevelSystem = new RecordLevelSystem();
				Plugin.OnCoreLoaded?.Invoke();
				Events.OnCoreLoaded?.Invoke();
				StartCoroutine(EventScheduler.ScheduleLoop());
			}
		}

		private static World GetServerWorld()
		{
			return ((IEnumerable<World>)World.s_AllWorlds.ToArray()).FirstOrDefault((Func<World, bool>)((World world) => world.Name == "Server"));
		}

		public static Coroutine StartCoroutine(IEnumerator routine)
		{
			//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_0027: Expected O, but got Unknown
			if ((Object)(object)monoBehaviour == (Object)null)
			{
				GameObject val = new GameObject("FANG");
				monoBehaviour = (MonoBehaviour)(object)val.AddComponent<IgnorePhysicsDebugSystem>();
				Object.DontDestroyOnLoad((Object)val);
			}
			return monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
		}

		public static void StopCoroutine(Coroutine coroutine)
		{
			if (!((Object)(object)monoBehaviour == (Object)null))
			{
				monoBehaviour.StopCoroutine(coroutine);
			}
		}
	}
	public class Events
	{
		public static Action OnCoreLoaded;

		public static Action<bool> OnServerWiped;
	}
	public static class Extensions
	{
		public static string LookupName(this PrefabGUID prefabGuid)
		{
			//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_0014: 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_002c: 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)
			PrefabCollectionSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
			PrefabLookupMap prefabLookupMap = existingSystemManaged._PrefabLookupMap;
			object obj;
			if (!((PrefabLookupMap)(ref prefabLookupMap)).ContainsKey(prefabGuid))
			{
				obj = "GUID Not Found";
			}
			else
			{
				prefabLookupMap = existingSystemManaged._PrefabLookupMap;
				string name = ((PrefabLookupMap)(ref prefabLookupMap)).GetName(prefabGuid);
				PrefabGUID val = prefabGuid;
				obj = name + " " + ((object)(PrefabGUID)(ref val)).ToString();
			}
			return obj.ToString();
		}
	}
	public static class FilePaths
	{
		public static string WipeData => Path.Combine(Paths.ConfigPath, "_WipeData");
	}
	[BepInPlugin("VAMP", "VAMP", "1.3.0")]
	public class Plugin : BasePlugin
	{
		private Harmony _harmony;

		[Obsolete("Use VAMP.Events.OnCoreLoaded instead. Will be removed in a future version.")]
		public static Action OnCoreLoaded;

		public static bool SpawnDebug;

		public static Plugin Instance { get; private set; }

		public static Harmony Harmony => Instance._harmony;

		public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log;

		internal static VSettings Settings { get; private set; }

		internal static VAMPSettings VAMPSettings { get; private set; }

		internal static string ConfigFiles => Path.Combine(Paths.ConfigPath, "VAMP");

		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
			Instance = this;
			Settings = default(VSettings);
			VSettings.InitConfig();
			VAMPSettings = default(VAMPSettings);
			VAMPSettings.InitConfig();
			_harmony = new Harmony("VAMP");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			Events.OnCoreLoaded = (Action)Delegate.Combine(Events.OnCoreLoaded, new Action(Loaded));
		}

		private void Loaded()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			FileWatcherSystem.Initialize();
			if (VAMPSettings.ModProfiler.Value)
			{
				Core.StartCoroutine(DelayStart());
			}
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("VAMP");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.3.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
		}

		private IEnumerator DelayStart()
		{
			yield return (object)new WaitForSeconds(30f);
			foreach (ModInfo item in ModSystem.GetLoadedModsInfo())
			{
				if (!(item.Name == "VAMP"))
				{
					ModProfiler.ProfileAssembly(item.Assembly);
				}
			}
			yield return (object)new WaitForSeconds(30f);
			while (true)
			{
				yield return (object)new WaitForSeconds(30f);
				ModProfiler.DumpStats();
			}
		}

		public override bool Unload()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "VAMP";

		public const string PLUGIN_NAME = "VAMP";

		public const string PLUGIN_VERSION = "1.3.0";
	}
}
namespace VAMP.Utilities
{
	public static class BuffUtil
	{
		private static ServerGameManager ServerGameManager => Core.ServerGameManager;

		private static SystemService SystemService => Core.SystemService;

		private static DebugEventsSystem DebugEventsSystem => SystemService.DebugEventsSystem;

		public static void ModifyBuff(Entity buffEntity, BuffModificationTypes buffModificationTypes, bool overwrite = false)
		{
			//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_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_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_0025: Expected I8, but got Unknown
			//IL_0025: 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)
			buffEntity.Add<BuffModificationFlagData>();
			BuffModificationFlagData componentData = buffEntity.Read<BuffModificationFlagData>();
			if (overwrite)
			{
				componentData.ModificationTypes = 0L;
			}
			ref long modificationTypes = ref componentData.ModificationTypes;
			modificationTypes |= buffModificationTypes;
			buffEntity.Write<BuffModificationFlagData>(componentData);
		}

		public static bool BuffEntity(Entity entity, PrefabGUID buff, out Entity buffEntity, float duration = 0f, bool attemptToPersistThroughDeath = false)
		{
			//IL_0002: 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_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_0011: 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_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_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_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_003b: 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_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_0059: 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_0049: 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_0078: 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_008e: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			ApplyBuffDebugEvent val = default(ApplyBuffDebugEvent);
			val.BuffPrefabGUID = buff;
			ApplyBuffDebugEvent val2 = val;
			FromCharacter val3 = default(FromCharacter);
			val3.User = PlayerService.GetUsersOnline().ToArray()[0];
			val3.Character = entity;
			FromCharacter val4 = val3;
			if (!HasBuff(entity, buff))
			{
				DebugEventsSystem.ApplyBuff(val4, val2);
			}
			ServerGameManager serverGameManager = ServerGameManager;
			if (((ServerGameManager)(ref serverGameManager)).TryGetBuff(entity, PrefabIdentifier.op_Implicit(buff), ref buffEntity))
			{
				if (attemptToPersistThroughDeath || duration == 0f)
				{
					buffEntity.Add<Buff_Persists_Through_Death>();
					buffEntity.Remove<Buff_Destroy_On_Owner_Death>();
					if (buffEntity.Has<RemoveBuffOnGameplayEventEntry>())
					{
						buffEntity.ReadBuffer<RemoveBuffOnGameplayEventEntry>().Clear();
					}
				}
				else if (!attemptToPersistThroughDeath)
				{
					buffEntity.Remove<Buff_Persists_Through_Death>();
					buffEntity.Add<Buff_Destroy_On_Owner_Death>();
				}
				if (duration == 0f)
				{
					if (buffEntity.Has<LifeTime>())
					{
						LifeTime componentData = buffEntity.Read<LifeTime>();
						buffEntity.Remove<Age>();
						componentData.Duration = 0f;
						componentData.EndAction = (LifeTimeEndAction)0;
						buffEntity.Write<LifeTime>(componentData);
					}
				}
				else if (duration > 0f)
				{
					if (buffEntity.Has<Age>())
					{
						Age componentData2 = buffEntity.Read<Age>();
						componentData2.Value = 0f;
						buffEntity.Write<Age>(componentData2);
					}
					if (!buffEntity.Has<LifeTime>())
					{
						buffEntity.Add<LifeTime>();
					}
					buffEntity.Write<LifeTime>(new LifeTime
					{
						EndAction = (LifeTimeEndAction)2,
						Duration = duration
					});
				}
				return true;
			}
			return false;
		}

		public static void ApplyCosmetic(Entity entity, PrefabGUID visual)
		{
			//IL_0002: 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_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_0011: 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_001c: 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_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_002c: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0058: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_009c: 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_00a8: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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)
			ApplyBuffDebugEvent val = default(ApplyBuffDebugEvent);
			val.BuffPrefabGUID = visual;
			ApplyBuffDebugEvent val2 = val;
			FromCharacter val3 = default(FromCharacter);
			val3.Character = entity;
			val3.User = entity;
			FromCharacter val4 = val3;
			DebugEventsSystem.ApplyBuff(val4, val2);
			ServerGameManager serverGameManager = ServerGameManager;
			Entity val5 = default(Entity);
			if (((ServerGameManager)(ref serverGameManager)).TryGetBuff(entity, ((PrefabGUID)(ref val2.BuffPrefabGUID)).ToIdentifier(), ref val5))
			{
				HandleBuffComponent(val5);
				HandleLifetime(val5);
				if (!val5.Has<Buff_Persists_Through_Death>())
				{
					val5.Add<Buff_Persists_Through_Death>();
				}
				RemoveComponent<CreateGameplayEventsOnSpawn>(val5);
				RemoveComponent<GameplayEventListeners>(val5);
				RemoveComponent<RemoveBuffOnGameplayEvent>(val5);
				RemoveComponent<RemoveBuffOnGameplayEventEntry>(val5);
				RemoveComponent<DealDamageOnGameplayEvent>(val5);
				RemoveComponent<HealOnGameplayEvent>(val5);
				RemoveComponent<BloodBuffScript_ChanceToResetCooldown>(val5);
				RemoveComponent<ModifyMovementSpeedBuff>(val5);
				RemoveComponent<ApplyBuffOnGameplayEvent>(val5);
				RemoveComponent<DestroyOnGameplayEvent>(val5);
				RemoveComponent<WeakenBuff>(val5);
				RemoveComponent<ReplaceAbilityOnSlotBuff>(val5);
				RemoveComponent<AmplifyBuff>(val5);
				RemoveComponent<GameplayEventIdMapping>(val5);
			}
		}

		public static void RemoveBuff(Entity entity, PrefabGUID guid)
		{
			//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_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_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<EntityManager>(Core.EntityManager, entity, PrefabIdentifier.op_Implicit(guid), ref val))
			{
				DestroyUtility.Destroy(Core.EntityManager, val, (DestroyDebugReason)13, (string)null, 0);
			}
		}

		public static bool HasBuff(Entity entity, PrefabGUID buff)
		{
			//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_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)
			return BuffUtility.HasBuff<EntityManager>(Core.EntityManager, entity, PrefabIdentifier.op_Implicit(buff));
		}

		private static void RemoveComponent<T>(Entity buff) where T : struct
		{
			//IL_0000: 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)
			if (buff.Has<T>())
			{
				buff.Remove<T>();
			}
		}

		private static void HandleBuffComponent(Entity buff)
		{
			//IL_0000: 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_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_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)
			if (buff.Has<Buff>())
			{
				BuffCategory componentData = buff.Read<BuffCategory>();
				componentData.Groups = (BuffCategoryFlag)0;
				buff.Write<BuffCategory>(componentData);
			}
		}

		private static void HandleLifetime(Entity buff)
		{
			//IL_0000: 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_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_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_0024: Unknown result type (might be due to invalid IL or missing references)
			if (buff.Has<LifeTime>())
			{
				LifeTime componentData = buff.Read<LifeTime>();
				componentData.Duration = -1f;
				componentData.EndAction = (LifeTimeEndAction)0;
				buff.Write<LifeTime>(componentData);
			}
		}
	}
	public static class ChatUtil
	{
		public static readonly int MESSAGE_LIMIT = 460;

		public static void SystemSendUser(User user, string message)
		{
			//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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			foreach (string item in SplitMessage(message, MESSAGE_LIMIT))
			{
				FixedString512Bytes val = FixedString512Bytes.op_Implicit(item);
				ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, user, ref val);
			}
		}

		public static void SystemSendUsers(User[] users, string message)
		{
			//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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = SplitMessage(message, MESSAGE_LIMIT);
			foreach (User val in users)
			{
				foreach (string item in list)
				{
					FixedString512Bytes val2 = FixedString512Bytes.op_Implicit(item);
					ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, val, ref val2);
				}
			}
		}

		public static void SystemSendAll(string message)
		{
			//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_0020: Unknown result type (might be due to invalid IL or missing references)
			foreach (string item in SplitMessage(message, MESSAGE_LIMIT))
			{
				FixedString512Bytes val = FixedString512Bytes.op_Implicit(item);
				ServerChatUtils.SendSystemMessageToAllClients(Core.EntityManager, ref val);
			}
		}

		public static void SystemSendAllExcept(User user, string message)
		{
			//IL_0007: 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_003e: 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_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_004f: 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)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = SplitMessage(message, MESSAGE_LIMIT);
			foreach (Entity item in PlayerService.GetUsersOnline().Where(delegate(Entity x)
			{
				//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_000a: Unknown result type (might be due to invalid IL or missing references)
				User val3 = x.Read<User>();
				return !((User)(ref val3)).Equals(user);
			}).ToList())
			{
				User val = item.Read<User>();
				if (((User)(ref val)).Equals(user))
				{
					continue;
				}
				foreach (string item2 in list)
				{
					FixedString512Bytes val2 = FixedString512Bytes.op_Implicit(item2);
					ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, item.Read<User>(), ref val2);
				}
			}
		}

		public static void SystemSendAllExcept(User[] users, string message)
		{
			//IL_003e: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0062: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = SplitMessage(message, MESSAGE_LIMIT);
			foreach (Entity item in (from x in PlayerService.GetUsersOnline()
				where !users.Contains(x.Read<User>())
				select x).ToList())
			{
				foreach (string item2 in list)
				{
					FixedString512Bytes val = FixedString512Bytes.op_Implicit(item2);
					ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, item.Read<User>(), ref val);
				}
			}
		}

		public static void SystemSendLocal(User user, float3 translation, string message)
		{
			//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_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_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_0044: 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_0050: 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_0069: 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_0078: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = SplitMessage(message, MESSAGE_LIMIT);
			float num = 40f;
			float2 val = default(float2);
			((float2)(ref val))..ctor(translation.x, translation.z);
			foreach (Entity item in PlayerService.GetUsersOnline())
			{
				User val2 = item.Read<User>();
				if (((User)(ref val2)).Equals(user) || !item.TryGetComponent<LocalToWorld>(out LocalToWorld componentData) || !(math.distance(new float2(((LocalToWorld)(ref componentData)).Position.x, ((LocalToWorld)(ref componentData)).Position.z), val) <= num))
				{
					continue;
				}
				foreach (string item2 in list)
				{
					FixedString512Bytes val3 = FixedString512Bytes.op_Implicit(item2);
					ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, item.Read<User>(), ref val3);
				}
			}
		}

		public static void SystemSendTeam(User user, string message)
		{
			//IL_0007: 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_0067: 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_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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = SplitMessage(message, MESSAGE_LIMIT);
			foreach (Entity item in (from x in PlayerService.GetUsersOnline()
				where x.Read<User>().ClanEntity._Entity.Has<ClanTeam>()
				select x).ToList().Where(delegate(Entity x)
			{
				//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_001e: Unknown result type (might be due to invalid IL or missing references)
				User val3 = x.Read<User>();
				return ((Entity)(ref val3.ClanEntity._Entity)).Equals(user.ClanEntity._Entity);
			}).ToList())
			{
				User val = item.Read<User>();
				if (((User)(ref val)).Equals(user))
				{
					continue;
				}
				foreach (string item2 in list)
				{
					FixedString512Bytes val2 = FixedString512Bytes.op_Implicit(item2);
					ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, item.Read<User>(), ref val2);
				}
			}
		}

		public static void SystemSendAdmins(string message)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = SplitMessage(message, MESSAGE_LIMIT);
			foreach (Player item in (from x in PlayerService.GetCachedUsersOnlineAsPlayer()
				where x.IsAdminCapable
				select x).ToList())
			{
				foreach (string item2 in list)
				{
					FixedString512Bytes val = FixedString512Bytes.op_Implicit(item2);
					ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, item.User.Read<User>(), ref val);
				}
			}
		}

		private static List<string> SplitMessage(string message, int maxLength)
		{
			List<string> list = new List<string>();
			if (string.IsNullOrEmpty(message))
			{
				return list;
			}
			if (message.Length <= maxLength)
			{
				list.Add(message);
				return list;
			}
			string[] array = message.Split('\n');
			string text = "";
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				if (text.Length + text2.Length + 1 > maxLength)
				{
					if (!string.IsNullOrEmpty(text))
					{
						list.Add(text.TrimEnd());
						text = "";
					}
					if (text2.Length > maxLength)
					{
						List<string> collection = SplitLongLine(text2, maxLength);
						list.AddRange(collection);
					}
					else
					{
						text = text2 + "\n";
					}
				}
				else
				{
					text = text + text2 + "\n";
				}
			}
			if (!string.IsNullOrEmpty(text))
			{
				list.Add(text.TrimEnd());
			}
			return list;
		}

		private static List<string> SplitLongLine(string line, int maxLength)
		{
			List<string> list = new List<string>();
			string[] array = line.Split(' ');
			string text = "";
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				if (text.Length + text2.Length + 1 > maxLength)
				{
					if (!string.IsNullOrEmpty(text))
					{
						list.Add(text.TrimEnd());
						text = "";
					}
					if (text2.Length > maxLength)
					{
						list.Add(text2.Substring(0, maxLength - 3) + "...");
					}
					else
					{
						text = text2 + " ";
					}
				}
				else
				{
					text = text + text2 + " ";
				}
			}
			if (!string.IsNullOrEmpty(text))
			{
				list.Add(text.TrimEnd());
			}
			return list;
		}

		public static string Color(string text, string hex)
		{
			return $"<color=#{hex.Replace(" ", "").Replace("#", "")}>{text}</color>";
		}
	}
	public static class DevUtil
	{
		public static bool ChatDebugMode;

		public static string[] ChatDebugKeys;

		public static void ChatDebug(string message, string key = null)
		{
			if (ChatDebugMode && !string.IsNullOrEmpty(message) && (string.IsNullOrEmpty(key) || ChatDebugKeys.Contains(key)))
			{
				ChatUtil.SystemSendAll(message);
			}
		}

		public static void Dump(this Entity entity, string filePath)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_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_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_009e: 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)
			Directory.CreateDirectory("VAMPDump");
			filePath = Path.Combine("VAMPDump", filePath);
			File.AppendAllText(filePath, "--------------------------------------------------" + Environment.NewLine);
			File.AppendAllText(filePath, $"Dumping components of {entity}:" + Environment.NewLine);
			EntityManager entityManager = Core.Server.EntityManager;
			Enumerator<ComponentType> enumerator = ((EntityManager)(ref entityManager)).GetComponentTypes(entity, (Allocator)2).GetEnumerator();
			while (enumerator.MoveNext())
			{
				ComponentType current = enumerator.Current;
				File.AppendAllText(filePath, $"{current}" + Environment.NewLine);
			}
			File.AppendAllText(filePath, "--------------------------------------------------" + Environment.NewLine);
			File.AppendAllText(filePath, DumpEntity(entity));
		}

		private static string DumpEntity(Entity entity, bool fullDump = true)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder val = new StringBuilder();
			EntityDebuggingUtility.DumpEntity(Core.Server, entity, fullDump, val);
			return ((Object)val).ToString();
		}
	}
	public static class EntityUtil
	{
		public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			byte[] array = StructureToByteArray(componentData);
			int num = Marshal.SizeOf<T>();
			fixed (byte* ptr = array)
			{
				EntityManager entityManager = Core.EntityManager;
				((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
			}
		}

		public static byte[] StructureToByteArray<T>(T structure) where T : struct
		{
			int num = Marshal.SizeOf(structure);
			byte[] array = new byte[num];
			IntPtr intPtr = Marshal.AllocHGlobal(num);
			Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true);
			Marshal.Copy(intPtr, array, 0, num);
			Marshal.FreeHGlobal(intPtr);
			return array;
		}

		public unsafe static T Read<T>(this Entity entity) where T : struct
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = Core.EntityManager;
			return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex)));
		}

		public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct
		{
			//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)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = Core.Server.EntityManager;
			return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity, false);
		}

		public static bool Has<T>(this Entity entity)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = Core.EntityManager;
			return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
		}

		public static void Add<T>(this Entity entity)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = Core.EntityManager;
			((EntityManager)(ref entityManager)).AddComponent(entity, val);
		}

		public static void Remove<T>(this Entity entity)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = Core.EntityManager;
			((EntityManager)(ref entityManager)).RemoveComponent(entity, val);
		}

		public static bool TryGetComponent<T>(this Entity entity, out T componentData) where T : struct
		{
			//IL_0007: 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)
			componentData = default(T);
			if (entity.Has<T>())
			{
				componentData = entity.Read<T>();
				return true;
			}
			return false;
		}

		public static void DestroyWithReason(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_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_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)
			EntityManager entityManager = Core.EntityManager;
			((EntityManager)(ref entityManager)).AddComponent<Disabled>(entity);
			DestroyUtility.CreateDestroyEvent(Core.EntityManager, entity, (DestroyReason)0, (DestroyDebugReason)32);
			DestroyUtility.Destroy(Core.EntityManager, entity, (DestroyDebugReason)0, (string)null, 0);
		}

		public static void KillOrDestroy(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_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)
			StatChangeUtility.KillOrDestroyEntity(Core.EntityManager, entity, entity, entity, 0.0, (StatChangeReason)0, true);
		}

		public static bool Exists(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)
			EntityManager entityManager = Core.EntityManager;
			return ((EntityManager)(ref entityManager)).Exists(entity);
		}

		public static bool Disabled(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return entity.Has<Disabled>();
		}

		public static NativeArray<Entity> GetEntitiesByComponentType<T1>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false)
		{
			//IL_0001: 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_000b: 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_0010: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0044: 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_0059: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			EntityQueryOptions val = (EntityQueryOptions)0;
			if (includeAll)
			{
				val = (EntityQueryOptions)(val | 0xC3);
			}
			if (includeDisabled)
			{
				val = (EntityQueryOptions)(val | 2);
			}
			if (includeSpawn)
			{
				val = (EntityQueryOptions)(val | 0x40);
			}
			if (includePrefab)
			{
				val = (EntityQueryOptions)(val | 1);
			}
			if (includeDestroyed)
			{
				val = (EntityQueryOptions)(val | 0x80);
			}
			EntityQueryDesc val2 = new EntityQueryDesc();
			val2.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1]
			{
				new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0)
			});
			val2.Options = val;
			EntityQueryDesc val3 = val2;
			EntityManager entityManager = Core.EntityManager;
			EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val3 });
			return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
		}

		public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false)
		{
			//IL_0001: 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_000b: 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_0010: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0044: 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_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_006b: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			EntityQueryOptions val = (EntityQueryOptions)0;
			if (includeAll)
			{
				val = (EntityQueryOptions)(val | 0xC3);
			}
			if (includeDisabled)
			{
				val = (EntityQueryOptions)(val | 2);
			}
			if (includeSpawn)
			{
				val = (EntityQueryOptions)(val | 0x40);
			}
			if (includePrefab)
			{
				val = (EntityQueryOptions)(val | 1);
			}
			if (includeDestroyed)
			{
				val = (EntityQueryOptions)(val | 0x80);
			}
			EntityQueryDesc val2 = new EntityQueryDesc();
			val2.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2]
			{
				new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0),
				new ComponentType(Il2CppType.Of<T2>(), (AccessMode)0)
			});
			val2.Options = val;
			EntityQueryDesc val3 = val2;
			EntityManager entityManager = Core.EntityManager;
			EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val3 });
			return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
		}

		public static NativeArray<Entity> GetEntitiesByComponentTypes<T1>(EntityQueryOptions queryOptions = 0)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1]
			{
				new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0)
			});
			val.Options = queryOptions;
			EntityQueryDesc val2 = val;
			EntityManager entityManager = Core.EntityManager;
			EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val2 });
			NativeArray<Entity> result = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			((EntityQuery)(ref val3)).Dispose();
			return result;
		}

		public unsafe static NativeArray<Entity> GetEntitiesInArea(BoundsMinMax area, TileType tileType)
		{
			//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_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_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_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)
			SystemState state = *Core.TileModelSpatialLookupSystem.Read<SystemInstance>().state;
			TileModelSpatialLookupSystemData val = TileModelSpatialLookupSystemData.Create(ref state, 32, 32);
			TileModelSpatialLookup spatialLookupAndComplete = ((TileModelSpatialLookupSystemData)(ref val)).GetSpatialLookupAndComplete(ref state);
			((TileModelSpatialLookup)(ref spatialLookupAndComplete)).GetEntities(ref area, tileType);
			return spatialLookupAndComplete.Results.ToArray(AllocatorHandle.op_Implicit((Allocator)2));
		}

		public static Entity EntityFromGUID(PrefabGUID guid)
		{
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			PrefabLookupMap prefabLookupMap = Core.ServerScriptMapper._PrefabCollectionSystem._PrefabLookupMap;
			return ((PrefabLookupMap)(ref prefabLookupMap))[guid];
		}

		public static bool TryGetEntityFromGUID(PrefabGUID guid, out Entity prefabEntity)
		{
			//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)
			return Core.ServerScriptMapper._PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(guid, ref prefabEntity);
		}

		public static PrefabGUID GetGUID(this Entity entity)
		{
			//IL_0000: 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_0008: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			if (entity.Exists() && entity.Has<PrefabGUID>())
			{
				return entity.Read<PrefabGUID>();
			}
			return PrefabGUID.Empty;
		}

		public static NativeArray<Entity> SortEntitiesByDistance(NativeArray<Entity> entities, float3 position)
		{
			//IL_001a: 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_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_0034: 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_009b: 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)
			(Entity, float)[] array = new(Entity, float)[entities.Length];
			for (int i = 0; i < entities.Length; i++)
			{
				float item = float.MaxValue;
				if (entities[i].Has<LocalToWorld>())
				{
					LocalToWorld val = entities[i].Read<LocalToWorld>();
					item = math.distance(position, ((LocalToWorld)(ref val)).Position);
				}
				array[i] = (entities[i], item);
			}
			Array.Sort(array, ((Entity entity, float distance) a, (Entity entity, float distance) b) => a.distance.CompareTo(b.distance));
			for (int j = 0; j < entities.Length; j++)
			{
				entities[j] = array[j].Item1;
			}
			return entities;
		}

		public static bool IsInBase(Entity entity, out Entity territory, out TerritoryAlignment territoryAlignment, bool requireRoom = false)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0025: 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_002b: 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_004a: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			territoryAlignment = TerritoryAlignment.None;
			if (CastleTerritoryService.TryGetCastleTerritory(entity, out territory))
			{
				Entity castleHeart = territory.Read<CastleTerritory>().CastleHeart;
				if (castleHeart.Exists())
				{
					if (Team.IsAllies(castleHeart.Read<Team>(), entity.Read<Team>()))
					{
						territoryAlignment = TerritoryAlignment.Friendly;
					}
					else
					{
						territoryAlignment = TerritoryAlignment.Enemy;
					}
				}
				else
				{
					territoryAlignment = TerritoryAlignment.Neutral;
				}
				if (!requireRoom)
				{
					return true;
				}
				if (TryGetFloorEntityBelowEntity(entity, out var floorEntity) && floorEntity.Has<CastleRoomConnection>())
				{
					CastleRoom val = floorEntity.Read<CastleRoomConnection>().RoomEntity._Entity.Read<CastleRoom>();
					return ((CastleRoom)(ref val)).IsEnclosedRoom;
				}
				return false;
			}
			return false;
		}

		public static bool TryGetFloorEntityBelowEntity(Entity entity, out Entity floorEntity)
		{
			//IL_0001: 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_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_000e: 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_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_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_004a: 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_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_0060: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			floorEntity = default(Entity);
			TilePosition val = entity.Read<TilePosition>();
			Enumerator<Entity> enumerator = GetEntitiesInArea(entity.Read<TileBounds>().Value, (TileType)8).GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				TilePosition val2 = current.Read<TilePosition>();
				if (((TilePosition)(ref val2)).HeightLevel == ((TilePosition)(ref val)).HeightLevel && current.Has<CastleFloor>() && !current.Has<CastleStairs>())
				{
					TileBounds val3 = current.Read<TileBounds>();
					if (((BoundsMinMax)(ref val3.Value)).Contains(val.Tile))
					{
						floorEntity = current;
						return true;
					}
				}
			}
			return false;
		}

		public static Entity GetHoveredTileModel<T>(Entity 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)
			//IL_0007: 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_000e: 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_0015: 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_0038: 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_0048: 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_0064: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00be: 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_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)
			//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_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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			EntityInput val = User.Read<EntityInput>();
			float3 aimPosition = val.AimPosition;
			int2 val2 = CastleTerritoryService.ConvertPosToBlockCoord(aimPosition);
			if (val.HoveredEntity.Exists() && val.HoveredEntity.Has<T>())
			{
				return val.HoveredEntity;
			}
			BoundsMinMax area = default(BoundsMinMax);
			area.Min = new int2(val2.x - 1, val2.y - 1);
			area.Max = new int2(val2.x + 1, val2.y + 1);
			NativeArray<Entity> entitiesInArea = GetEntitiesInArea(area, (TileType)255);
			if (entitiesInArea.Length > 0)
			{
				SortEntitiesByDistance(entitiesInArea, aimPosition);
				Enumerator<Entity> enumerator = entitiesInArea.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (current.Has<T>())
					{
						return current;
					}
				}
			}
			return Entity.Null;
		}
	}
	public static class ItemUtil
	{
		private static readonly Dictionary<string, Func<string, string>> PrefabTransformations = new Dictionary<string, Func<string, string>>
		{
			["Item_Weapon_"] = (string s) => s.Replace("Item_Weapon_", "").Replace("_T\\d{2}", "").Replace("_", " ")
				.Split(' ')
				.Reverse()
				.Aggregate((string a, string b) => a + " " + b),
			["Item_Ingredient_Mineral_"] = (string s) => s.Replace("Item_Ingredient_Mineral_", "").Replace("_", " ").Split(' ')
				.Aggregate((string a, string b) => a + " " + b),
			["Item_Ingredient_Coin_"] = (string s) => s.Replace("Item_Ingredient_Coin_", "").Replace("_", " ") + " Coin".Replace("Royal", "Goldsun"),
			["Item_Ingredient_"] = (string s) => s.Replace("Item_Ingredient_", "").Replace("_", " ").Split(' ')
				.Aggregate((string a, string b) => a + " " + b),
			["Item_MagicSource_SoulShard"] = (string s) => "Soul Shard of " + s.Replace("Item_MagicSource_SoulShard_", "").Replace("Manticore", "the Winged Horror").Replace("Monster", "the Monster"),
			["Item_Cloak_"] = (string s) => s.Replace("Item_Cloak_", "").Replace("_T\\d{2}_", " ").Replace("_", " ")
				.Split(' ')
				.Aggregate((string a, string b) => a + " " + b) + " Cloak",
			["Item_Headgear_"] = (string s) => s.Replace("Item_Headgear_", "").Replace("_", " ").Split(' ')
				.Aggregate((string a, string b) => a + " " + b),
			["Item_Building_Sapling_"] = (string s) => s.Replace("Item_Building_Sapling_", "").Replace("_Seed", "").Replace("_", " ") + " Sapling",
			["Item_Consumable_Eat_"] = (string s) => string.Concat(from c in s.Replace("Item_Consumable_Eat_", "")
				select (!char.IsUpper(c)) ? c.ToString() : (" " + c)).TrimStart().Replace("_", " ")
				.Split(' ')
				.Aggregate((string a, string b) => a + " " + b)
		};

		public static void ClearEntityInventory(Entity entity, bool all = false)
		{
			//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_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_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_001e: 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)
			Enumerator<InventoryInstanceElement> enumerator = entity.ReadBuffer<InventoryInstanceElement>().GetEnumerator();
			while (enumerator.MoveNext())
			{
				InventoryInstanceElement current = enumerator.Current;
				InventoryUtilitiesServer.ClearInventory(Core.EntityManager, current.ExternalInventoryEntity._Entity);
			}
		}

		public static bool AddItemToInventory(Entity recipient, PrefabGUID guid, int amount, out Entity entity, bool equip = true, int slot = 0, bool drop = true)
		{
			//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_0009: 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_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_0027: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0035: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			ServerGameManager serverGameManager = Core.ServerGameManager;
			AddItemResponse val = ((ServerGameManager)(ref serverGameManager)).TryAddInventoryItem(recipient, guid, amount, new Nullable_Unboxed<int>(slot), false);
			if (val.RemainingAmount > 0 && drop && recipient.Has<Translation>())
			{
				CreateDroppedItem(recipient.Read<Translation>().Value, guid, val.RemainingAmount);
			}
			if (((AddItemResponse)(ref val)).Success)
			{
				entity = val.NewEntity;
				return true;
			}
			entity = default(Entity);
			return false;
		}

		public static void CreateDroppedItem(float3 pos, PrefabGUID prefabGUID, int amount)
		{
			//IL_0007: 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_000e: 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_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_002e: 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_00b1: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0066: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			ItemData val = default(ItemData);
			if (!Core.SystemService.GameDataSystem.ItemHashLookupMap.TryGetValue(prefabGUID, ref val))
			{
				return;
			}
			bool flag = default(bool);
			while (amount > 0)
			{
				try
				{
					int num = Math.Min(amount, val.MaxAmount);
					InventoryUtilitiesServer.CreateDroppedItemEntity(Core.EntityManager, Core.SystemService.EntityCommandBufferSystem.CreateCommandBuffer(), Core.SystemService.GameDataSystem.ItemHashLookupMap, pos, prefabGUID, num);
					amount -= num;
				}
				catch (Exception)
				{
					ManualLogSource logInstance = Plugin.LogInstance;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(33, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Could not create dropped item: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float3>(pos);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(prefabGUID.LookupName());
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(amount);
					}
					logInstance.LogWarning(val2);
					Reattempt(Action.op_Implicit((Action)delegate
					{
						//IL_0001: 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)
						CreateDroppedItem(pos, prefabGUID, amount);
					}));
					break;
				}
			}
		}

		public static string CleanItemName(string input)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			if (string.IsNullOrEmpty(input))
			{
				return input ?? string.Empty;
			}
			bool flag = default(bool);
			try
			{
				string netherShardName = GetNetherShardName(input);
				if (netherShardName != null)
				{
					return netherShardName;
				}
				string gemName = GetGemName(input);
				if (gemName != null)
				{
					return gemName;
				}
				KeyValuePair<string, Func<string, string>> keyValuePair = PrefabTransformations.FirstOrDefault((KeyValuePair<string, Func<string, string>> x) => input.Contains(x.Key));
				if (keyValuePair.Key != null)
				{
					try
					{
						return keyValuePair.Value(input);
					}
					catch (Exception ex)
					{
						ManualLogSource logInstance = Plugin.LogInstance;
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(58, 3, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to transform item name '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(input);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' using transformation '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(keyValuePair.Key);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
						}
						logInstance.LogWarning(val);
						return input.Replace(keyValuePair.Key, "").Replace("_", " ").Trim();
					}
				}
				IEnumerable<string> source = from part in input.Split('_').Skip(1)
					where !string.IsNullOrEmpty(part)
					select part;
				return source.Any() ? source.Aggregate((string a, string b) => a + " " + b) : input;
			}
			catch (Exception ex2)
			{
				ManualLogSource logInstance2 = Plugin.LogInstance;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(101, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to clean item name (give this log line to skytech6 on discord / CrimsonModding discord)\n '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(input);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("':\n ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
				}
				logInstance2.LogWarning(val);
				return input;
			}
		}

		private static string GetNetherShardName(string input)
		{
			if (input.Contains("NetherShard_T01"))
			{
				return "Stygian Shard";
			}
			if (input.Contains("NetherShard_T02"))
			{
				return "Greater Stygian Shard";
			}
			if (input.Contains("NetherShard_T03"))
			{
				return "Primal Stygian Shard";
			}
			return null;
		}

		private static string GetGemName(string input)
		{
			string[] array = input.Split('_');
			if (array.Length <= 3)
			{
				return null;
			}
			string text = array[3];
			if (input.Contains("_T01"))
			{
				return "Crude " + text;
			}
			if (input.Contains("_T02"))
			{
				return "Regular " + text;
			}
			if (input.Contains("_T03"))
			{
				return "Flawless " + text;
			}
			if (input.Contains("_T04"))
			{
				return "Perfect " + text;
			}
			return null;
		}

		private static async void Reattempt(Action action)
		{
			await Task.Delay(300);
			action.Invoke();
		}
	}
	public static class JsonUtil
	{
		public class LongShortNamesConverter : JsonConverter<(string Long, string Short)>
		{
			public override (string Long, string Short) Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
			{
				if (reader.TokenType != JsonTokenType.StartObject)
				{
					throw new JsonException();
				}
				string item = string.Empty;
				string item2 = string.Empty;
				while (reader.Read())
				{
					if (reader.TokenType == JsonTokenType.EndObject)
					{
						return (item, item2);
					}
					if (reader.TokenType != JsonTokenType.PropertyName)
					{
						throw new JsonException();
					}
					string @string = reader.GetString();
					reader.Read();
					switch (@string)
					{
					case "Long":
						item = reader.GetString();
						break;
					case "Short":
						item2 = reader.GetString();
						break;
					case "Item1":
						item = reader.GetString();
						break;
					case "Item2":
						item2 = reader.GetString();
						break;
					}
				}
				throw new JsonException();
			}

			public override void Write(Utf8JsonWriter writer, (string Long, string Short) value, JsonSerializerOptions options)
			{
				writer.WriteStartObject();
				writer.WriteString("Long", value.Long);
				writer.WriteString("Short", value.Short);
				writer.WriteEndObject();
			}
		}

		public class PrefabGUIDConverter : JsonConverter<PrefabGUID>
		{
			public override PrefabGUID Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
			{
				//IL_000f: 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)
				if (reader.TokenType == JsonTokenType.Number)
				{
					return new PrefabGUID(reader.GetInt32());
				}
				if (reader.TokenType == JsonTokenType.String && int.TryParse(reader.GetString(), out var result))
				{
					return new PrefabGUID(result);
				}
				throw new JsonException("Expected number or numeric string for PrefabGUID");
			}

			public override void Write(Utf8JsonWriter writer, PrefabGUID value, JsonSerializerOptions options)
			{
				writer.WriteNumberValue(((PrefabGUID)(ref value)).GuidHash);
			}
		}

		public class TimeOnlyConverter : JsonConverter<TimeOnly>
		{
			private const string TimeFormat = "HH:mm:ss";

			public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
			{
				return TimeOnly.Parse(reader.GetString() ?? "00:00:00");
			}

			public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
			{
				writer.WriteStringValue(value.ToString("HH:mm:ss"));
			}
		}

		public class TimeOnlyHourMinuteConverter : JsonConverter<TimeOnly>
		{
			private const string TimeFormat = "HH:mm";

			public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
			{
				return TimeOnly.ParseExact(reader.GetString() ?? "00:00", "HH:mm");
			}

			public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
			{
				writer.WriteStringValue(value.ToString("HH:mm"));
			}
		}

		public class DayOfWeekConverter : JsonConverter<DayOfWeek?>
		{
			public override DayOfWeek? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
			{
				if (reader.TokenType == JsonTokenType.Null)
				{
					return null;
				}
				string @string = reader.GetString();
				if (string.IsNullOrEmpty(@string) || @string.Equals("Daily", StringComparison.OrdinalIgnoreCase))
				{
					return null;
				}
				if (Enum.TryParse<DayOfWeek>(@string, ignoreCase: true, out var result))
				{
					return result;
				}
				throw new JsonException("Unable to parse '" + @string + "' as DayOfWeek");
			}

			public override void Write(Utf8JsonWriter writer, DayOfWeek? value, JsonSerializerOptions options)
			{
				if (value.HasValue)
				{
					writer.WriteStringValue(value.Value.ToString());
				}
				else
				{
					writer.WriteStringValue("Daily");
				}
			}
		}

		public static readonly JsonSerializerOptions PrettyJsonOptions = new JsonSerializerOptions
		{
			WriteIndented = true,
			IncludeFields = true,
			AllowTrailingCommas = true,
			ReadCommentHandling = JsonCommentHandling.Skip,
			Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
		};

		public static string SerializeWithComments<T>(T value, string commentHeader, JsonSerializerOptions options = null)
		{
			return FormatJsonWithComments(JsonSerializer.Serialize(value, options ?? PrettyJsonOptions), commentHeader);
		}

		public static string FormatJsonWithComments(string json, string commentHeader)
		{
			if (string.IsNullOrEmpty(commentHeader))
			{
				return json;
			}
			string[] source = commentHeader.Split(new char[2] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
			return string.Join(Environment.NewLine, source.Select((string line) => "// " + line)) + Environment.NewLine + Environment.NewLine + json;
		}
	}
	public static class SettingsUtil
	{
		public static ConfigFile CreateConfigFile(string settingsName)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			if (string.IsNullOrEmpty(settingsName))
			{
				Plugin.LogInstance.LogError((object)"Settings name cannot be empty when creating a config file");
				return null;
			}
			return new ConfigFile(Path.Combine(Paths.ConfigPath, settingsName + ".cfg"), true);
		}

		public static ConfigEntry<T> InitConfigEntry<T>(ConfigFile config, string section, string key, T defaultValue, string description)
		{
			return config.Bind<T>(section, key, defaultValue, description);
		}

		public static void ReorderConfigSections(List<string> sections, string settingsName = "")
		{
			if (string.IsNullOrEmpty(settingsName))
			{
				settingsName = "VAMP";
			}
			string path = Path.Combine(Paths.ConfigPath, settingsName + ".cfg");
			if (!File.Exists(path))
			{
				return;
			}
			List<string> list = File.ReadAllLines(path).ToList();
			Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>();
			string text = "";
			foreach (string item in list)
			{
				if (item.StartsWith("["))
				{
					text = item.Trim('[', ']');
					dictionary[text] = new List<string> { item };
				}
				else if (!string.IsNullOrWhiteSpace(text))
				{
					dictionary[text].Add(item);
				}
			}
			using StreamWriter streamWriter = new StreamWriter(path, append: false);
			foreach (string section in sections)
			{
				if (!dictionary.ContainsKey(section))
				{
					continue;
				}
				foreach (string item2 in dictionary[section])
				{
					streamWriter.WriteLine(item2);
				}
				streamWriter.WriteLine();
			}
		}
	}
	public static class UnitUtil
	{
		public class SpawnedUnit
		{
			public Unit Unit;

			public float3 SpawnPosition;

			public Player Player;

			public SpawnedUnit(Unit unit, float3 spawnPosition, Player player = null)
			{
				//IL_000e: 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)
				Unit = unit;
				SpawnPosition = spawnPosition;
				Player = player;
			}
		}

		public static Dictionary<int, SpawnedUnit> HashToUnit = new Dictionary<int, SpawnedUnit>();

		public static Dictionary<Unit, Entity> UnitToEntity = new Dictionary<Unit, Entity>();

		public static bool TryGetSpawnedUnitFromEntity(Entity unitEntity, out SpawnedUnit unit)
		{
			//IL_0000: 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_0010: 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)
			if (unitEntity.Has<ResistanceData>() && unitEntity.Has<CanFly>())
			{
				int key = (int)unitEntity.Read<ResistanceData>().FireResistance_RedcuedIgiteChancePerRating;
				return HashToUnit.TryGetValue(key, out unit);
			}
			unit = null;
			return false;
		}

		public static void SpawnUnitWithCallback(Unit unit, float3 position, Action<Entity> postActions, Player player = null)
		{
			//IL_000e: 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_002a: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			SpawnedUnit spawnedUnit = new SpawnedUnit(unit, position, player);
			SpawnService.SpawnUnitWithCallback(unit.PrefabGuid, position, 0f, delegate(Entity e)
			{
				//IL_0025: 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_003d: 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_008c: 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_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_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)
				int hashCode = ((object)(Entity)(ref e)).GetHashCode();
				HashToUnit[hashCode] = spawnedUnit;
				StoreMetaDataOnUnit(unit, e, position, player);
				SetHealth(unit, e);
				if (unit.MaxDistanceFromPreCombatPosition != -1f)
				{
					AggroConsumer componentData = e.Read<AggroConsumer>();
					componentData.MaxDistanceFromPreCombatPosition = unit.MaxDistanceFromPreCombatPosition;
					e.Write<AggroConsumer>(componentData);
				}
				UnitToEntity[unit] = e;
				postActions(e);
			});
		}

		private static void ModifyAggroRadius(Unit unit, Entity buffEntity)
		{
			//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_0009: 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)
			buffEntity.Add<ModifyAggroRangesBuff>();
			buffEntity.Write<ModifyAggroRangesBuff>(new ModifyAggroRangesBuff
			{
				AggroCircleRadiusFactor = unit.AggroRadius,
				AggroConeRadiusFactor = unit.AggroRadius,
				AlertCircleRadiusFactor = unit.AggroRadius,
				AlertConeRadiusFactor = unit.AggroRadius
			});
		}

		public static float StringToFloatHash(string input)
		{
			float num = 0f;
			float num2 = 31f;
			foreach (char c in input)
			{
				num = num * num2 + (float)(int)c;
			}
			return num;
		}

		public static float3 GetSpawnPositionOfEntity(Entity entity)
		{
			//IL_0000: 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_0008: 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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (entity.Has<ResistanceData>())
			{
				ResistanceData val = entity.Read<ResistanceData>();
				return new float3(val.HolyResistance_DamageAbsorbPerRating, val.HolyResistance_DamageReductionPerRating, val.SilverResistance_DamageReductionPerRating);
			}
			return float3.zero;
		}

		private static void StoreMetaDataOnUnit(Unit unit, Entity e, float3 position, Player player = null)
		{
			//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_0009: 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_0027: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			e.Add<NameableInteractable>();
			e.Write<NameableInteractable>(new NameableInteractable
			{
				Name = FixedString64Bytes.op_Implicit(unit.Category)
			});
			e.Add<ResistanceData>();
			ResistanceData componentData = e.Read<ResistanceData>();
			componentData.FireResistance_DamageReductionPerRating = unit.Team;
			componentData.FireResistance_RedcuedIgiteChancePerRating = ((object)(Entity)(ref e)).GetHashCode();
			componentData.GarlicResistance_IncreasedExposureFactorPerRating = StringToFloatHash(unit.Category);
			componentData.HolyResistance_DamageAbsorbPerRating = position.x;
			componentData.HolyResistance_DamageReductionPerRating = position.y;
			componentData.SilverResistance_DamageReductionPerRating = position.z;
			e.Write<ResistanceData>(componentData);
			if (player != null)
			{
				e.Write<TeamReference>(player.Character.Read<TeamReference>());
				e.Write<Team>(player.Character.Read<Team>());
			}
		}

		private static void DisableAggro(Entity buffEntity)
		{
			//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_0009: 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)
			buffEntity.Add<DisableAggroBuff>();
			buffEntity.Write<DisableAggroBuff>(new DisableAggroBuff
			{
				Mode = (DisableAggroBuffMode)1
			});
		}

		private static void GiveKnockbackResistance(Unit unit, Entity e, Entity buffEntity)
		{
			//IL_0000: 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_0043: 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_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_005a: 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_000e: 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_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_002f: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			e.Add<BuffResistances>();
			if (unit.IsRooted)
			{
				e.Write<BuffResistances>(new BuffResistances
				{
					SettingsEntity = new ModifiableEntity(EntityUtil.EntityFromGUID(Prefabs.BuffResistance_Golem)),
					InitialSettingGuid = Prefabs.BuffResistance_Golem
				});
			}
			else
			{
				e.Write<BuffResistances>(new BuffResistances
				{
					SettingsEntity = new ModifiableEntity(EntityUtil.EntityFromGUID(Prefabs.BuffResistance_UberMobNoKnockbackOrGrab)),
					InitialSettingGuid = Prefabs.BuffResistance_UberMobNoKnockbackOrGrab
				});
			}
		}

		private static void AddBuffModifications(Unit unit, Entity buffEntity)
		{
			//IL_0000: Unknown result type (might be due