Decompiled source of SanguineArchives v0.1.0

SanguineArchives.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using Bloodstone.API;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Behaviours;
using ProjectM.Gameplay.Clan;
using ProjectM.Gameplay.Systems;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Scripting;
using ProjectM.Shared;
using SanguineArchives.Common;
using SanguineArchives.Common.Commands.Converters;
using SanguineArchives.Common.KindredCommands.Data;
using SanguineArchives.Common.KindredCommands.Models;
using SanguineArchives.Common.KindredCommands.Services;
using SanguineArchives.Common.Utils;
using SanguineArchives.VBloodArchives.Data;
using SanguineArchives.VBloodArchives.Services;
using Stunlock.Core;
using Stunlock.Localization;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("dokebi")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Keep an archive of V Blood fights")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+95f9f952fe3ac02780a42fd85f0082d26c0f4109")]
[assembly: AssemblyProduct("SanguineArchives")]
[assembly: AssemblyTitle("SanguineArchives")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 SanguineArchives
{
	[BepInPlugin("dokebi21.SanguineArchives", "SanguineArchives", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[Reloadable]
	public class Plugin : BasePlugin
	{
		internal static Harmony Harmony;

		public static ManualLogSource LogInstance { get; private set; }

		public override void Load()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			if (!(Application.productName != "VRisingServer"))
			{
				ManualLogSource log = ((BasePlugin)this).Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("dokebi21.SanguineArchives");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.0");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
				}
				log.LogInfo(val);
				LogInstance = ((BasePlugin)this).Log;
				Harmony = new Harmony("dokebi21.SanguineArchives");
				Harmony.PatchAll(Assembly.GetExecutingAssembly());
				CommandRegistry.RegisterAll();
			}
		}

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

		public const string PLUGIN_NAME = "SanguineArchives";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}
namespace SanguineArchives.VBloodArchives.Services
{
	internal class KillVBloodService
	{
		public Dictionary<string, HashSet<string>> vbloodKills = new Dictionary<string, HashSet<string>>();

		private PrefabCollectionSystem _prefabCollectionSystem = Core.PrefabCollectionSystem;

		public Dictionary<string, DateTime> lastKillerUpdate = new Dictionary<string, DateTime>();

		public Dictionary<string, float> combatDuration = new Dictionary<string, float>();

		public Dictionary<string, Dictionary<string, float>> maxPlayerLevels = new Dictionary<string, Dictionary<string, float>>();

		public Dictionary<string, bool> startedWhileRecovering = new Dictionary<string, bool>();

		public void SetCombatDuration(string vblood, float duration)
		{
			combatDuration[vblood] = duration;
		}

		public void SetMaxPlayerLevels(string vblood, Dictionary<string, float> playerLevels)
		{
			maxPlayerLevels[vblood] = playerLevels;
		}

		public void ResetStartedWhileRecovering(string vblood)
		{
			startedWhileRecovering.Remove(vblood);
		}

		public void AddKiller(string vblood, string killerCharacterName)
		{
			if (!vbloodKills.ContainsKey(vblood))
			{
				vbloodKills[vblood] = new HashSet<string>();
			}
			vbloodKills[vblood].Add(killerCharacterName);
		}

		public void RemoveKillers(string vblood)
		{
			vbloodKills[vblood] = new HashSet<string>();
			SetCombatDuration(vblood, 0f);
			maxPlayerLevels.Remove(vblood);
			startedWhileRecovering.Remove(vblood);
		}

		public List<string> GetKillers(string vblood)
		{
			return vbloodKills[vblood].ToList();
		}

		public bool CheckPlayerLevelsDuringCombat(string vblood)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			if (Core.Prefabs.TryGetItem(vblood, out var prefab))
			{
				PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap;
				Entity entity = default(Entity);
				if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(prefab, ref entity))
				{
					num = ModifiableInt.op_Implicit(entity.Read<UnitLevel>().Level);
				}
			}
			float num2 = -1f;
			foreach (KeyValuePair<string, float> item in maxPlayerLevels[vblood])
			{
				item.Deconstruct(out var key, out var value);
				string text = key;
				float val = value;
				num2 = Math.Max(num2, val);
			}
			return num2 <= (float)num;
		}

		public bool CheckStartedWhileRecovering(string vblood)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ManualLogSource log = Core.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CheckStartedWhileRecovering: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(startedWhileRecovering.ContainsKey(vblood));
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" vs ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(startedWhileRecovering.ContainsKey(vblood) && startedWhileRecovering[vblood]);
			}
			log.LogInfo(val);
			return startedWhileRecovering.ContainsKey(vblood) && startedWhileRecovering[vblood];
		}

		public void AnnounceVBloodKill(string vblood)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			List<string> killers = GetKillers(vblood);
			if (killers.Count == 0)
			{
				RemoveKillers(vblood);
				return;
			}
			combatDuration.TryGetValue(vblood, out var value);
			string text = ChatColor.Yellow(CombinedKillersLabel(vblood));
			if (!Core.Prefabs.TryGetItem(vblood, out var prefab))
			{
				return;
			}
			string value2 = ChatColor.Purple(prefab.GetLocalizedName());
			string message = ChatColor.Green($"Congratulations to {text} for defeating {value2} in {value:F2} seconds!");
			ManualLogSource log = Core.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AnnounceVBloodKill: VBlood ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(vblood);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" was killed by ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("!");
			}
			log.LogInfo(val);
			if (killers.Count == 1 && maxPlayerLevels[vblood].Count == 1)
			{
				VBloodRecord vBloodRecord = default(VBloodRecord);
				vBloodRecord.CharacterName = killers[0];
				vBloodRecord.DateTime = DateTime.Now.ToString("o");
				vBloodRecord.CombatDuration = value;
				VBloodRecord vBloodRecord2 = vBloodRecord;
				if (vBloodRecord2.CombatDuration == 0f)
				{
					SendVBloodMessageToAll(message);
					RemoveKillers(vblood);
					return;
				}
				if (!CheckPlayerLevelsDuringCombat(vblood) || CheckStartedWhileRecovering(vblood))
				{
					SendVBloodMessageToAll(message);
					RemoveKillers(vblood);
					return;
				}
				if (Core.VBloodRecordsService.IsNewTopRecord(vblood, vBloodRecord2))
				{
					SendVBloodMessageToAll(message);
					string message2 = ChatColor.Green("** A new top record has been set! **");
					SendVBloodMessageToAll(message2);
					if (Core.VBloodRecordsService.TryGetTopRecordForVBlood(vblood, out var _))
					{
						float value3 = Core.VBloodRecordsService.GetCurrentTopRecord(vblood) - value;
						string text2 = ChatColor.Green($"{value3:F2}");
						string message3 = "The new record is faster by " + text2 + " seconds.";
						SendVBloodMessageToAll(message3);
					}
				}
				else
				{
					SendVBloodMessageToAll(message);
				}
				if (Core.VBloodRecordsService.IsNewPlayerRecord(vblood, vBloodRecord2))
				{
					string message4 = ChatColor.Green("** A new personal record has been set! **");
					SendVBloodMessageToPlayers(killers, message4);
					if (Core.VBloodRecordsService.TryGetPlayerRecordForVBlood(vblood, vBloodRecord2.CharacterName, out var _))
					{
						float value4 = Core.VBloodRecordsService.GetCurrentPlayerRecord(vblood, vBloodRecord2.CharacterName) - value;
						string text3 = ChatColor.Green($"{value4:F2}");
						string message5 = "Your new record is faster by " + text3 + " seconds.";
						SendVBloodMessageToPlayers(killers, message5);
					}
				}
				Core.VBloodRecordsService.AddRecord(vblood, vBloodRecord2);
			}
			if (killers.Count > 1 || maxPlayerLevels[vblood].Count > 1)
			{
				SendVBloodMessageToAll(message);
			}
			RemoveKillers(vblood);
		}

		public void SendVBloodMessageToAll(string message)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_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)
			IEnumerable<Entity> usersOnline = PlayerService.GetUsersOnline();
			foreach (Entity item in usersOnline)
			{
				Player player = new Player(item);
				ServerChatUtils.SendSystemMessageToClient(VWorld.Server.EntityManager, player.User.Read<User>(), ChatColor.Gray(message));
			}
		}

		public void SendVBloodMessageToPlayers(List<string> players, string message)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			IEnumerable<Entity> usersOnline = PlayerService.GetUsersOnline();
			foreach (Entity item in usersOnline)
			{
				Player player = new Player(item);
				if (players.Contains(player.Name))
				{
					ServerChatUtils.SendSystemMessageToClient(VWorld.Server.EntityManager, player.User.Read<User>(), ChatColor.Gray(message));
				}
			}
		}

		private string CombinedKillersLabel(string vblood)
		{
			List<string> killers = GetKillers(vblood);
			StringBuilder stringBuilder = new StringBuilder();
			if (killers.Count == 0)
			{
				return null;
			}
			if (killers.Count == 1)
			{
				stringBuilder.Append(ChatColor.Yellow(killers[0]));
			}
			if (killers.Count == 2)
			{
				StringBuilder stringBuilder2 = stringBuilder;
				StringBuilder stringBuilder3 = stringBuilder2;
				StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(5, 2, stringBuilder2);
				handler.AppendFormatted(ChatColor.Yellow(killers[0]));
				handler.AppendLiteral(" and ");
				handler.AppendFormatted(ChatColor.Yellow(killers[1]));
				stringBuilder3.Append(ref handler);
			}
			if (killers.Count > 2)
			{
				for (int i = 0; i < killers.Count; i++)
				{
					if (i == killers.Count - 1)
					{
						StringBuilder stringBuilder2 = stringBuilder;
						StringBuilder stringBuilder4 = stringBuilder2;
						StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(4, 1, stringBuilder2);
						handler.AppendLiteral("and ");
						handler.AppendFormatted(ChatColor.Yellow(killers[i]));
						stringBuilder4.Append(ref handler);
					}
					else
					{
						StringBuilder stringBuilder2 = stringBuilder;
						StringBuilder stringBuilder5 = stringBuilder2;
						StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(2, 1, stringBuilder2);
						handler.AppendFormatted(ChatColor.Yellow(killers[i]));
						handler.AppendLiteral(", ");
						stringBuilder5.Append(ref handler);
					}
				}
			}
			return stringBuilder.ToString();
		}
	}
	public class TrackVBloodCombat
	{
		private readonly Dictionary<string, Dictionary<string, float>> vbloodPlayerLevels = new Dictionary<string, Dictionary<string, float>>();

		public static Dictionary<string, bool> vbloodStillRecovering = new Dictionary<string, bool>();

		public TrackVBloodCombat()
		{
			Core.StartCoroutine(MonitorForPlayerLevels());
		}

		public void StartTrackingForVBlood(string vblood, ref Entity playerEntity, ref Entity vbloodEntity)
		{
			//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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			if (!vbloodPlayerLevels.ContainsKey(vblood))
			{
				vbloodPlayerLevels[vblood] = new Dictionary<string, float>();
			}
			PlayerCharacter val = playerEntity.Read<PlayerCharacter>();
			string text = ((object)(FixedString64Bytes)(ref val.Name)).ToString();
			Entity userEntity = playerEntity.Read<PlayerCharacter>().UserEntity;
			Player player = new Player(userEntity);
			float playerEquipmentLevel = Helper.GetPlayerEquipmentLevel(player);
			if (vbloodPlayerLevels[vblood].ContainsKey(player.Name))
			{
				vbloodPlayerLevels[vblood][player.Name] = Math.Max(vbloodPlayerLevels[vblood][player.Name], playerEquipmentLevel);
			}
			else
			{
				vbloodPlayerLevels[vblood][player.Name] = playerEquipmentLevel;
			}
			if (vbloodPlayerLevels[vblood].Count > 1)
			{
				if (Core.Prefabs.TryGetItem(vblood, out var prefab))
				{
					string value = ChatColor.Purple(prefab.GetLocalizedName());
					string message = $"Your fight with {value} will not be recorded. {ChatColor.Yellow(text)} joined the fight.";
					Core.KillVBloodService.SendVBloodMessageToPlayers(vbloodPlayerLevels[vblood].Keys.ToList(), message);
				}
				return;
			}
			int num = 0;
			if (!Core.Prefabs.TryGetItem(vblood, out var prefab2))
			{
				return;
			}
			PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap;
			Entity entity = default(Entity);
			if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(prefab2, ref entity))
			{
				return;
			}
			num = ModifiableInt.op_Implicit(entity.Read<UnitLevel>().Level);
			if (Core.Prefabs.TryGetItem(vblood, out var prefab3))
			{
				string text2 = ChatColor.Purple(prefab3.GetLocalizedName());
				float num2 = vbloodPlayerLevels[vblood][player.Name];
				if (num2 > (float)num)
				{
					string message2 = "Your fight with " + text2 + " will not be recorded. Your level is too high.";
					Core.KillVBloodService.SendVBloodMessageToPlayers(new List<string>(1) { text }, message2);
				}
				else if (vbloodStillRecovering.ContainsKey(vblood) && vbloodStillRecovering[vblood])
				{
					Core.KillVBloodService.startedWhileRecovering[vblood] = true;
					string message3 = "Your fight with " + text2 + " will not be recorded. Enemy not fully recovered yet.";
					Core.KillVBloodService.SendVBloodMessageToPlayers(new List<string>(1) { text }, message3);
				}
				else
				{
					Core.KillVBloodService.startedWhileRecovering[vblood] = false;
					string message4 = "Your fight with " + text2 + " started. Good luck!";
					Core.KillVBloodService.SendVBloodMessageToPlayers(new List<string>(1) { text }, message4);
				}
			}
		}

		public void StopTrackingForVBlood(string vblood, bool isDead)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!vbloodPlayerLevels.ContainsKey(vblood))
			{
				return;
			}
			if (!isDead)
			{
				if (!Core.Prefabs.TryGetItem(vblood, out var prefab))
				{
					return;
				}
				string text = ChatColor.Purple(prefab.GetLocalizedName());
				string message = "Your fight with " + text + " ended. Aggro was reset.";
				Core.KillVBloodService.SendVBloodMessageToPlayers(vbloodPlayerLevels[vblood].Keys.ToList(), message);
			}
			Core.KillVBloodService.SetMaxPlayerLevels(vblood, new Dictionary<string, float>(vbloodPlayerLevels[vblood]));
			vbloodPlayerLevels.Remove(vblood);
		}

		private IEnumerator MonitorForPlayerLevels()
		{
			Entity prefabEntity = default(Entity);
			while (true)
			{
				foreach (KeyValuePair<string, Dictionary<string, float>> vbloodPlayerLevel in vbloodPlayerLevels)
				{
					vbloodPlayerLevel.Deconstruct(out var key, out var value);
					string vblood = key;
					Dictionary<string, float> cachedLevels = value;
					IEnumerable<Entity> usersOnline = Core.Players.GetCachedUsersOnline();
					foreach (Entity user in usersOnline)
					{
						Player player = new Player(user);
						if (!cachedLevels.TryGetValue(player.Name, out var cachedLevel))
						{
							continue;
						}
						float currentLevel = Helper.GetPlayerEquipmentLevel(player);
						if (cachedLevel < currentLevel)
						{
							if (Core.Prefabs.TryGetItem(vblood, out var prefabGuid))
							{
								PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap;
								if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(prefabGuid, ref prefabEntity))
								{
									int vbloodLevel = ModifiableInt.op_Implicit(prefabEntity.Read<UnitLevel>().Level);
									if (cachedLevel <= (float)vbloodLevel && currentLevel > (float)vbloodLevel)
									{
										if (!Core.Prefabs.TryGetItem(vblood, out var vbloodPrefab))
										{
											break;
										}
										string vbloodLabel = ChatColor.Purple(vbloodPrefab.GetLocalizedName());
										string msg = $"Your fight with {vbloodLabel} will not be recorded. A player level is too high ({ChatColor.Yellow(player.Name)}).";
										Core.KillVBloodService.SendVBloodMessageToPlayers(vbloodPlayerLevels[vblood].Keys.ToList(), msg);
										vbloodPrefab = default(PrefabGUID);
									}
								}
								prefabEntity = default(Entity);
							}
							prefabGuid = default(PrefabGUID);
						}
						cachedLevels[player.Name] = Math.Max(cachedLevel, currentLevel);
					}
				}
				yield return null;
			}
		}
	}
	public struct VBloodRecord
	{
		public string CharacterName { get; set; }

		public string DateTime { get; set; }

		public float CombatDuration { get; set; }
	}
	public class VBloodRecordsService
	{
		public Dictionary<string, List<VBloodRecord>> vbloodRecords = new Dictionary<string, List<VBloodRecord>>(VBloodCollectionData.DefaultVBloodRecords);

		protected static readonly string CONFIG_PATH = Path.Combine(Paths.ConfigPath, "SanguineArchives");

		protected string RecordsConfigPath => Path.Combine(CONFIG_PATH, "vblood_combat_records.json");

		public VBloodRecordsService()
		{
			LoadRecords();
		}

		public float GetVBloodLevel(string vblood)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			if (Core.Prefabs.TryGetItem(vblood, out var prefab))
			{
				PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap;
				Entity entity = default(Entity);
				if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(prefab, ref entity))
				{
					num = ModifiableInt.op_Implicit(entity.Read<UnitLevel>().Level);
				}
			}
			return num;
		}

		public bool IsPlayerLevelAcceptable(string vblood, string characterName)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (Core.Players.TryFindName(FixedString64Bytes.op_Implicit(characterName.ToLower()), out var playerData))
			{
				Entity charEntity = playerData.CharEntity;
				Equipment val = charEntity.Read<Equipment>();
				float num = ModifiableFloat.op_Implicit(val.ArmorLevel) + ModifiableFloat.op_Implicit(val.SpellLevel) + ModifiableFloat.op_Implicit(val.WeaponLevel);
				float vBloodLevel = GetVBloodLevel(vblood);
				return num <= vBloodLevel;
			}
			return false;
		}

		public void AddRecord(string vblood, VBloodRecord newRecord)
		{
			int num = vbloodRecords[vblood].FindIndex((VBloodRecord r) => r.CharacterName == newRecord.CharacterName);
			if (num == -1)
			{
				vbloodRecords[vblood].Add(newRecord);
			}
			else
			{
				VBloodRecord vBloodRecord = vbloodRecords[vblood][num];
				if (newRecord.CombatDuration < vBloodRecord.CombatDuration)
				{
					vbloodRecords[vblood][num] = newRecord;
				}
			}
			SaveRecords();
		}

		public List<VBloodRecord> GetRecordsForVBlood(string vblood)
		{
			if (vbloodRecords.ContainsKey(vblood))
			{
				return vbloodRecords[vblood].OrderBy((VBloodRecord kvp) => kvp.CombatDuration).ToList();
			}
			return new List<VBloodRecord>();
		}

		public Dictionary<string, VBloodRecord> GetRecordsForPlayer(string characterName)
		{
			Dictionary<string, VBloodRecord> dictionary = new Dictionary<string, VBloodRecord>();
			foreach (KeyValuePair<string, List<VBloodRecord>> vbloodRecord in vbloodRecords)
			{
				string key = vbloodRecord.Key;
				int num = vbloodRecords[key].FindIndex((VBloodRecord r) => r.CharacterName == characterName);
				if (num != -1)
				{
					dictionary.Add(key, vbloodRecords[key][num]);
				}
			}
			return dictionary;
		}

		public Dictionary<string, VBloodRecord> GetRecordsForPlayerByDate(string characterName, int count)
		{
			Dictionary<string, VBloodRecord> recordsForPlayer = GetRecordsForPlayer(characterName);
			IEnumerable<KeyValuePair<string, VBloodRecord>> source = recordsForPlayer.OrderByDescending((KeyValuePair<string, VBloodRecord> kvp) => kvp.Value.DateTime).Take(count);
			return source.ToDictionary((KeyValuePair<string, VBloodRecord> kvp) => kvp.Key, (KeyValuePair<string, VBloodRecord> kvp) => kvp.Value);
		}

		public Dictionary<string, VBloodRecord> GetTopRecords()
		{
			Dictionary<string, VBloodRecord> dictionary = new Dictionary<string, VBloodRecord>();
			foreach (KeyValuePair<string, List<VBloodRecord>> vbloodRecord in vbloodRecords)
			{
				string key = vbloodRecord.Key;
				if (vbloodRecords[key].Count == 0)
				{
					continue;
				}
				VBloodRecord value = vbloodRecords[key][0];
				foreach (VBloodRecord item in vbloodRecords[key])
				{
					if (value.CombatDuration > item.CombatDuration)
					{
						value = item;
					}
				}
				dictionary[key] = value;
			}
			return dictionary;
		}

		public Dictionary<string, VBloodRecord> GetTopRecordsByDate(int count)
		{
			Dictionary<string, VBloodRecord> topRecords = GetTopRecords();
			IEnumerable<KeyValuePair<string, VBloodRecord>> source = topRecords.OrderByDescending((KeyValuePair<string, VBloodRecord> kvp) => kvp.Value.DateTime).Take(count);
			return source.ToDictionary((KeyValuePair<string, VBloodRecord> kvp) => kvp.Key, (KeyValuePair<string, VBloodRecord> kvp) => kvp.Value);
		}

		public Dictionary<string, VBloodRecord> GetTopRecordsForVBloods(List<string> vbloods)
		{
			Dictionary<string, VBloodRecord> dictionary = new Dictionary<string, VBloodRecord>();
			foreach (string vblood in vbloods)
			{
				if (vbloodRecords[vblood].Count == 0)
				{
					continue;
				}
				VBloodRecord value = vbloodRecords[vblood][0];
				foreach (VBloodRecord item in vbloodRecords[vblood])
				{
					if (value.CombatDuration > item.CombatDuration)
					{
						value = item;
					}
				}
				dictionary[vblood] = value;
			}
			return dictionary;
		}

		public bool IsNewTopRecord(string vblood, VBloodRecord record)
		{
			if (TryGetTopRecordForVBlood(vblood, out var topRecord))
			{
				return record.CombatDuration < topRecord.CombatDuration;
			}
			return true;
		}

		public float GetCurrentPlayerRecord(string vblood, string characterName)
		{
			if (TryGetPlayerRecordForVBlood(vblood, characterName, out var playerRecord))
			{
				return playerRecord.CombatDuration;
			}
			return -1f;
		}

		public float GetCurrentTopRecord(string vblood)
		{
			if (TryGetTopRecordForVBlood(vblood, out var topRecord))
			{
				return topRecord.CombatDuration;
			}
			return -1f;
		}

		public bool IsNewPlayerRecord(string vblood, VBloodRecord record)
		{
			if (TryGetPlayerRecordForVBlood(vblood, record.CharacterName, out var playerRecord))
			{
				return record.CombatDuration < playerRecord.CombatDuration;
			}
			return true;
		}

		public bool TryGetPlayerRecordForVBlood(string vblood, string characterName, out VBloodRecord playerRecord)
		{
			if (vbloodRecords[vblood].Count == 0)
			{
				playerRecord = default(VBloodRecord);
				return false;
			}
			int num = vbloodRecords[vblood].FindIndex((VBloodRecord r) => r.CharacterName == characterName);
			if (num == -1)
			{
				playerRecord = default(VBloodRecord);
				return false;
			}
			playerRecord = vbloodRecords[vblood][num];
			return true;
		}

		public bool TryGetTopRecordForVBlood(string vblood, out VBloodRecord topRecord)
		{
			if (vbloodRecords[vblood].Count == 0)
			{
				topRecord = default(VBloodRecord);
				return false;
			}
			topRecord = vbloodRecords[vblood][0];
			foreach (VBloodRecord item in vbloodRecords[vblood])
			{
				if (topRecord.CombatDuration > item.CombatDuration)
				{
					topRecord = item;
				}
			}
			return true;
		}

		public string formatDateTime(string dateTime)
		{
			return DateTime.Parse(dateTime).ToString("yyyy-MM-dd hh:mm tt");
		}

		public void SaveRecords()
		{
			if (!Directory.Exists(CONFIG_PATH))
			{
				Directory.CreateDirectory(CONFIG_PATH);
			}
			JsonSerializerOptions options = new JsonSerializerOptions
			{
				WriteIndented = true
			};
			string contents = JsonSerializer.Serialize(vbloodRecords, options);
			File.WriteAllText(RecordsConfigPath, contents);
		}

		public void LoadRecords()
		{
			if (File.Exists(RecordsConfigPath))
			{
				string json = File.ReadAllText(RecordsConfigPath);
				vbloodRecords = JsonSerializer.Deserialize<Dictionary<string, List<VBloodRecord>>>(json) ?? new Dictionary<string, List<VBloodRecord>>();
			}
			else
			{
				SaveRecords();
			}
		}
	}
}
namespace SanguineArchives.VBloodArchives.Patches
{
	[HarmonyPatch(typeof(CreateGameplayEventOnBehaviourStateChangedSystem), "OnUpdate")]
	internal static class BehaviorStateChangedSystemPatch
	{
		private static void Prefix(CreateGameplayEventOnBehaviourStateChangedSystem __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_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_006d: 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_0076: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_008f: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Invalid comparison between Unknown and I4
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			EntityQuery _query_221632411_ = __instance.__query_221632411_0;
			NativeArray<Entity> val = ((EntityQuery)(ref _query_221632411_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<Entity> enumerator = val.GetEnumerator();
				bool flag = default(bool);
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (!current.Has<BehaviourTreeStateChangedEvent>())
					{
						continue;
					}
					BehaviourTreeStateChangedEvent val2 = current.Read<BehaviourTreeStateChangedEvent>();
					if (val2.Entity.Has<VBloodUnit>())
					{
						GenericEnemyState previousState = val2.PreviousState;
						GenericEnemyState newState = val2.NewState;
						Entity entity = val2.Entity;
						Health val3 = entity.Read<Health>();
						PrefabGUID prefabGuid = entity.Read<PrefabGUID>();
						string prefabName = prefabGuid.GetPrefabName();
						ManualLogSource log = Core.Log;
						BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(42, 5, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("BehaviourTreeStateChangedEvent: ");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(prefabName);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" - ");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<GenericEnemyState>(previousState);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("->");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<GenericEnemyState>(newState);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" HP:");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<float>(val3.Value);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("/");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<float>(((ModifiableFloat)(ref val3.MaxHealth)).Value);
						}
						log.LogInfo(val4);
						if ((previousState & 0x140008) != 0 && (newState & 0x140008) == 0)
						{
							Core.StartCoroutine(WaitForFullRecovery(prefabName, entity));
						}
					}
				}
			}
			finally
			{
				val.Dispose();
			}
		}

		private static IEnumerator WaitForFullRecovery(string vbloodString, Entity vbloodEntity)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Health health = vbloodEntity.Read<Health>();
			bool isFullHealth = health.Value >= ((ModifiableFloat)(ref health.MaxHealth)).Value;
			GenericEnemyState currState = vbloodEntity.Read<BehaviourTreeState>().Value;
			while ((currState & 0x140008) == 0 && !isFullHealth)
			{
				TrackVBloodCombat.vbloodStillRecovering[vbloodString] = !isFullHealth;
				health = vbloodEntity.Read<Health>();
				isFullHealth = health.Value >= ((ModifiableFloat)(ref health.MaxHealth)).Value;
				currState = vbloodEntity.Read<BehaviourTreeState>().Value;
				yield return null;
			}
			TrackVBloodCombat.vbloodStillRecovering[vbloodString] = false;
			ManualLogSource log = Core.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("WaitForFullRecovery: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(vbloodString);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<GenericEnemyState>(currState);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" HP:");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(health.Value);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(((ModifiableFloat)(ref health.MaxHealth)).Value);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - Done");
			}
			log.LogInfo(val);
		}
	}
	[HarmonyPatch]
	internal class DeathVBloodPatch
	{
		private const double SendMessageDelay = 2.0;

		private static bool _checkKiller;

		[HarmonyPatch(typeof(VBloodSystem), "OnUpdate")]
		[HarmonyPrefix]
		private static void OnUpdate_Prefix(VBloodSystem __instance)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				OnDeathVBlood(__instance, __instance.EventList);
			}
			catch (Exception ex)
			{
				Core.Log.LogError((object)ex);
			}
		}

		public static void OnDeathVBlood(VBloodSystem sender, NativeList<VBloodConsumed> deathEvents)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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)
			if (deathEvents.Length > 0)
			{
				Enumerator<VBloodConsumed> enumerator = deathEvents.GetEnumerator();
				while (enumerator.MoveNext())
				{
					VBloodConsumed current = enumerator.Current;
					EntityManager entityManager = Core.EntityManager;
					if (((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(current.Target))
					{
						entityManager = Core.EntityManager;
						PlayerCharacter componentData = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(current.Target);
						entityManager = Core.EntityManager;
						User componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<User>(componentData.UserEntity);
						string prefabName = current.Source.GetPrefabName();
						Core.KillVBloodService.AddKiller(prefabName.ToString(), ((object)(FixedString64Bytes)(ref componentData2.CharacterName)).ToString());
						Core.KillVBloodService.lastKillerUpdate[prefabName.ToString()] = DateTime.Now;
						_checkKiller = true;
					}
				}
			}
			else
			{
				if (!_checkKiller)
				{
					return;
				}
				bool checkKiller = false;
				foreach (KeyValuePair<string, DateTime> item in Core.KillVBloodService.lastKillerUpdate)
				{
					DateTime value = item.Value;
					if (DateTime.Now - value < TimeSpan.FromSeconds(2.0))
					{
						checkKiller = true;
					}
					else
					{
						Core.KillVBloodService.AnnounceVBloodKill(item.Key);
					}
				}
				_checkKiller = checkKiller;
			}
		}
	}
	[HarmonyPatch]
	internal static class PlayerCombatBuffSystemPatch
	{
		[HarmonyPatch(typeof(PlayerCombatBuffSystem_OnAggro), "OnUpdate")]
		[HarmonyPrefix]
		private static void OnUpdate_Prefix(PlayerCombatBuffSystem_OnAggro __instance)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			EntityQuery val = ((Il2CppArrayBase<EntityQuery>)(object)((ComponentSystemBase)__instance).EntityQueries)[0];
			NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				bool flag = default(bool);
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (!current.Has<Added>())
					{
						continue;
					}
					Added val3 = current.Read<Added>();
					if (val3.Producer.Has<PlayerCharacter>() && val3.Consumer.Has<VBloodUnit>())
					{
						PrefabGUID prefabGuid = val3.Consumer.Read<PrefabGUID>();
						string prefabName = prefabGuid.GetPrefabName();
						Core.TrackVBloodCombat.StartTrackingForVBlood(prefabName, ref val3.Producer, ref val3.Consumer);
						ManualLogSource log = Core.Log;
						BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(52, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("PlayerCombatBuffSystemPatch: Start Tracking ");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(prefabName);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" for ");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Entity>(val3.Producer);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("...");
						}
						log.LogInfo(val4);
					}
				}
			}
			finally
			{
				val2.Dispose();
			}
		}

		[HarmonyPatch(typeof(PlayerCombatBuffSystem_Reapplication), "OnUpdate")]
		[HarmonyPrefix]
		private static void OnUpdate_Prefix(PlayerCombatBuffSystem_Reapplication __instance)
		{
		}
	}
	[HarmonyPatch(typeof(UpdateBuffsBuffer_Destroy), "OnUpdate")]
	internal class UpdateBuffsBuffer_DestroyPatch
	{
		public static void Prefix(UpdateBuffsBuffer_Destroy __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			EntityQuery _query_401358720_ = __instance.__query_401358720_0;
			NativeArray<Entity> val = ((EntityQuery)(ref _query_401358720_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val.GetEnumerator();
			bool flag = default(bool);
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				PrefabGUID item = current.Read<PrefabGUID>();
				if (VBloodCollectionData.Buff_InCombat_VBlood_Set.Contains(item))
				{
					Age val2 = current.Read<Age>();
					Buff val3 = current.Read<Buff>();
					PrefabGUID prefabGuid = val3.Target.Read<PrefabGUID>();
					string prefabName = prefabGuid.GetPrefabName();
					bool isDead = val3.Target.Read<Health>().IsDead;
					Core.KillVBloodService.SetCombatDuration(prefabName, val2.Value);
					Core.TrackVBloodCombat.StopTrackingForVBlood(prefabName, isDead);
					ManualLogSource log = Core.Log;
					BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("UpdateBuffsBuffer_Destroy: Stop Tracking ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(prefabName);
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("...");
					}
					log.LogInfo(val4);
				}
			}
			val.Dispose();
		}
	}
}
namespace SanguineArchives.VBloodArchives.Data
{
	public class VBloodCollectionData
	{
		public static readonly List<string> VBloods_Act1 = new List<string>
		{
			"CHAR_Forest_Wolf_VBlood", "CHAR_Bandit_Frostarrow_VBlood", "CHAR_Bandit_StoneBreaker_VBlood", "CHAR_Bandit_Foreman_VBlood", "CHAR_Bandit_Stalker_VBlood", "CHAR_Undead_BishopOfDeath_VBlood", "CHAR_Bandit_Chaosarrow_VBlood", "CHAR_Bandit_Bomber_VBlood", "CHAR_Vermin_DireRat_VBlood", "CHAR_Bandit_Fisherman_VBlood",
			"CHAR_Poloma_VBlood", "CHAR_Forest_Bear_Dire_Vblood", "CHAR_Undead_Priest_VBlood", "CHAR_Bandit_Tourok_VBlood"
		};

