Decompiled source of RPGMods Experience v0.9.9

RPGMods_Experience.dll

Decompiled a month ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Costura;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Gameplay;
using ProjectM.Gameplay.Systems;
using ProjectM.Network;
using ProjectM.Scripting;
using RPGMods.Hooks;
using RPGMods.Systems;
using RPGMods.Utils;
using Stunlock.Core;
using Stunlock.Network;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
using VampireCommandFramework;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RPGMods_Experience")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("RPG Mods - Experience Module")]
[assembly: AssemblyFileVersion("0.9.9.0")]
[assembly: AssemblyInformationalVersion("0.9.9")]
[assembly: AssemblyProduct("RPGMods_Experience")]
[assembly: AssemblyTitle("RPGMods_Experience")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.9.9.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
		AssemblyLoader.Attach();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 RPGMods
{
	[BepInPlugin("RPGMods_Experience", "RPGMods - Experience Module", "0.9.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		public const string moduleName = "Experience";

		public static Harmony harmony;

		public static bool testing;

		public static bool isInitialized;

		public static ManualLogSource Logger;

		private static World _serverWorld;

		private static bool parseLogging;

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

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

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

		public void InitConfig()
		{
			if (!Directory.Exists("BepInEx/config/RPGMods"))
			{
				Directory.CreateDirectory("BepInEx/config/RPGMods");
			}
			if (!Directory.Exists("BepInEx/config/RPGMods/Experience"))
			{
				Directory.CreateDirectory("BepInEx/config/RPGMods/Experience");
			}
			if (!Directory.Exists("BepInEx/config/RPGMods/Experience/Backup"))
			{
				Directory.CreateDirectory("BepInEx/config/RPGMods/Experience/Backup");
			}
		}

		public override void Load()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			if (!IsServer)
			{
				((BasePlugin)this).Log.LogWarning((object)"RPGMods is a server plugin. Not continuing to load on client.");
				return;
			}
			InitConfig();
			Logger = ((BasePlugin)this).Log;
			harmony = new Harmony("RPGMods - Experience");
			harmony.PatchAll(Assembly.GetExecutingAssembly());
			TaskRunner.Initialize();
			((BasePlugin)this).Log.LogInfo((object)"Plugin RPGMods - Experience is loaded!");
		}

		public override bool Unload()
		{
			AutoSaveSystem.SaveDatabase();
			((BasePlugin)this).Config.Clear();
			harmony.UnpatchSelf();
			TaskRunner.Destroy();
			return true;
		}

		public void OnGameInitialized()
		{
			Initialize();
		}

		public static void Initialize()
		{
			Logger.LogInfo((object)("Trying to Initalize RPGMods - Experience, isInitalized already: " + isInitialized));
			if (!isInitialized)
			{
				Logger.LogInfo((object)"Initalizing RPGMods - Experience");
				Helper.CreatePlayerCache();
				Logger.LogInfo((object)"Registering commands");
				CommandRegistry.RegisterAll();
				AutoSaveSystem.LoadDatabase();
				Logger.LogInfo((object)"Finished initialising");
				isInitialized = true;
			}
		}

		public static int[] parseIntArrayConifg(string data)
		{
			if (parseLogging)
			{
				Logger.LogInfo((object)(">>>parsing int array: " + data));
			}
			Match match = Regex.Match(data, "([0-9]+)");
			List<int> list = new List<int>();
			while (match.Success)
			{
				try
				{
					if (parseLogging)
					{
						Logger.LogInfo((object)(">>>got int: " + match.Value));
					}
					int item = int.Parse(match.Value, CultureInfo.InvariantCulture);
					if (parseLogging)
					{
						Logger.LogInfo((object)(">>>int parsed into: " + item));
					}
					list.Add(item);
				}
				catch
				{
					if (parseLogging)
					{
						Logger.LogWarning((object)("Error interperting integer value: " + match.ToString()));
					}
				}
				match = match.NextMatch();
			}
			if (parseLogging)
			{
				Logger.LogInfo((object)">>>done parsing int array");
			}
			return list.ToArray();
		}

		public static float[] parseFloatArrayConifg(string data)
		{
			if (parseLogging)
			{
				Logger.LogInfo((object)(">>>parsing float array: " + data));
			}
			Match match = Regex.Match(data, "[-+]?[0-9]*\\.?[0-9]+");
			List<float> list = new List<float>();
			while (match.Success)
			{
				try
				{
					if (parseLogging)
					{
						Logger.LogInfo((object)(">>>got float: " + match.Value));
					}
					float item = float.Parse(match.Value, CultureInfo.InvariantCulture);
					if (parseLogging)
					{
						Logger.LogInfo((object)(">>>float parsed into: " + item));
					}
					list.Add(item);
				}
				catch
				{
					Logger.LogWarning((object)("Error interperting float value: " + match.ToString()));
				}
				match = match.NextMatch();
			}
			if (parseLogging)
			{
				Logger.LogInfo((object)">>>done parsing float array");
			}
			return list.ToArray();
		}

		public static double[] parseDoubleArrayConifg(string data)
		{
			if (parseLogging)
			{
				Logger.LogInfo((object)(">>>parsing double array: " + data));
			}
			Match match = Regex.Match(data, "[-+]?[0-9]*\\.?[0-9]+");
			List<double> list = new List<double>();
			while (match.Success)
			{
				try
				{
					if (parseLogging)
					{
						Logger.LogInfo((object)(">>>got double: " + match.Value));
					}
					double item = double.Parse(match.Value, CultureInfo.InvariantCulture);
					if (parseLogging)
					{
						Logger.LogInfo((object)(">>>double parsed into: " + item));
					}
					list.Add(item);
				}
				catch
				{
					Logger.LogWarning((object)("Error interperting double value: " + match.ToString()));
				}
				match = match.NextMatch();
			}
			if (parseLogging)
			{
				Logger.LogInfo((object)">>>done parsing double array");
			}
			return list.ToArray();
		}

		public static string[] parseStringArrayConifg(string data)
		{
			if (parseLogging)
			{
				Logger.LogInfo((object)(">>>parsing comma seperated String array: " + data));
			}
			List<string> list = new List<string>();
			while (data.IndexOf(",") > 0)
			{
				string text = data.Substring(0, data.IndexOf(","));
				text.Trim();
				list.Add(text);
				data = data.Substring(data.IndexOf(",") + 1);
			}
			data.Trim();
			list.Add(data);
			if (parseLogging)
			{
				Logger.LogInfo((object)">>>done parsing string array");
			}
			return list.ToArray();
		}
	}
}
namespace RPGMods.Utils
{
	public class Alliance
	{
		public struct CloseAlly
		{
			public Entity userEntity;

			public User userComponent;

			public int currentXp;

			public int playerLevel;

			public ulong steamID;

			public float3 position;

			public bool isTrigger;
		}

		private static readonly int CacheAgeLimit = 300;

		private static bool ConvertToAlly(Entity entity, float3 position, bool logging, out CloseAlly ally)
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = Plugin.Server.EntityManager;
			PlayerCharacter val = default(PlayerCharacter);
			EntityManagerDebug debug;
			if (!((EntityManager)(ref entityManager)).TryGetComponentData<PlayerCharacter>(entity, ref val))
			{
				if (logging)
				{
					ManualLogSource logger = Plugin.Logger;
					string text = DateTime.Now.ToString();
					entityManager = Plugin.Server.EntityManager;
					debug = ((EntityManager)(ref entityManager)).Debug;
					logger.LogInfo((object)(text + ": Player Character Component unavailable, available components are: " + ((EntityManagerDebug)(ref debug)).GetEntityInfo(entity)));
				}
				ally = default(CloseAlly);
				return false;
			}
			Entity userEntity = val.UserEntity;
			entityManager = Plugin.Server.EntityManager;
			User val2 = default(User);
			if (!((EntityManager)(ref entityManager)).TryGetComponentData<User>(userEntity, ref val2))
			{
				if (logging)
				{
					ManualLogSource logger2 = Plugin.Logger;
					string text2 = DateTime.Now.ToString();
					entityManager = Plugin.Server.EntityManager;
					debug = ((EntityManager)(ref entityManager)).Debug;
					logger2.LogInfo((object)(text2 + ": User Component unavailable, available components from pc.UserEntity are: " + ((EntityManagerDebug)(ref debug)).GetEntityInfo(userEntity)));
				}
				ally = default(CloseAlly);
				return false;
			}
			ulong platformId = val2.PlatformId;
			int playerLevel = 0;
			Database.player_experience.TryGetValue(platformId, out var value);
			ally = new CloseAlly
			{
				currentXp = value,
				playerLevel = playerLevel,
				steamID = platformId,
				userEntity = userEntity,
				userComponent = val2,
				position = position
			};
			return true;
		}

		public static List<CloseAlly> GetCloseAllies(Entity closeToEntity, Entity triggerEntity, float groupMaxDistance, bool useGroup, bool logging)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_0094: Expected O, but got Unknown
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			float num = groupMaxDistance * groupMaxDistance;
			if (logging)
			{
				Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Fetching allies..."));
			}
			List<CloseAlly> list = new List<CloseAlly>();
			EntityManager entityManager;
			LocalToWorld componentData;
			if (!useGroup)
			{
				entityManager = Plugin.Server.EntityManager;
				componentData = ((EntityManager)(ref entityManager)).GetComponentData<LocalToWorld>(triggerEntity);
				float3 position = ((LocalToWorld)(ref componentData)).Position;
				if (ConvertToAlly(triggerEntity, position, logging, out var ally))
				{
					ally.isTrigger = true;
					list.Add(ally);
				}
			}
			else
			{
				GetAllies(triggerEntity, logging, out var playerGroup);
				if (logging)
				{
					ManualLogSource logger = Plugin.Logger;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Getting close allies");
					}
					logger.LogInfo(val);
				}
				entityManager = Plugin.Server.EntityManager;
				LocalToWorld componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<LocalToWorld>(closeToEntity);
				foreach (KeyValuePair<Entity, Entity> ally3 in playerGroup.Allies)
				{
					if (logging)
					{
						Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Iterating over allies, entity is " + ally3.GetHashCode()));
					}
					bool flag2 = ((Entity)(ref triggerEntity)).Equals(ally3.Key);
					if (logging && flag2)
					{
						Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Entity is trigger"));
					}
					entityManager = Plugin.Server.EntityManager;
					componentData = ((EntityManager)(ref entityManager)).GetComponentData<LocalToWorld>(ally3.Value);
					float3 position2 = ((LocalToWorld)(ref componentData)).Position;
					if (!flag2)
					{
						if (logging)
						{
							Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Got entity Position"));
						}
						float3 position3 = ((LocalToWorld)(ref componentData2)).Position;
						float num2 = math.distancesq(((float3)(ref position3)).xz, ((float3)(ref position2)).xz);
						if (logging)
						{
							Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": DistanceSq is " + num2 + ", Max DistanceSq is " + num));
						}
						if (!(num2 <= num))
						{
							continue;
						}
					}
					if (logging)
					{
						Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Converting entity to ally..."));
					}
					if (ConvertToAlly(ally3.Key, position2, logging, out var ally2))
					{
						ally2.isTrigger = flag2;
						list.Add(ally2);
					}
				}
			}
			if (logging)
			{
				Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Allies Fetched, Total ally count of " + list.Count));
			}
			return list;
		}

		public static void GetAllies(Entity playerCharacter, bool logging, out PlayerGroup playerGroup)
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_064a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Expected O, but got Unknown
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Expected O, but got Unknown
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Expected O, but got Unknown
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Expected O, but got Unknown
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Expected O, but got Unknown
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = Plugin.Server.EntityManager;
			bool flag = default(bool);
			EntityManagerDebug debug;
			if (!((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(playerCharacter))
			{
				if (logging)
				{
					ManualLogSource logger = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Entity is not user: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(playerCharacter);
					}
					logger.LogInfo(val);
					ManualLogSource logger2 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Components for Player Character are: ");
						BepInExInfoLogInterpolatedStringHandler obj = val;
						entityManager = Plugin.Server.EntityManager;
						debug = ((EntityManager)(ref entityManager)).Debug;
						((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>(((EntityManagerDebug)(ref debug)).GetEntityInfo(playerCharacter));
					}
					logger2.LogInfo(val);
				}
				playerGroup = new PlayerGroup
				{
					Allies = new Dictionary<Entity, Entity>()
				};
				return;
			}
			if (logging)
			{
				ManualLogSource logger3 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Beginning To Parse Player Group");
				}
				logger3.LogInfo(val);
			}
			if (Cache.PlayerAllies.TryGetValue(playerCharacter, out playerGroup))
			{
				if (logging)
				{
					ManualLogSource logger4 = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Allies Found in Cache, timestamp is ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(playerGroup.TimeStamp);
					}
					logger4.LogInfo(val);
				}
				if ((DateTime.Now - playerGroup.TimeStamp).TotalSeconds < (double)CacheAgeLimit)
				{
					return;
				}
				if (logging)
				{
					ManualLogSource logger5 = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Refreshing cached allies");
					}
					logger5.LogInfo(val);
				}
			}
			entityManager = Plugin.Server.EntityManager;
			Team val2 = default(Team);
			if (!((EntityManager)(ref entityManager)).TryGetComponentData<Team>(playerCharacter, ref val2))
			{
				if (logging)
				{
					ManualLogSource logger6 = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Could not get team for Player Character: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(playerCharacter);
					}
					logger6.LogInfo(val);
					ManualLogSource logger7 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Components for Player Character are: ");
						BepInExInfoLogInterpolatedStringHandler obj2 = val;
						entityManager = Plugin.Server.EntityManager;
						debug = ((EntityManager)(ref entityManager)).Debug;
						((BepInExLogInterpolatedStringHandler)obj2).AppendFormatted<string>(((EntityManagerDebug)(ref debug)).GetEntityInfo(playerCharacter));
					}
					logger7.LogInfo(val);
				}
				playerGroup = new PlayerGroup
				{
					Allies = new Dictionary<Entity, Entity>()
				};
				return;
			}
			if (logging)
			{
				ManualLogSource logger8 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Player Character Found Value: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(val2.Value);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - Faction Index: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(val2.FactionIndex);
				}
				logger8.LogInfo(val);
			}
			playerGroup.TimeStamp = DateTime.Now;
			Dictionary<Entity, Entity> dictionary = new Dictionary<Entity, Entity>();
			entityManager = Plugin.Server.EntityManager;
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val3 = new EntityQueryDesc();
			val3.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<PlayerCharacter>(),
				ComponentType.ReadOnly<IsConnected>()
			});
			val3.Options = (EntityQueryOptions)2;
			array[0] = val3;
			EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array);
			NativeArray<Entity> val5 = ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			if (logging)
			{
				ManualLogSource logger9 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": got connected PC entities buffer of length ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(val5.Length);
				}
				logger9.LogInfo(val);
			}
			Enumerator<Entity> enumerator = val5.GetEnumerator();
			Team val7 = default(Team);
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				Entity val6;
				if (logging)
				{
					ManualLogSource logger10 = Plugin.Logger;
					string text = DateTime.Now.ToString();
					val6 = current;
					logger10.LogInfo((object)(text + ": got Entity " + ((object)(Entity)(ref val6)).ToString()));
				}
				entityManager = Plugin.Server.EntityManager;
				if (((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(current))
				{
					if (logging)
					{
						ManualLogSource logger11 = Plugin.Logger;
						string text2 = DateTime.Now.ToString();
						val6 = current;
						logger11.LogInfo((object)(text2 + ": Entity is User " + ((object)(Entity)(ref val6)).ToString()));
					}
					if (((Entity)(ref current)).Equals(playerCharacter))
					{
						if (logging)
						{
							Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Entity is self"));
						}
						dictionary[current] = current;
						continue;
					}
					bool flag2 = false;
					try
					{
						if (logging)
						{
							Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Trying to get teams "));
						}
						entityManager = Plugin.Server.EntityManager;
						bool flag3 = ((EntityManager)(ref entityManager)).TryGetComponentData<Team>(current, ref val7);
						if (logging)
						{
							if (flag3)
							{
								Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Team Value:" + val7.Value + " - Faction Index: " + val7.FactionIndex));
							}
							else
							{
								ManualLogSource logger12 = Plugin.Logger;
								string text3 = DateTime.Now.ToString();
								val6 = current;
								logger12.LogInfo((object)(text3 + ": Could not get team for entity: " + ((object)(Entity)(ref val6)).ToString()));
								ManualLogSource logger13 = Plugin.Logger;
								string text4 = DateTime.Now.ToString();
								entityManager = Plugin.Server.EntityManager;
								debug = ((EntityManager)(ref entityManager)).Debug;
								logger13.LogInfo((object)(text4 + ": Components for entity are: " + ((EntityManagerDebug)(ref debug)).GetEntityInfo(current)));
							}
						}
						flag2 = flag3 && val7.Value == val2.Value;
					}
					catch (Exception ex)
					{
						if (logging)
						{
							Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": IsAllies Failed " + ex.Message));
						}
					}
					if (flag2)
					{
						if (logging)
						{
							ManualLogSource logger14 = Plugin.Logger;
							BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(13, 3, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Allies: ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(playerCharacter);
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(current);
							}
							logger14.LogInfo(val);
						}
						dictionary[current] = current;
					}
					else if (logging)
					{
						ManualLogSource logger15 = Plugin.Logger;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 3, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Not allies: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(playerCharacter);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(current);
						}
						logger15.LogInfo(val);
					}
				}
				else if (logging)
				{
					Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": No Associated User!"));
				}
			}
			playerGroup.Allies = dictionary;
			playerGroup.AllyCount = dictionary.Count;
			Cache.PlayerAllies[playerCharacter] = playerGroup;
		}
	}
	public static class AutoSaveSystem
	{
		public const string mainSaveFolder = "BepInEx/config/RPGMods/Experience/";

		public const string backupSaveFolder = "BepInEx/config/RPGMods/Experience/Backup/";

		private static int saveCount = 0;

		public static int backupFrequency = 5;

		public static bool saveLogging = false;

		public static void SaveDatabase()
		{
			saveCount++;
			string saveFolder = "BepInEx/config/RPGMods/Experience/";
			if (saveCount % backupFrequency == 0)
			{
				saveFolder = "BepInEx/config/RPGMods/Experience/Backup/";
			}
			ExperienceSystem.SaveEXPData(saveFolder);
			Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Experience databases saved to JSON file."));
		}

		public static void LoadDatabase()
		{
			ExperienceSystem.LoadEXPData();
			Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Experience database is now loaded."));
		}
	}
	public static class Color
	{
		private static string ColorText(string color, string text)
		{
			return "<color=" + color + ">" + text + "</color>";
		}

		public static string White(string text)
		{
			return ColorText("#fffffffe", text);
		}

		public static string Black(string text)
		{
			return ColorText("#000000", text);
		}

		public static string Gray(string text)
		{
			return ColorText("#404040", text);
		}

		public static string Orange(string text)
		{
			return ColorText("#c98332", text);
		}

		public static string Yellow(string text)
		{
			return ColorText("#cfc14a", text);
		}

		public static string Green(string text)
		{
			return ColorText("#56ad3b", text);
		}

		public static string Teal(string text)
		{
			return ColorText("#3b8dad", text);
		}

		public static string Blue(string text)
		{
			return ColorText("#3444a8", text);
		}

		public static string Purple(string text)
		{
			return ColorText("#8b3691", text);
		}

		public static string Pink(string text)
		{
			return ColorText("#b53c8ffe", text);
		}

		public static string Red(string text)
		{
			return ColorText("#ff0000", text);
		}

		public static string SoftRed(string text)
		{
			return ColorText("#b53c40", text);
		}
	}
	public static class Cache
	{
		public static Dictionary<string, PlayerData> NamePlayerCache = new Dictionary<string, PlayerData>();

		public static Dictionary<ulong, PlayerData> SteamPlayerCache = new Dictionary<ulong, PlayerData>();

		public static Dictionary<Entity, PlayerGroup> PlayerAllies = new Dictionary<Entity, PlayerGroup>();

		public static Dictionary<Entity, LocalToWorld> PlayerLocations = new Dictionary<Entity, LocalToWorld>();

		public static Dictionary<ulong, List<BuffData>> buffData = new Dictionary<ulong, List<BuffData>>();

		public static Dictionary<ulong, float> command_Cooldown = new Dictionary<ulong, float>();

		public static Dictionary<ulong, DateTime> playerCombatStart = new Dictionary<ulong, DateTime>();

		public static Dictionary<ulong, DateTime> playerCombatEnd = new Dictionary<ulong, DateTime>();

		public static Dictionary<ulong, DateTime> player_last_combat = new Dictionary<ulong, DateTime>();

		public static Dictionary<ulong, int> player_combat_ticks = new Dictionary<ulong, int>();

		public static Dictionary<ulong, float> player_level = new Dictionary<ulong, float>();

		public static Dictionary<ulong, Dictionary<UnitStatType, float>> player_geartypedonned = new Dictionary<ulong, Dictionary<UnitStatType, float>>();

		public static Dictionary<Entity, LevelData> PlayerLevelCache = new Dictionary<Entity, LevelData>();

		public static Dictionary<ulong, PvPOffenseLog> OffenseLog = new Dictionary<ulong, PvPOffenseLog>();

		public static Dictionary<ulong, ReputationLog> ReputationLog = new Dictionary<ulong, ReputationLog>();

		public static Dictionary<Entity, StateData> HostilityState = new Dictionary<Entity, StateData>();

		public static SizedDictionaryAsync<float, SpawnNPCListen> spawnNPC_Listen = new SizedDictionaryAsync<float, SpawnNPCListen>(500);

		public static DateTime GetCombatStart(ulong steamID)
		{
			if (!playerCombatStart.TryGetValue(steamID, out var value))
			{
				return DateTime.MinValue;
			}
			return value;
		}

		public static DateTime GetCombatEnd(ulong steamID)
		{
			if (!playerCombatEnd.TryGetValue(steamID, out var value))
			{
				return DateTime.MinValue;
			}
			return value;
		}
	}
	public static class Database
	{
		public static class Buff
		{
			public static PrefabGUID EquipBuff = new PrefabGUID(343359674);

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

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

			public static PrefabGUID BatForm = new PrefabGUID(1205505492);

			public static PrefabGUID NormalForm = new PrefabGUID(1352541204);

			public static PrefabGUID RatForm = new PrefabGUID(902394170);

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

			public static PrefabGUID BloodSight = new PrefabGUID(1199823151);

			public static PrefabGUID InCombat = new PrefabGUID(581443919);

			public static PrefabGUID InCombat_PvP = new PrefabGUID(697095869);

			public static PrefabGUID OutofCombat = new PrefabGUID(897325455);

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

			public static PrefabGUID Severe_GarlicDebuff = new PrefabGUID(1582196539);

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

			public static PrefabGUID Buff_4pT2 = new PrefabGUID(1444835872);

			public static PrefabGUID cloakBuff = new PrefabGUID(1409441911);

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

			public static PrefabGUID SiegeGolem_T02 = new PrefabGUID(914043867);

			public static PrefabGUID AB_Interact_GetInside_Owner_Buff_Stone = new PrefabGUID(569692162);

			public static PrefabGUID AB_Interact_GetInside_Owner_Buff_Base = new PrefabGUID(381160212);

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

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

			public static PrefabGUID AB_Interact_TombCoffinSpawn_Travel = new PrefabGUID(722466953);

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

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

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

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

			public static PrefabGUID AB_Undead_BishopOfShadows_ShadowSoldier_Minion_Buff = new PrefabGUID(450215391);

			public static PrefabGUID HolyNuke = new PrefabGUID(-1807398295);

			public static PrefabGUID AB_Manticore_Flame_Buff_UNUSED = new PrefabGUID(1502566434);

			public static PrefabGUID Pig_Transform_Debuff = new PrefabGUID(1356064917);

			public static PrefabGUID EquipBuff_Chest_Base = new PrefabGUID(1872694456);

			public static PrefabGUID Buff_VBlood_Perk_ProgTest = new PrefabGUID(1614409699);

			public static PrefabGUID AB_BloodBuff_VBlood_0 = new PrefabGUID(20081801);
		}

		public static JsonSerializerOptions JSON_options = new JsonSerializerOptions
		{
			WriteIndented = false,
			IncludeFields = false
		};

		public static JsonSerializerOptions Pretty_JSON_options = new JsonSerializerOptions
		{
			WriteIndented = true,
			IncludeFields = true
		};

		public static HashSet<ApplyBuffDebugEvent> playerBuffs = new HashSet<ApplyBuffDebugEvent>();

		public static bool ErrorOnLoadingExperienceClasses = false;

		public static Dictionary<ulong, SiegeData> SiegeState = new Dictionary<ulong, SiegeData>();

		public static Dictionary<ulong, bool> sunimmunity { get; set; }

		public static Dictionary<ulong, bool> nocooldownlist { get; set; }

		public static Dictionary<ulong, bool> godmode { get; set; }

		public static Dictionary<ulong, bool> speeding { get; set; }

		public static Dictionary<ulong, bool> autoRespawn { get; set; }

		public static Dictionary<string, Tuple<float, float, float, int, int, int, string>> waypointDBNew { get; set; }

		public static Dictionary<ulong, DateTime> lastUsedWaypoint { get; set; }

		public static Dictionary<string, WaypointData> globalWaypoint { get; set; }

		public static Dictionary<string, WaypointData> waypoints { get; set; }

		public static Dictionary<ulong, int> waypoints_owned { get; set; }

		public static Dictionary<ulong, int> user_permission { get; set; }

		public static Dictionary<string, int> command_permission { get; set; }

		public static Dictionary<ulong, PowerUpData> PowerUpList { get; set; }

		public static Dictionary<ulong, int> player_experience { get; set; }

		public static Dictionary<ulong, int> player_abilityIncrease { get; set; }

		public static LazyDictionary<ulong, LazyDictionary<UnitStatType, float>> player_level_stats { get; set; }

		public static Dictionary<string, Dictionary<UnitStatType, float>> experience_class_stats { get; set; }

		public static Dictionary<ulong, bool> player_log_exp { get; set; }

		public static Dictionary<int, int> XPChart { get; set; }

		public static ConcurrentDictionary<ulong, PvPData> PvPStats { get; set; }

		public static Dictionary<Entity, Entity> killMap { get; set; }

		public static Dictionary<ulong, int> pvpkills { get; set; }

		public static Dictionary<ulong, int> pvpdeath { get; set; }

		public static Dictionary<ulong, double> pvpkd { get; set; }

		public static Dictionary<ulong, DateTime> player_decaymastery_logout { get; set; }

		public static Dictionary<ulong, bool> player_log_mastery { get; set; }

		public static Dictionary<ulong, bool> player_log_buffs { get; set; }

		public static bool logAllBuffs { get; set; }

		public static Dictionary<int, int> forcedMasteryType { get; set; }

		public static Dictionary<int, string> forcedMasteryName { get; set; }

		public static Dictionary<ulong, HashSet<int>> playerActiveBuffs { get; set; }

		public static Dictionary<ulong, DateTime> playerActiveBuffsLastClear { get; set; }

		public static Dictionary<int, RateData> buffMasteryRates { get; set; }

		public static Dictionary<ulong, WeaponMasterData_Dictionary> player_weaponmastery_Dictionary { get; set; }

		public static Dictionary<int, RateData> mastery_Rates { get; set; }

		public static Dictionary<ulong, DateTime> playerDecayBloodlineLogout { get; set; }

		public static Dictionary<ulong, bool> playerLogBloodline { get; set; }

		public static ConcurrentDictionary<int, FactionData> FactionStats { get; set; }

		public static HashSet<string> IgnoredMonsters { get; set; }

		public static HashSet<PrefabGUID> IgnoredMonstersGUID { get; set; }

		public static Dictionary<int, Tuple<int, string>> ForcedFactionMonstersGUID { get; set; }
	}
	public static class FactionUnits
	{
		public struct Unit
		{
			public Prefabs.Units type { get; }

			public int level { get; }

			public int value { get; }

			public Unit(Prefabs.Units type, int level, int value)
			{
				this.type = type;
				this.level = level;
				this.value = value;
			}
		}

		private static Unit[] bandit_units = new Unit[9]
		{
			new Unit(Prefabs.Units.CHAR_Bandit_Wolf, 14, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Hunter, 16, 2),
			new Unit(Prefabs.Units.CHAR_Bandit_Thug, 16, 2),
			new Unit(Prefabs.Units.CHAR_Bandit_Thief, 18, 3),
			new Unit(Prefabs.Units.CHAR_Bandit_Mugger, 20, 3),
			new Unit(Prefabs.Units.CHAR_Bandit_Trapper, 20, 3),
			new Unit(Prefabs.Units.CHAR_Bandit_Deadeye, 26, 4),
			new Unit(Prefabs.Units.CHAR_Bandit_Stalker, 30, 4),
			new Unit(Prefabs.Units.CHAR_Bandit_Bomber, 32, 4)
		};

		private static Unit[] church = new Unit[14]
		{
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Miner_Standard, 42, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Archer, 56, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_SlaveRuffian, 60, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Cleric, 62, 2),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Footman, 62, 2),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Rifleman, 62, 2),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_SlaveMaster_Enforcer, 64, 3),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_SlaveMaster_Sentry, 64, 3),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Knight_2H, 68, 3),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Knight_Shield, 68, 3),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_CardinalAide, 70, 4),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Lightweaver, 72, 4),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Paladin, 74, 4),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Priest, 74, 4)
		};

		private static Unit[] church_elite = new Unit[1]
		{
			new Unit(Prefabs.Units.CHAR_Paladin_DivineAngel, 80, 5)
		};

		private static Unit[] church_extra = new Unit[1]
		{
			new Unit(Prefabs.Units.CHAR_Militia_EyeOfGod, 0, 1)
		};

		private static Unit[] cultist_units = new Unit[2]
		{
			new Unit(Prefabs.Units.CHAR_Cultist_Pyromancer, 60, 2),
			new Unit(Prefabs.Units.CHAR_Cultist_Slicer, 60, 2)
		};

		private static Unit[] cursed_units = new Unit[12]
		{
			new Unit(Prefabs.Units.CHAR_Cursed_MonsterToad, 61, 1),
			new Unit(Prefabs.Units.CHAR_Cursed_ToadSpitter, 61, 1),
			new Unit(Prefabs.Units.CHAR_Cursed_Witch_Exploding_Mosquito, 61, 1),
			new Unit(Prefabs.Units.CHAR_Cursed_MonsterToad_Minion, 62, 1),
			new Unit(Prefabs.Units.CHAR_Cursed_Mosquito, 62, 1),
			new Unit(Prefabs.Units.CHAR_Cursed_Wolf, 62, 1),
			new Unit(Prefabs.Units.CHAR_Cursed_WormTerror, 62, 2),
			new Unit(Prefabs.Units.CHAR_Cursed_Bear_Standard, 64, 2),
			new Unit(Prefabs.Units.CHAR_Cursed_Nightlurker, 64, 2),
			new Unit(Prefabs.Units.CHAR_Cursed_Witch, 72, 3),
			new Unit(Prefabs.Units.CHAR_Cursed_Bear_Spirit, 80, 3),
			new Unit(Prefabs.Units.CHAR_Cursed_Wolf_Spirit, 80, 3)
		};

		private static Unit[] farmlands = new Unit[8]
		{
			new Unit(Prefabs.Units.CHAR_Farmlands_HostileVillager_Female_FryingPan, 28, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_HostileVillager_Female_Pitchfork, 28, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_HostileVillager_Male_Club, 28, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_HostileVillager_Male_Shovel, 28, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_HostileVillager_Male_Torch, 28, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_HostileVillager_Male_Unarmed, 28, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Woodcutter_Standard, 34, 1),
			new Unit(Prefabs.Units.CHAR_Farmland_Wolf, 40, 1)
		};

		private static Unit[] farmNonHostile = new Unit[4]
		{
			new Unit(Prefabs.Units.CHAR_Farmlands_Villager_Female_Sister, 20, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Villager_Female, 26, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Villager_Male, 26, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Farmer, 34, 1)
		};

		public static Unit[] farmFood = new Unit[6]
		{
			new Unit(Prefabs.Units.CHAR_Farmlands_SheepOld, 10, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_SmallPig, 20, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Pig, 24, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Cow, 30, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Sheep, 36, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Ram, 38, 1)
		};

		private static Unit[] forest = new Unit[3]
		{
			new Unit(Prefabs.Units.CHAR_Forest_Wolf, 10, 1),
			new Unit(Prefabs.Units.CHAR_Forest_AngryMoose, 16, 2),
			new Unit(Prefabs.Units.CHAR_Forest_Bear_Standard, 18, 2)
		};

		private static Unit[] gloomrot = new Unit[14]
		{
			new Unit(Prefabs.Units.CHAR_Gloomrot_Pyro, 56, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Batoon, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Railgunner, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Tazer, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Technician, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Technician_Labworker, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_TractorBeamer, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_SentryOfficer, 60, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_SentryTurret, 60, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_SpiderTank_Driller, 60, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_AceIncinerator, 74, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_SpiderTank_LightningRod, 74, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_SpiderTank_Gattler, 77, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_SpiderTank_Zapper, 77, 1)
		};

		private static Unit[] harpy = new Unit[4]
		{
			new Unit(Prefabs.Units.CHAR_Harpy_Dasher, 66, 1),
			new Unit(Prefabs.Units.CHAR_Harpy_FeatherDuster, 66, 1),
			new Unit(Prefabs.Units.CHAR_Harpy_Sorceress, 68, 1),
			new Unit(Prefabs.Units.CHAR_Harpy_Scratcher, 70, 1)
		};

		private static Unit[] militia_units = new Unit[12]
		{
			new Unit(Prefabs.Units.CHAR_Militia_Hound, 36, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Light, 36, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Torchbearer, 36, 2),
			new Unit(Prefabs.Units.CHAR_Militia_InkCrawler, 38, 2),
			new Unit(Prefabs.Units.CHAR_Militia_Guard, 40, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Bomber, 47, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Longbowman, 42, 3),
			new Unit(Prefabs.Units.CHAR_Militia_Nun, 42, 3),
			new Unit(Prefabs.Units.CHAR_Militia_Miner_Standard, 50, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Heavy, 54, 3),
			new Unit(Prefabs.Units.CHAR_Militia_Devoted, 56, 2),
			new Unit(Prefabs.Units.CHAR_Militia_Crossbow, 70, 2)
		};

		private static Unit[] vhunter = new Unit[2]
		{
			new Unit(Prefabs.Units.CHAR_VHunter_Leader_VBlood, 44, 5),
			new Unit(Prefabs.Units.CHAR_VHunter_Jade_VBlood, 57, 5)
		};

		private static Unit[] wtf = new Unit[3]
		{
			new Unit(Prefabs.Units.CHAR_Scarecrow, 54, 3),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Sommelier_BarrelMinion, 50, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_HostileVillager_Werewolf, 20, 2)
		};

		private static Unit[] spiders = new Unit[7]
		{
			new Unit(Prefabs.Units.CHAR_Spider_Forestling, 20, 1),
			new Unit(Prefabs.Units.CHAR_Spider_Forest, 26, 1),
			new Unit(Prefabs.Units.CHAR_Spider_Baneling, 56, 1),
			new Unit(Prefabs.Units.CHAR_Spider_Spiderling, 56, 1),
			new Unit(Prefabs.Units.CHAR_Spider_Melee, 58, 2),
			new Unit(Prefabs.Units.CHAR_Spider_Range, 58, 2),
			new Unit(Prefabs.Units.CHAR_Spider_Broodmother, 60, 4)
		};

		private static Unit[] golems = new Unit[5]
		{
			new Unit(Prefabs.Units.CHAR_IronGolem, 36, 1),
			new Unit(Prefabs.Units.CHAR_StoneGolem, 36, 1),
			new Unit(Prefabs.Units.CHAR_CopperGolem, 42, 1),
			new Unit(Prefabs.Units.CHAR_RockElemental, 50, 1),
			new Unit(Prefabs.Units.CHAR_Treant, 57, 1)
		};

		private static Unit[] mutants = new Unit[5]
		{
			new Unit(Prefabs.Units.CHAR_Mutant_RatHorror, 58, 1),
			new Unit(Prefabs.Units.CHAR_Mutant_FleshGolem, 60, 2),
			new Unit(Prefabs.Units.CHAR_Mutant_Wolf, 64, 1),
			new Unit(Prefabs.Units.CHAR_Mutant_Spitter, 70, 2),
			new Unit(Prefabs.Units.CHAR_Mutant_Bear_Standard, 74, 2)
		};

		private static Unit[] undead_minions = new Unit[39]
		{
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonSoldier_TombSummon, 1, 1),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonSoldier_Withered, 1, 1),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonCrossbow_Graveyard, 2, 1),
			new Unit(Prefabs.Units.CHAR_Undead_RottingGhoul, 4, 1),
			new Unit(Prefabs.Units.CHAR_Undead_ArmoredSkeletonCrossbow_Farbane, 18, 1),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonCrossbow_GolemMinion, 18, 1),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonCrossbow_Farbane_OLD, 20, 1),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonSoldier_Armored_Farbane, 20, 1),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonSoldier_GolemMinion, 20, 1),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonApprentice, 22, 1),
			new Unit(Prefabs.Units.CHAR_Undead_UndyingGhoul, 25, 2),
			new Unit(Prefabs.Units.CHAR_Undead_Priest, 27, 3),
			new Unit(Prefabs.Units.CHAR_Undead_Ghoul_TombSummon, 30, 1),
			new Unit(Prefabs.Units.CHAR_Undead_FlyingSkull, 32, 2),
			new Unit(Prefabs.Units.CHAR_Undead_Assassin, 35, 3),
			new Unit(Prefabs.Units.CHAR_Undead_ArmoredSkeletonCrossbow_Dunley, 38, 1),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonGolem, 38, 3),
			new Unit(Prefabs.Units.CHAR_Undead_Ghoul_Armored_Farmlands, 40, 2),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonSoldier_Armored_Dunley, 40, 2),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonSoldier_Infiltrator, 40, 1),
			new Unit(Prefabs.Units.CHAR_Undead_Guardian, 42, 2),
			new Unit(Prefabs.Units.CHAR_Undead_Necromancer, 46, 3),
			new Unit(Prefabs.Units.CHAR_Undead_Necromancer_TombSummon, 46, 3),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonMage, 44, 3),
			new Unit(Prefabs.Units.CHAR_Unholy_Baneling, 58, 1),
			new Unit(Prefabs.Units.CHAR_Undead_CursedSmith_FloatingWeapon_Base, 60, 3),
			new Unit(Prefabs.Units.CHAR_Undead_CursedSmith_FloatingWeapon_Mace, 60, 3),
			new Unit(Prefabs.Units.CHAR_Undead_CursedSmith_FloatingWeapon_Slashers, 60, 3),
			new Unit(Prefabs.Units.CHAR_Undead_CursedSmith_FloatingWeapon_Spear, 60, 3),
			new Unit(Prefabs.Units.CHAR_Undead_CursedSmith_FloatingWeapon_Sword, 60, 3),
			new Unit(Prefabs.Units.CHAR_Undead_ShadowSoldier, 60, 2),
			new Unit(Prefabs.Units.CHAR_Undead_SkeletonSoldier_Base, 60, 1),
			new Unit(Prefabs.Units.CHAR_Undead_GhostMilitia_Crossbow, 63, 2),
			new Unit(Prefabs.Units.CHAR_Undead_GhostMilitia_Light, 63, 2),
			new Unit(Prefabs.Units.CHAR_Undead_ZealousCultist_Ghost, 64, 1),
			new Unit(Prefabs.Units.CHAR_Undead_GhostAssassin, 65, 3),
			new Unit(Prefabs.Units.CHAR_Undead_GhostBanshee, 65, 3),
			new Unit(Prefabs.Units.CHAR_Undead_GhostBanshee_TombSummon, 65, 3),
			new Unit(Prefabs.Units.CHAR_Undead_GhostGuardian, 65, 3)
		};

		private static Unit[] werewolves = new Unit[2]
		{
			new Unit(Prefabs.Units.CHAR_Werewolf, 62, 1),
			new Unit(Prefabs.Units.CHAR_WerewolfChieftain_VBlood, 64, 2)
		};

		private static Unit[] winter = new Unit[3]
		{
			new Unit(Prefabs.Units.CHAR_Winter_Wolf, 50, 1),
			new Unit(Prefabs.Units.CHAR_Winter_Moose, 52, 2),
			new Unit(Prefabs.Units.CHAR_Winter_Bear_Standard, 54, 2)
		};

		private static Unit[] servants = new Unit[59]
		{
			new Unit(Prefabs.Units.CHAR_Bandit_Bomber_Servant, 32, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Deadeye_Servant, 26, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Hunter_Servant, 16, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Miner_Standard_Servant, 14, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Mugger_Servant, 20, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Stalker_Servant, 30, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Thief_Servant, 18, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Thug_Servant, 16, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Trapper_Servant, 20, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Woodcutter_Standard_Servant, 14, 1),
			new Unit(Prefabs.Units.CHAR_Bandit_Worker_Gatherer_Servant, 14, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Archer_Servant, 56, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Cleric_Servant, 62, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Footman_Servant, 62, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Knight_2H_Servant, 68, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Knight_Shield_Servant, 68, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Lightweaver_Servant, 72, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Miner_Standard_Servant, 42, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Paladin_Servant, 74, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Priest_Servant, 74, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Rifleman_Servant, 62, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_SlaveMaster_Enforcer_Servant, 64, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_SlaveMaster_Sentry_Servant, 64, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_SlaveRuffian_Servant, 60, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Villager_Female_Servant, 50, 1),
			new Unit(Prefabs.Units.CHAR_ChurchOfLight_Villager_Male_Servant, 50, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Farmer_Servant, 34, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Nun_Servant, 46, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Villager_Female_Servant, 26, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Villager_Female_Sister_Servant, 20, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Villager_Male_Servant, 26, 1),
			new Unit(Prefabs.Units.CHAR_Farmlands_Woodcutter_Standard_Servant, 34, 1),
			new Unit(Prefabs.Units.CHAR_Militia_BellRinger_Servant, 36, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Bomber_Servant, 47, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Crossbow_Servant, 36, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Devoted_Servant, 56, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Guard_Servant, 40, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Heavy_Servant, 54, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Light_Servant, 36, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Torchbearer_Servant, 36, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Longbowman_Servant, 42, 1),
			new Unit(Prefabs.Units.CHAR_Militia_Miner_Standard_Servant, 40, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_AceIncinerator_Servant, 72, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Batoon_Servant, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Pyro_Servant, 56, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Railgunner_Servant, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_SentryOfficer_Servant, 60, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Tazer_Servant, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Technician_Labworker_Servant, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Technician_Servant, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_TractorBeamer_Servant, 58, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Villager_Female_Servant, 50, 1),
			new Unit(Prefabs.Units.CHAR_Gloomrot_Villager_Male_Servant, 50, 1),
			new Unit(Prefabs.Units.CHAR_NecromancyDagger_SkeletonBerserker_Armored_Farbane, 20, 1),
			new Unit(Prefabs.Units.CHAR_Paladin_FallenAngel, 80, 1),
			new Unit(Prefabs.Units.CHAR_Spectral_Guardian, 1, 1),
			new Unit(Prefabs.Units.CHAR_Spectral_SpellSlinger, 60, 1),
			new Unit(Prefabs.Units.CHAR_Unholy_DeathKnight, 60, 1),
			new Unit(Prefabs.Units.CHAR_Unholy_FallenAngel, 0, 1)
		};

		private static ArraySegment<Unit> GetUnitsForLevel(Unit[] units, int playerLevel)
		{
			int num = playerLevel + 10;
			int i;
			for (i = 1; i < units.Length && units[i].level < num; i++)
			{
			}
			return new ArraySegment<Unit>(units, 0, i);
		}

		public static ArraySegment<Unit> GetFactionUnits(Prefabs.Faction faction, int playerLevel, int wantedLevel)
		{
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Expected O, but got Unknown
			switch (faction)
			{
			case Prefabs.Faction.Bandits:
				return GetUnitsForLevel(bandit_units, playerLevel);
			case Prefabs.Faction.Undead:
				return GetUnitsForLevel(undead_minions, playerLevel);
			case Prefabs.Faction.Militia:
				if (wantedLevel > 3)
				{
					return GetUnitsForLevel(church, playerLevel);
				}
				if (wantedLevel > 1)
				{
					return GetUnitsForLevel(militia_units, playerLevel);
				}
				return GetUnitsForLevel(farmlands, playerLevel);
			case Prefabs.Faction.ChurchOfLum_SpotShapeshiftVampire:
				return GetUnitsForLevel(church, playerLevel);
			case Prefabs.Faction.Gloomrot:
				return GetUnitsForLevel(gloomrot, playerLevel);
			default:
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(25, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Enum.GetName(faction));
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" units not yet suppported");
				}
				logger.LogWarning(val);
				return GetUnitsForLevel(bandit_units, playerLevel);
			}
			}
		}
	}
	public class LazyDictionary<TKey, TValue> : Dictionary<TKey, TValue> where TValue : new()
	{
		public new TValue this[TKey key]
		{
			get
			{
				if (!ContainsKey(key))
				{
					Add(key, new TValue());
				}
				return base[key];
			}
			set
			{
				if (!ContainsKey(key))
				{
					Add(key, value);
				}
				else
				{
					base[key] = value;
				}
			}
		}
	}
	public static class Helper
	{
		private static Entity empty_entity = default(Entity);

		private static Random rand = new Random();

		public static ServerGameSettings SGS = null;

		public static ServerGameManager SGM = default(ServerGameManager);

		public static UserActivityGridSystem UAGS = null;

		public static int groupRange = 50;

		public static int buffGUID = 1444835872;

		public static int forbiddenBuffGUID = -161632603;

		public static bool buffLogging = false;

		public static bool deathLogging = false;

		public static PrefabGUID appliedBuff = Database.Buff.Buff_4pT2;

		public static PrefabGUID vBloodType = new PrefabGUID(-338774148);

		public static Regex rxName = new Regex("(?<=\\])[^\\[].*");

		public static bool FindPlayer(string name, bool mustOnline, out Entity playerEntity, out Entity userEntity)
		{
			//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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0088: 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_0091: 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_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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//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)
			EntityManager entityManager = Plugin.Server.EntityManager;
			name = name.ToLower().Trim();
			if (Cache.NamePlayerCache.TryGetValue(name.ToLower(), out var value))
			{
				playerEntity = value.CharEntity;
				userEntity = value.UserEntity;
				if (mustOnline && !((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity).IsConnected)
				{
					return false;
				}
				return true;
			}
			EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
			Enumerator<Entity> enumerator = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(current);
				if (mustOnline && !componentData.IsConnected)
				{
					continue;
				}
				string text = ((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString().ToLower().Trim();
				bool flag = text.Equals(name);
				if (!flag && text.EndsWith(name))
				{
					int num = text.IndexOf("]");
					if (num > 0 && text.Length > num && text.Substring(num + 1).Equals(name))
					{
						flag = true;
					}
				}
				if (flag)
				{
					userEntity = current;
					playerEntity = componentData.LocalCharacter._Entity;
					return true;
				}
			}
			playerEntity = empty_entity;
			userEntity = empty_entity;
			return false;
		}

		public static bool FindPlayer(ulong steamid, bool mustOnline, out Entity playerEntity, out Entity userEntity)
		{
			//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_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_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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003a: 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)
			EntityManager entityManager = Plugin.Server.EntityManager;
			if (Cache.SteamPlayerCache.TryGetValue(steamid, out var value))
			{
				playerEntity = value.CharEntity;
				userEntity = value.UserEntity;
				if (mustOnline && !((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity).IsConnected)
				{
					return false;
				}
				return true;
			}
			playerEntity = empty_entity;
			userEntity = empty_entity;
			return false;
		}

		public static int GetAllies(Entity playerCharacter, out PlayerGroup playerGroup)
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: 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_0070: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Expected O, but got Unknown
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_0677: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Expected O, but got Unknown
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Expected O, but got Unknown
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Expected O, but got Unknown
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Expected O, but got Unknown
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Expected O, but got Unknown
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = Plugin.Server.EntityManager;
			bool flag = default(bool);
			EntityManagerDebug debug;
			if (!((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(playerCharacter))
			{
				if (ExperienceSystem.xpLogging)
				{
					ManualLogSource logger = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Entity is not user: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(playerCharacter);
					}
					logger.LogInfo(val);
					ManualLogSource logger2 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Components for Player Character are: ");
						BepInExInfoLogInterpolatedStringHandler obj = val;
						entityManager = Plugin.Server.EntityManager;
						debug = ((EntityManager)(ref entityManager)).Debug;
						((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>(((EntityManagerDebug)(ref debug)).GetEntityInfo(playerCharacter));
					}
					logger2.LogInfo(val);
				}
				playerGroup = new PlayerGroup
				{
					Allies = new Dictionary<Entity, Entity>()
				};
				return 0;
			}
			if (ExperienceSystem.xpLogging)
			{
				ManualLogSource logger3 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Beginning To Parse Player Group");
				}
				logger3.LogInfo(val);
			}
			if (Cache.PlayerAllies.TryGetValue(playerCharacter, out playerGroup))
			{
				if (ExperienceSystem.xpLogging)
				{
					ManualLogSource logger4 = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Allies Found in Cache, timestamp is ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(playerGroup.TimeStamp);
					}
					logger4.LogInfo(val);
				}
				if ((DateTime.Now - playerGroup.TimeStamp).TotalSeconds < 300.0)
				{
					return playerGroup.AllyCount;
				}
				if (ExperienceSystem.xpLogging)
				{
					ManualLogSource logger5 = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Refreshing cached allies");
					}
					logger5.LogInfo(val);
				}
			}
			entityManager = Plugin.Server.EntityManager;
			Team val2 = default(Team);
			if (!((EntityManager)(ref entityManager)).TryGetComponentData<Team>(playerCharacter, ref val2))
			{
				if (ExperienceSystem.xpLogging)
				{
					ManualLogSource logger6 = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Could not get team for Player Character: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(playerCharacter);
					}
					logger6.LogInfo(val);
					ManualLogSource logger7 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Components for Player Character are: ");
						BepInExInfoLogInterpolatedStringHandler obj2 = val;
						entityManager = Plugin.Server.EntityManager;
						debug = ((EntityManager)(ref entityManager)).Debug;
						((BepInExLogInterpolatedStringHandler)obj2).AppendFormatted<string>(((EntityManagerDebug)(ref debug)).GetEntityInfo(playerCharacter));
					}
					logger7.LogInfo(val);
				}
				playerGroup = new PlayerGroup
				{
					Allies = new Dictionary<Entity, Entity>()
				};
				return 0;
			}
			if (ExperienceSystem.xpLogging)
			{
				ManualLogSource logger8 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Player Character Found Value: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(val2.Value);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - Faction Index: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(val2.FactionIndex);
				}
				logger8.LogInfo(val);
			}
			playerGroup.TimeStamp = DateTime.Now;
			Dictionary<Entity, Entity> dictionary = new Dictionary<Entity, Entity>();
			entityManager = Plugin.Server.EntityManager;
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val3 = new EntityQueryDesc();
			val3.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<PlayerCharacter>(),
				ComponentType.ReadOnly<IsConnected>()
			});
			val3.Options = (EntityQueryOptions)2;
			array[0] = val3;
			EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array);
			NativeArray<Entity> val5 = ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			if (ExperienceSystem.xpLogging)
			{
				ManualLogSource logger9 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": got connected PC entities buffer of length ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(val5.Length);
				}
				logger9.LogInfo(val);
			}
			Enumerator<Entity> enumerator = val5.GetEnumerator();
			Team val7 = default(Team);
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				Entity val6;
				if (ExperienceSystem.xpLogging)
				{
					ManualLogSource logger10 = Plugin.Logger;
					string text = DateTime.Now.ToString();
					val6 = current;
					logger10.LogInfo((object)(text + ": got Entity " + ((object)(Entity)(ref val6)).ToString()));
				}
				entityManager = Plugin.Server.EntityManager;
				if (((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(current))
				{
					if (ExperienceSystem.xpLogging)
					{
						ManualLogSource logger11 = Plugin.Logger;
						string text2 = DateTime.Now.ToString();
						val6 = current;
						logger11.LogInfo((object)(text2 + ": Entity is User " + ((object)(Entity)(ref val6)).ToString()));
					}
					if (((Entity)(ref current)).Equals(playerCharacter))
					{
						if (ExperienceSystem.xpLogging)
						{
							Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Entity is self"));
						}
						dictionary[current] = current;
						continue;
					}
					bool flag2 = false;
					try
					{
						if (ExperienceSystem.xpLogging)
						{
							Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Trying to get teams "));
						}
						entityManager = Plugin.Server.EntityManager;
						bool flag3 = ((EntityManager)(ref entityManager)).TryGetComponentData<Team>(current, ref val7);
						if (ExperienceSystem.xpLogging)
						{
							if (flag3)
							{
								Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": Team Value:" + val7.Value + " - Faction Index: " + val7.FactionIndex));
							}
							else
							{
								ManualLogSource logger12 = Plugin.Logger;
								string text3 = DateTime.Now.ToString();
								val6 = current;
								logger12.LogInfo((object)(text3 + ": Could not get team for entity: " + ((object)(Entity)(ref val6)).ToString()));
								ManualLogSource logger13 = Plugin.Logger;
								string text4 = DateTime.Now.ToString();
								entityManager = Plugin.Server.EntityManager;
								debug = ((EntityManager)(ref entityManager)).Debug;
								logger13.LogInfo((object)(text4 + ": Components for entity are: " + ((EntityManagerDebug)(ref debug)).GetEntityInfo(current)));
							}
						}
						flag2 = flag3 && val7.Value == val2.Value;
					}
					catch (Exception ex)
					{
						if (ExperienceSystem.xpLogging)
						{
							Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": IsAllies Failed " + ex.Message));
						}
					}
					if (flag2)
					{
						if (ExperienceSystem.xpLogging)
						{
							ManualLogSource logger14 = Plugin.Logger;
							BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(13, 3, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Allies: ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(playerCharacter);
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(current);
							}
							logger14.LogInfo(val);
						}
						dictionary[current] = current;
					}
					else if (ExperienceSystem.xpLogging)
					{
						ManualLogSource logger15 = Plugin.Logger;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 3, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(DateTime.Now);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Not allies: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(playerCharacter);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(current);
						}
						logger15.LogInfo(val);
					}
				}
				else if (ExperienceSystem.xpLogging)
				{
					Plugin.Logger.LogInfo((object)(DateTime.Now.ToString() + ": No Associated User!"));
				}
			}
			playerGroup.Allies = dictionary;
			playerGroup.AllyCount = dictionary.Count;
			Cache.PlayerAllies[playerCharacter] = playerGroup;
			return playerGroup.AllyCount;
		}

		public static void ApplyBuff(Entity User, Entity Char, PrefabGUID GUID)
		{
			//IL_0005: 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_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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0034: 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)
			Plugin.Server.GetExistingSystem<DebugEventsSystem>();
			FromCharacter val = default(FromCharacter);
			val.User = User;
			val.Character = Char;
			ApplyBuffDebugEvent val2 = default(ApplyBuffDebugEvent);
			val2.BuffPrefabGUID = GUID;
			ApplyBuffDebugEvent item = val2;
			Database.playerBuffs.Add(item);
		}

		public static string GetTrueName(string name)
		{
			MatchCollection matchCollection = rxName.Matches(name);
			if (matchCollection.Count > 0)
			{
				name = matchCollection[matchCollection.Count - 1].ToString();
			}
			return name;
		}

		public static void CreatePlayerCache()
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0070: 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_0085: 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_008d: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			Cache.NamePlayerCache.Clear();
			Cache.SteamPlayerCache.Clear();
			EntityManager entityManager = Plugin.Server.EntityManager;
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
			val.Options = (EntityQueryOptions)2;
			array[0] = val;
			EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array);
			Enumerator<Entity> enumerator = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				entityManager = Plugin.Server.EntityManager;
				User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(current);
				PlayerData value = new PlayerData(((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString(), componentData.PlatformId, componentData.IsConnected, current, componentData.LocalCharacter._Entity);
				Cache.NamePlayerCache.TryAdd(GetTrueName(((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString().ToLower()), value);
				Cache.SteamPlayerCache.TryAdd(componentData.PlatformId, value);
			}
			Plugin.Logger.LogWarning((object)"Player Cache Created.");
		}

		public static Dictionary<TKey, TVal> LoadDB<TKey, TVal>(string specificFile)
		{
			confirmFile("BepInEx/config/RPGMods/Experience/", specificFile);
			confirmFile("BepInEx/config/RPGMods/Experience/Backup/", specificFile);
			string json = File.ReadAllText("BepInEx/config/RPGMods/Experience/" + specificFile);
			Dictionary<TKey, TVal> dictionary;
			try
			{
				dictionary = JsonSerializer.Deserialize<Dictionary<TKey, TVal>>(json);
				if (dictionary == null)
				{
					json = File.ReadAllText("BepInEx/config/RPGMods/Experience/Backup/" + specificFile);
					dictionary = JsonSerializer.Deserialize<Dictionary<TKey, TVal>>(json);
				}
				Plugin.Logger.LogWarning((object)(DateTime.Now.ToString() + ": DB Populated for " + specificFile));
			}
			catch (Exception ex)
			{
				dictionary = new Dictionary<TKey, TVal>();
				Plugin.Logger.LogWarning((object)(DateTime.Now.ToString() + ": DB Created for " + specificFile));
				Plugin.Logger.LogWarning((object)(DateTime.Now.ToString() + ": Caught error for " + specificFile + " of: " + ex.ToString()));
			}
			return dictionary;
		}

		public static void TeleportTo(ChatCommandContext ctx, Tuple<float, float, float> position)
		{
			//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_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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_003e: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00a8: 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)
			EntityManager entityManager = Plugin.Server.EntityManager;
			Entity val = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadWrite<FromCharacter>(),
				ComponentType.ReadWrite<PlayerTeleportDebugEvent>()
			});
			entityManager = Plugin.Server.EntityManager;
			((EntityManager)(ref entityManager)).SetComponentData<FromCharacter>(val, new FromCharacter
			{
				User = ctx.Event.SenderUserEntity,
				Character = ctx.Event.SenderCharacterEntity
			});
			entityManager = Plugin.Server.EntityManager;
			((EntityManager)(ref entityManager)).SetComponentData<PlayerTeleportDebugEvent>(val, new PlayerTeleportDebugEvent
			{
				Position = new float3(position.Item1, position.Item2, position.Item3),
				Target = (TeleportTarget)0
			});
		}

		public static void AddItemToInventory(ChatCommandContext ctx, PrefabGUID guid, int amount)
		{
			//IL_0005: 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_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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Server.GetExistingSystem<GameDataSystem>();
			AddItemSettings val = default(AddItemSettings);
			val.EntityManager = Plugin.Server.EntityManager;
			val.DropRemainder = true;
			val.EquipIfPossible = true;
			InventoryUtilitiesServer.TryAddItem(val, ctx.Event.SenderCharacterEntity, guid, amount);
		}

		public static bool IsPlayerInCombat(Entity player)
		{
			//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_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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (!BuffUtility.HasBuff(Plugin.Server.EntityManager, player, PrefabIdentifier.op_Implicit(Database.Buff.InCombat)))
			{
				return BuffUtility.HasBuff(Plugin.Server.EntityManager, player, PrefabIdentifier.op_Implicit(Database.Buff.InCombat_PvP));
			}
			return true;
		}

		public static void confirmFile(string address, string file)
		{
			try
			{
				Directory.CreateDirectory(address);
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)(DateTime.Now.ToString() + ": Error creating directory at " + address + "\n Error is: " + ex.Message));
			}
			try
			{
				if (!File.Exists(address + file))
				{
					File.Create(address + file).Dispose();
				}
			}
			catch (Exception ex2)
			{
				Plugin.Logger.LogWarning((object)(DateTime.Now.ToString() + ": Error creating file at " + address + "\n Error is: " + ex2.Message));
			}
		}
	}
	public class ItemKit
	{
		public string Name { get; }

		public Dictionary<int, int> PrefabGUIDs { get; }

		public ItemKit(string name, Dictionary<int, int> prefabGuids)
		{
			Name = name;
			PrefabGUIDs = prefabGuids;
		}
	}
	public static class Output
	{
		public static void CustomErrorMessage(VChatEvent ev, string message)
		{
			//IL_0005: 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)
			ServerChatUtils.SendSystemMessageToClient(Plugin.Server.EntityManager, ev.User, "<color=#ff0000