		public static readonly List<string> VBloods_Act2 = new List<string>
		{
			"CHAR_Villager_Tailor_VBlood", "CHAR_Militia_Guard_VBlood", "CHAR_Militia_Nun_VBlood", "CHAR_VHunter_Leader_VBlood", "CHAR_Undead_Leader_Vblood", "CHAR_Undead_BishopOfShadows_VBlood", "CHAR_Militia_Scribe_VBlood", "CHAR_Undead_Infiltrator_VBlood", "CHAR_Militia_Glassblower_VBlood", "CHAR_Militia_Longbowman_LightArrow_Vblood",
			"CHAR_Geomancer_Human_VBlood", "CHAR_Wendigo_VBlood", "CHAR_Vampire_IceRanger_VBlood", "CHAR_Vampire_HighLord_VBlood", "CHAR_VHunter_Jade_VBlood", "CHAR_Militia_BishopOfDunley_VBlood", "CHAR_Militia_Leader_VBlood"
		};

		public static readonly List<string> VBloods_Act3 = new List<string> { "CHAR_Gloomrot_Iva_VBlood", "CHAR_Gloomrot_Voltage_VBlood", "CHAR_Gloomrot_Purifier_VBlood", "CHAR_Spider_Queen_VBlood", "CHAR_Villager_CursedWanderer_VBlood", "CHAR_Undead_ZealousCultist_VBlood", "CHAR_Cursed_ToadKing_VBlood", "CHAR_WerewolfChieftain_Human", "CHAR_Undead_CursedSmith_VBlood" };

		public static readonly List<string> VBloods_Act4 = new List<string>
		{
			"CHAR_ChurchOfLight_Overseer_VBlood", "CHAR_ChurchOfLight_Sommelier_VBlood", "CHAR_Harpy_Matriarch_VBlood", "CHAR_ArchMage_VBlood", "CHAR_Gloomrot_TheProfessor_VBlood", "CHAR_Cursed_Witch_VBlood", "CHAR_Winter_Yeti_VBlood", "CHAR_ChurchOfLight_Cardinal_VBlood", "CHAR_Gloomrot_RailgunSergeant_VBlood", "CHAR_VHunter_CastleMan",
			"CHAR_BatVampire_VBlood", "CHAR_Cursed_MountainBeast_VBlood", "CHAR_Vampire_BloodKnight_VBlood", "CHAR_ChurchOfLight_Paladin_VBlood", "CHAR_Manticore_VBlood", "CHAR_Gloomrot_Monster_VBlood", "CHAR_Vampire_Dracula_VBlood"
		};

		public static readonly Dictionary<string, List<VBloodRecord>> DefaultVBloodRecords = new Dictionary<string, List<VBloodRecord>>
		{
			{
				"CHAR_Forest_Wolf_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_Frostarrow_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_StoneBreaker_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_Foreman_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_Stalker_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Undead_BishopOfDeath_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_Chaosarrow_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_Bomber_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Vermin_DireRat_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_Fisherman_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Poloma_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Forest_Bear_Dire_Vblood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Undead_Priest_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_Tourok_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Villager_Tailor_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Militia_Guard_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Militia_Nun_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_VHunter_Leader_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Undead_Leader_Vblood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Undead_BishopOfShadows_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Militia_Scribe_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Undead_Infiltrator_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Militia_Glassblower_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Militia_Longbowman_LightArrow_Vblood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Geomancer_Human_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Wendigo_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Vampire_IceRanger_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Vampire_HighLord_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_VHunter_Jade_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Militia_BishopOfDunley_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Militia_Leader_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Gloomrot_Iva_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Gloomrot_Voltage_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Gloomrot_Purifier_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Spider_Queen_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Villager_CursedWanderer_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Undead_ZealousCultist_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Cursed_ToadKing_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_WerewolfChieftain_Human",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Undead_CursedSmith_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_ChurchOfLight_Overseer_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_ChurchOfLight_Sommelier_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Harpy_Matriarch_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_ArchMage_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Gloomrot_TheProfessor_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Cursed_Witch_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Winter_Yeti_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_ChurchOfLight_Cardinal_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Gloomrot_RailgunSergeant_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_VHunter_CastleMan",
				new List<VBloodRecord>()
			},
			{
				"CHAR_BatVampire_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Cursed_MountainBeast_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Vampire_BloodKnight_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_ChurchOfLight_Paladin_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Manticore_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Gloomrot_Monster_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Vampire_Dracula_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_GraveDigger_VBlood_UNUSED",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_Leader_VBlood_UNUSED",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Bandit_Miner_VBlood_UNUSED",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Militia_Hound_VBlood",
				new List<VBloodRecord>()
			},
			{
				"CHAR_Militia_HoundMaster_VBlood",
				new List<VBloodRecord>()
			}
		};

		public static readonly HashSet<PrefabGUID> Buff_InCombat_VBlood_Set = new HashSet<PrefabGUID>
		{
			Prefabs.Buff_InCombat_Forest_Wolf,
			Prefabs.Buff_InCombat_VBlood_Frostarrow,
			Prefabs.Buff_InCombat_VBlood_StoneBreaker,
			Prefabs.Buff_InCombat_VBlood_Foreman,
			Prefabs.Buff_InCombat_VBlood_Armorer,
			Prefabs.Buff_InCombat_VBlood_Armorer_ALREADY_EXISTS_2,
			Prefabs.Buff_InCombat_VBlood_BishopOfDeath,
			Prefabs.Buff_InCombat_VBlood_Chaosarrow,
			Prefabs.Buff_InCombat_VBlood_Bandit_Bomber,
			Prefabs.Buff_InCombat_VBlood_DireRat,
			Prefabs.Buff_InCombat_Fisherman,
			Prefabs.Buff_InCombat_VBlood_Poloma,
			Prefabs.Buff_InCombat_VBlood_Bear_Dire,
			Prefabs.Buff_InCombat_VBlood_Undead_Priest,
			Prefabs.Buff_InCombat_VBlood_Tourok,
			Prefabs.Buff_InCombat_VBlood_Tailor,
			Prefabs.Buff_Tailor_VBlood_Flee,
			Prefabs.Buff_InCombat_VBlood_Militia_Guard,
			Prefabs.Buff_InCombat_VBlood_Nun,
			Prefabs.Buff_VHunter_Leader_InCombat,
			Prefabs.Buff_Undead_Leader_VBlood_InCombat,
			Prefabs.Buff_InCombat_VBlood_BishopOfShadows,
			Prefabs.Buff_InCombat_VBlood_Militia_Scribe,
			Prefabs.Buff_Undead_Infiltrator_VBlood_InCombat,
			Prefabs.Buff_InCombat_VBlood_Militia_Glassblower,
			Prefabs.Buff_InCombat_VBlood_Militia_LightArrow,
			Prefabs.Buff_InCombat_VBlood_Geomancer_Human,
			Prefabs.Buff_InCombat_VBlood_Wendigo,
			Prefabs.Buff_InCombat_VBlood_IceRanger,
			Prefabs.Buff_InCombat_Npc_HighLord,
			Prefabs.Buff_InCombat_VHunter_Jade,
			Prefabs.Buff_InCombat_VBlood_BishopOfDunley,
			Prefabs.Buff_InCombat_VBlood_Militia_Leader,
			Prefabs.Buff_InCombat_VBlood_Iva,
			Prefabs.Buff_InCombat_VBlood_Voltage,
			Prefabs.Buff_InCombat_VBlood_Purifier,
			Prefabs.Buff_InCombat_VBlood_Spider_Queen,
			Prefabs.Buff_InCombat_VBlood_CursedWanderer,
			Prefabs.Buff_CursedWanderer_VBlood_Flee,
			Prefabs.Buff_Undead_ZealousCultist_InCombat,
			Prefabs.Buff_InCombat_VBlood_ToadKing,
			Prefabs.Buff_InCombat_VBlood_WerewolfChieftain_Werewolf,
			Prefabs.Buff_Undead_CursedSmith_InCombat,
			Prefabs.Buff_InCombat_VBlood_Overseer,
			Prefabs.Buff_InCombat_VBlood_Sommelier,
			Prefabs.Buff_InCombat_VBlood_Harpy_Matriarch,
			Prefabs.Buff_InCombat_VBlood_Archmage,
			Prefabs.Buff_InCombat_TheProfessor,
			Prefabs.Buff_InCombat_VBlood_Witch,
			Prefabs.Buff_InCombat_VBlood_Yeti,
			Prefabs.Buff_InCombat_VBlood_ChurchOfLight_Cardinal,
			Prefabs.Buff_InCombat_Gloomrot_RailgunSergeant,
			Prefabs.Buff_InCombat_Npc_CastleMan,
			Prefabs.Buff_BatVampire_InCombat,
			Prefabs.Buff_InCombat_VBlood_MountainBeast,
			Prefabs.Buff_InCombat_BloodKnight,
			Prefabs.Buff_InCombat_ChurchOfLight_Paladin,
			Prefabs.Buff_InCombat_Manticore,
			Prefabs.Buff_InCombat_Npc_Monster,
			Prefabs.Buff_InCombat_Npc_Boss
		};
	}
}
namespace SanguineArchives.VBloodArchives.Commands
{
	[CommandGroup("archives", "sga")]
	public class VBloodRecordsCommand
	{
		public static void SendVBloodRecordsToChat(ChatCommandContext ctx, PrefabGUID vbloodPrefab, VBloodRecord record)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			string value = ChatColor.Purple(vbloodPrefab.GetLocalizedName());
			string value2 = ChatColor.Yellow(record.CharacterName ?? "");
			string value3 = ChatColor.Green($"{record.CombatDuration:F2}s");
			string value4 = ChatColor.Gray("(" + DateTime.Parse(record.DateTime).ToString("d") + ")");
			ctx.Reply($"{value}: {value2} - {value3} {value4}");
		}

		[Command("boss", "b", ".sga b [BossName]", "Show records for the specified V Blood boss", null, false)]
		public static void ShowVBloodRecords(ChatCommandContext ctx, FoundVBlood foundVBlood)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			PrefabGUID value = foundVBlood.Value;
			string prefabName = value.GetPrefabName();
			string text = ChatColor.Purple(value.GetLocalizedName());
			List<VBloodRecord> recordsForVBlood = Core.VBloodRecordsService.GetRecordsForVBlood(prefabName);
			ctx.Reply(ChatColor.Green("*** V Blood Records for " + text + " ***"));
			foreach (VBloodRecord item in recordsForVBlood)
			{
				SendVBloodRecordsToChat(ctx, value, item);
			}
		}

		[Command("top", "t", ".sga t (0-4)", "Show top records for V Blood per Act. Shows recent records by default or for Act 0.", null, false)]
		public static void ShowTopRecords(ChatCommandContext ctx, int act = 0)
		{
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, VBloodRecord> dictionary;
			if (act == 0)
			{
				ctx.Reply(ChatColor.Green("*** Recent V Blood Records ***"));
				dictionary = Core.VBloodRecordsService.GetTopRecordsByDate(10);
			}
			else
			{
				string text = $"Act {act}";
				ctx.Reply(ChatColor.Green("*** " + text + " V Blood Records ***"));
				dictionary = act switch
				{
					1 => Core.VBloodRecordsService.GetTopRecordsForVBloods(VBloodCollectionData.VBloods_Act1), 
					2 => Core.VBloodRecordsService.GetTopRecordsForVBloods(VBloodCollectionData.VBloods_Act2), 
					3 => Core.VBloodRecordsService.GetTopRecordsForVBloods(VBloodCollectionData.VBloods_Act3), 
					_ => Core.VBloodRecordsService.GetTopRecordsForVBloods(VBloodCollectionData.VBloods_Act4), 
				};
			}
			foreach (var (input, record) in dictionary)
			{
				if (Core.Prefabs.TryGetItem(input, out var prefab))
				{
					SendVBloodRecordsToChat(ctx, prefab, record);
				}
			}
		}

		[Command("player", "p", ".sga p (0-4) (Player)", "Show V Blood records per Act for player. Shows recent records by default or for Act 0. Player defaults to self.", null, false)]
		public static void ShowRecordsForPlayer(ChatCommandContext ctx, int act = 0, OnlinePlayer player = null)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0039: 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_01e1: Unknown result type (might be due to invalid IL or missing references)
			FixedString64Bytes val = player?.Value.UserEntity.Read<User>().CharacterName ?? ctx.Event.User.CharacterName;
			Entity val2 = player?.Value.CharEntity ?? ctx.Event.SenderCharacterEntity;
			string value = $"Act {act}";
			string text = ChatColor.Yellow(((object)(FixedString64Bytes)(ref val)).ToString() ?? "");
			Dictionary<string, VBloodRecord> dictionary;
			if (act == 0)
			{
				ctx.Reply(ChatColor.Green("*** Recent V Blood Records for " + text + " ***"));
				dictionary = Core.VBloodRecordsService.GetRecordsForPlayerByDate(((object)(FixedString64Bytes)(ref val)).ToString(), 10);
			}
			else
			{
				ctx.Reply(ChatColor.Green($"*** {value} V Blood Records for {text} ***"));
				dictionary = act switch
				{
					1 => Core.VBloodRecordsService.GetTopRecordsForVBloods(VBloodCollectionData.VBloods_Act1), 
					2 => Core.VBloodRecordsService.GetTopRecordsForVBloods(VBloodCollectionData.VBloods_Act2), 
					3 => Core.VBloodRecordsService.GetTopRecordsForVBloods(VBloodCollectionData.VBloods_Act3), 
					_ => Core.VBloodRecordsService.GetTopRecordsForVBloods(VBloodCollectionData.VBloods_Act4), 
				};
			}
			foreach (var (input, record) in dictionary)
			{
				if (Core.Prefabs.TryGetItem(input, out var prefab))
				{
					SendVBloodRecordsToChat(ctx, prefab, record);
				}
			}
		}
	}
}
namespace SanguineArchives.Common
{
	internal static class Core
	{
		private static MonoBehaviour monoBehaviour;

		public const int MAX_REPLY_LENGTH = 509;

		private static bool _hasInitialized = false;

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


		public static EntityManager EntityManager { get; } = Server.EntityManager;


		public static GameDataSystem GameDataSystem { get; } = Server.GetExistingSystemManaged<GameDataSystem>();


		public static PrefabCollectionSystem PrefabCollectionSystem { get; internal set; }

		public static RelicDestroySystem RelicDestroySystem { get; internal set; }

		public static ServerScriptMapper ServerScriptMapper { get; internal set; }

		public static double ServerTime => ServerGameManager.ServerTime;

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

		public static ServerGameSettingsSystem ServerGameSettingsSystem { get; internal set; }

		public static ManualLogSource Log { get; } = Plugin.LogInstance;


		public static LocalizationService Localization { get; internal set; }

		public static PlayerService Players { get; internal set; }

		public static PrefabService Prefabs { get; internal set; }

		public static VBloodRecordsService VBloodRecordsService { get; internal set; }

		public static TrackVBloodCombat TrackVBloodCombat { get; internal set; }

		public static KillVBloodService KillVBloodService { get; internal set; }

		public static void LogException(Exception e, [CallerMemberName] string caller = null)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(51, 5, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failure in ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(caller);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nMessage: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Inner:");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.Message);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n\nStack: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.StackTrace);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nInner Stack: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.StackTrace);
			}
			log.LogError(val);
		}

		internal static void InitializeAfterLoaded()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			if (!_hasInitialized)
			{
				PrefabCollectionSystem = Server.GetExistingSystemManaged<PrefabCollectionSystem>();
				RelicDestroySystem = Server.GetExistingSystemManaged<RelicDestroySystem>();
				ServerGameSettingsSystem = Server.GetExistingSystemManaged<ServerGameSettingsSystem>();
				ServerScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
				Localization = new LocalizationService();
				Players = new PlayerService();
				Prefabs = new PrefabService();
				VBloodRecordsService = new VBloodRecordsService();
				TrackVBloodCombat = new TrackVBloodCombat();
				KillVBloodService = new KillVBloodService();
				_hasInitialized = true;
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("InitializeAfterLoaded");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" completed");
				}
				log.LogInfo(val);
			}
		}

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

		public static Coroutine StartCoroutine(IEnumerator routine)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)monoBehaviour == (Object)null)
			{
				GameObject val = new GameObject("SanguineArchives");
				monoBehaviour = (MonoBehaviour)(object)val.AddComponent<IgnorePhysicsDebugSystem>();
				Object.DontDestroyOnLoad((Object)(object)val);
			}
			return monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
		}

		public static void StopCoroutine(Coroutine coroutine)
		{
			if (!((Object)(object)monoBehaviour == (Object)null))
			{
				monoBehaviour.StopCoroutine(coroutine);
			}
		}
	}
}
namespace SanguineArchives.Common.Utils
{
	internal class Buffs
	{
		public static bool AddBuff(Entity User, Entity Character, PrefabGUID buffPrefab, int duration = 0, bool immortal = true)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0021: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0060: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: 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_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_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			DebugEventsSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<DebugEventsSystem>();
			ApplyBuffDebugEvent val = default(ApplyBuffDebugEvent);
			val.BuffPrefabGUID = buffPrefab;
			ApplyBuffDebugEvent val2 = val;
			FromCharacter val3 = default(FromCharacter);
			val3.User = User;
			val3.Character = Character;
			FromCharacter val4 = val3;
			Entity entity = default(Entity);
			if (!BuffUtility.TryGetBuff(Core.Server.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref entity))
			{
				existingSystemManaged.ApplyBuff(val4, val2);
				if (BuffUtility.TryGetBuff(Core.Server.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref entity))
				{
					if (entity.Has<CreateGameplayEventsOnSpawn>())
					{
						entity.Remove<CreateGameplayEventsOnSpawn>();
					}
					if (entity.Has<GameplayEventListeners>())
					{
						entity.Remove<GameplayEventListeners>();
					}
					if (immortal)
					{
						entity.Add<Buff_Persists_Through_Death>();
						if (entity.Has<RemoveBuffOnGameplayEvent>())
						{
							entity.Remove<RemoveBuffOnGameplayEvent>();
						}
						if (entity.Has<RemoveBuffOnGameplayEventEntry>())
						{
							entity.Remove<RemoveBuffOnGameplayEventEntry>();
						}
					}
					if (duration > -1 && duration != 0)
					{
						if (!entity.Has<LifeTime>())
						{
							entity.Add<LifeTime>();
							entity.Write<LifeTime>(new LifeTime
							{
								EndAction = (LifeTimeEndAction)2
							});
						}
						LifeTime componentData = entity.Read<LifeTime>();
						componentData.Duration = duration;
						entity.Write<LifeTime>(componentData);
					}
					else if (duration == -1)
					{
						if (entity.Has<LifeTime>())
						{
							LifeTime componentData2 = entity.Read<LifeTime>();
							componentData2.Duration = -1f;
							componentData2.EndAction = (LifeTimeEndAction)0;
							entity.Write<LifeTime>(componentData2);
						}
						if (entity.Has<RemoveBuffOnGameplayEvent>())
						{
							entity.Remove<RemoveBuffOnGameplayEvent>();
						}
						if (entity.Has<RemoveBuffOnGameplayEventEntry>())
						{
							entity.Remove<RemoveBuffOnGameplayEventEntry>();
						}
					}
					return true;
				}
				return false;
			}
			return false;
		}

		public static void RemoveBuff(Entity Character, PrefabGUID buffPrefab)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Entity val = default(Entity);
			if (BuffUtility.TryGetBuff(Core.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref val))
			{
				DestroyUtility.Destroy(Core.EntityManager, val, (DestroyDebugReason)13, (string)null, 0);
			}
		}
	}
	public class ChatColor
	{
		public static string Color(string hexColor, string text)
		{
			return $"<color={hexColor}>{text}</color>";
		}

		public static string White(string text)
		{
			return Color("#FFFFFF", text);
		}

		public static string Red(string text)
		{
			return Color("#E90000", text);
		}

		public static string Green(string text)
		{
			return Color("#7FE030", text);
		}

		public static string Blue(string text)
		{
			return Color("#256DFE", text);
		}

		public static string Yellow(string text)
		{
			return Color("#FFE100", text);
		}

		public static string Gray(string text)
		{
			return Color("#A9A9A9", text);
		}

		public static string Purple(string text)
		{
			return Color("#D900FF", text);
		}
	}
	public static class ECSExtensions
	{
		public delegate void ActionRef<T>(ref T item);

		public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
		{
			//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_0042: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			byte[] array = StructureToByteArray(componentData);
			int num = Marshal.SizeOf<T>();
			fixed (byte* ptr = array)
			{
				EntityManager entityManager = Core.EntityManager;
				((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
			}
		}

		public static void With<T>(this Entity entity, ActionRef<T> action) where T : struct
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			T item = entity.ReadRW<T>();
			action(ref item);
			EntityManager entityManager = Core.EntityManager;
			((EntityManager)(ref entityManager)).SetComponentData<T>(entity, item);
		}

		public unsafe static T ReadRW<T>(this Entity entity) where T : struct
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = Core.EntityManager;
			void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(entity, val.TypeIndex);
			return Marshal.PtrToStructure<T>(new IntPtr(componentDataRawRW));
		}

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

		public unsafe static T Read<T>(this Entity entity) where T : struct
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = Core.EntityManager;
			void* componentDataRawRO = ((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex);
			return Marshal.PtrToStructure<T>(new IntPtr(componentDataRawRO));
		}

		public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = Core.Server.EntityManager;
			return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity, false);
		}

		public static bool Has<T>(this Entity entity)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = Core.EntityManager;
			return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
		}

		public static string LookupName(this PrefabGUID prefabGuid)
		{
			//IL_0012: 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)
			PrefabCollectionSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
			return (existingSystemManaged.PrefabGuidToNameDictionary.ContainsKey(prefabGuid) ? existingSystemManaged.PrefabGuidToNameDictionary[prefabGuid] : "GUID Not Found").ToString();
		}

		public static string GetPrefabName(this PrefabGUID prefabGuid)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			string text = default(string);
			return Core.PrefabCollectionSystem.PrefabGuidToNameDictionary.TryGetValue(prefabGuid, ref text) ? (text ?? "") : "String.Empty";
		}

		public static string GetLocalizedName(this PrefabGUID prefabGuid)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			string prefabName = Core.Localization.GetPrefabName(prefabGuid);
			ManualLogSource log = Core.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("GetLocalizedName: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(prefabName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" for ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<PrefabGUID>(prefabGuid);
			}
			log.LogInfo(val);
			return string.IsNullOrEmpty(prefabName) ? prefabGuid.LookupName() : prefabName;
		}

		public static string GetLocalizedName(this Entity entity)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_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)
			string text = string.Empty;
			if (entity.Has<NameableInteractable>())
			{
				NameableInteractable val = entity.Read<NameableInteractable>();
				text = ((object)(FixedString64Bytes)(ref val.Name)).ToString();
			}
			if (string.IsNullOrEmpty(text) && entity.Has<PrefabGUID>())
			{
				text = entity.Read<PrefabGUID>().GetLocalizedName();
			}
			if (string.IsNullOrEmpty(text))
			{
				text = ((object)(Entity)(ref entity)).ToString();
			}
			return text;
		}

		public static void Add<T>(this Entity entity)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = Core.EntityManager;
			((EntityManager)(ref entityManager)).AddComponent(entity, val);
		}

		public static void Remove<T>(this Entity entity)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = Core.EntityManager;
			((EntityManager)(ref entityManager)).RemoveComponent(entity, val);
		}
	}
	internal static class Helper
	{
		public static AdminAuthSystem adminAuthSystem = Core.Server.GetExistingSystemManaged<AdminAuthSystem>();

		public static ClanSystem_Server clanSystem = Core.Server.GetExistingSystemManaged<ClanSystem_Server>();

		public static EntityCommandBufferSystem entityCommandBufferSystem = Core.Server.GetExistingSystemManaged<EntityCommandBufferSystem>();

		private static EntityQuery tilePositionQuery = default(EntityQuery);

		private const float ReviveDelaySeconds = 20f;

		public static PrefabGUID GetPrefabGUID(Entity entity)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0022: 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)
			EntityManager entityManager = Core.EntityManager;
			PrefabGUID componentData = default(PrefabGUID);
			try
			{
				componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(entity);
				return componentData;
			}
			catch
			{
				((PrefabGUID)(ref componentData))..ctor(0);
			}
			return componentData;
		}

		public static bool TryGetClanEntityFromPlayer(Entity User, out Entity ClanEntity)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if (User.Read<TeamReference>().Value._Value.ReadBuffer<TeamAllies>().Length > 0)
			{
				ClanEntity = User.Read<TeamReference>().Value._Value.ReadBuffer<TeamAllies>()[0].Value;
				return true;
			}
			ClanEntity = default(Entity);
			return false;
		}

		public static Entity AddItemToInventory(Entity recipient, PrefabGUID guid, int amount)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ServerGameManager serverGameManager = Core.Server.GetExistingSystemManaged<ServerScriptMapper>()._ServerGameManager;
				AddItemResponse val = ((ServerGameManager)(ref serverGameManager)).TryAddInventoryItem(recipient, guid, amount);
				return val.NewEntity;
			}
			catch (Exception e)
			{
				Core.LogException(e, "AddItemToInventory");
			}
			return default(Entity);
		}

		public static NativeArray<Entity> GetEntitiesByComponentType<T1>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryOptions val = (EntityQueryOptions)0;
			if (includeAll)
			{
				val = (EntityQueryOptions)(val | 0xC3);
			}
			if (includeDisabled)
			{
				val = (EntityQueryOptions)(val | 2);
			}
			if (includeSpawn)
			{
				val = (EntityQueryOptions)(val | 0x40);
			}
			if (includePrefab)
			{
				val = (EntityQueryOptions)(val | 1);
			}
			if (includeDestroyed)
			{
				val = (EntityQueryOptions)(val | 0x80);
			}
			EntityQueryDesc val2 = new EntityQueryDesc();
			val2.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1]
			{
				new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0)
			});
			val2.Options = val;
			EntityQueryDesc val3 = val2;
			EntityManager entityManager = Core.EntityManager;
			EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val3 });
			return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
		}

		public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to inva