Decompiled source of Dracula Training Room v1.0.0

plugins/Dracula_Training_Room/DraculaTrainingRoom.Client.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Il2CppSystem.Text;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Shared;
using ProjectM.UI;
using Steamworks;
using StunShared.UI;
using Stunlock.Core;
using Stunlock.Localization;
using Stunlock.Network;
using TMPro;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DraculaTrainingRoom.Client")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DraculaTrainingRoom.Client")]
[assembly: AssemblyTitle("DraculaTrainingRoom.Client")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DraculaTrainingRoom
{
	internal static class Ecs
	{
		public static World World;

		private static EntityManager EM => World.EntityManager;

		public unsafe static T Read<T>(this Entity entity) where T : struct
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager eM = EM;
			return Unsafe.Read<T>(((EntityManager)(ref eM)).GetComponentDataRawRO(entity, val.TypeIndex));
		}

		public unsafe static void Write<T>(this Entity entity, T data) where T : struct
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager eM = EM;
			Unsafe.Write(((EntityManager)(ref eM)).GetComponentDataRawRW(entity, val.TypeIndex), data);
		}

		public static bool Has<T>(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			return ((EntityManager)(ref eM)).HasComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0));
		}

		public static bool TryRead<T>(this Entity entity, out T value) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (entity.Exists() && entity.Has<T>())
			{
				value = entity.Read<T>();
				return true;
			}
			value = default(T);
			return false;
		}

		public static void Add<T>(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			((EntityManager)(ref eM)).AddComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0));
		}

		public static void Remove<T>(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			((EntityManager)(ref eM)).RemoveComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0));
		}

		public static DynamicBuffer<T> Buffer<T>(this Entity entity) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			return ((EntityManager)(ref eM)).GetBuffer<T>(entity, false);
		}

		public static bool Exists(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (entity != Entity.Null)
			{
				EntityManager eM = EM;
				return ((EntityManager)(ref eM)).Exists(entity);
			}
			return false;
		}

		public static PrefabGUID Guid(this Entity entity)
		{
			//IL_0000: 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_0010: 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)
			if (!entity.Has<PrefabGUID>())
			{
				return new PrefabGUID(0);
			}
			return entity.Read<PrefabGUID>();
		}

		public static EntityQuery Query(EntityQueryOptions options, params Type[] all)
		{
			//IL_0003: 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_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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryBuilder val = default(EntityQueryBuilder);
			((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2));
			foreach (Type type in all)
			{
				((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.From(type), (AccessMode)1));
			}
			((EntityQueryBuilder)(ref val)).WithOptions(options);
			EntityManager eM = EM;
			EntityQuery result = ((EntityManager)(ref eM)).CreateEntityQuery(ref val);
			((EntityQueryBuilder)(ref val)).Dispose();
			return result;
		}

		public static List<Entity> ToList(this EntityQuery q)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			NativeArray<Entity> val = ((EntityQuery)(ref q)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			List<Entity> list = new List<Entity>(val.Length);
			Enumerator<Entity> enumerator = val.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				list.Add(current);
			}
			val.Dispose();
			return list;
		}
	}
	public static class MirrorProtocol
	{
		public const string Give = "mirror.give";

		public const string Weapon = "mirror.weapon";

		public const string Jewel = "mirror.jewel";

		public const string Blood = "mirror.blood";

		public const string FiltersGet = "mirror.filters.get";

		public const string FiltersSet = "mirror.filters.set";

		public const int MaxTier = 3;

		public const int MaxPower = 1000;
	}
	public static class ModInfo
	{
		public const string Version = "1.0.0";
	}
	public static class Protocol
	{
		public sealed class Assembler
		{
			private readonly Dictionary<int, string[]> parts = new Dictionary<int, string[]>();

			public bool Feed(string text, out int id, out bool ok, out string body)
			{
				id = 0;
				ok = false;
				body = null;
				if (!IsOurs(text))
				{
					return false;
				}
				string[] array = text.Substring("§DT1|".Length).Split('|', 5);
				if (array.Length < 5 || array[0] != "r")
				{
					return false;
				}
				if (!int.TryParse(array[1], out id) || !int.TryParse(array[2], out var result) || !int.TryParse(array[3], out var result2))
				{
					return false;
				}
				if (!parts.TryGetValue(id, out var value) || value.Length != result2)
				{
					value = (parts[id] = new string[result2]);
				}
				value[result] = array[4];
				string[] array3 = value;
				for (int i = 0; i < array3.Length; i++)
				{
					if (array3[i] == null)
					{
						return false;
					}
				}
				parts.Remove(id);
				string text2 = string.Concat(value);
				ok = text2.StartsWith("1|", StringComparison.Ordinal);
				body = ((text2.Length >= 2) ? text2.Substring(2) : "");
				return true;
			}
		}

		public const string Prefix = "§DT1|";

		public const int ChunkChars = 380;

		public const int MaxRequestBytes = 500;

		public static bool IsOurs(string text)
		{
			return text?.StartsWith("§DT1|", StringComparison.Ordinal) ?? false;
		}

		public static string Request(int id, string command, string body)
		{
			string text = $"{"§DT1|"}q|{id}|{command}|{body ?? ""}";
			if (Encoding.UTF8.GetByteCount(text) > 500)
			{
				throw new ArgumentException("request too long: " + command);
			}
			return text;
		}

		public static bool TryParseRequest(string text, out int id, out string command, out string body)
		{
			id = 0;
			command = (body = null);
			if (!IsOurs(text))
			{
				return false;
			}
			string[] array = text.Substring("§DT1|".Length).Split('|', 4);
			if (array.Length < 4 || array[0] != "q" || !int.TryParse(array[1], out id))
			{
				return false;
			}
			command = array[2];
			body = array[3];
			return true;
		}

		public static List<string> Reply(int id, bool ok, string body)
		{
			string text = (ok ? "1|" : "0|") + body;
			List<string> list = new List<string>();
			int num = Math.Max(1, (text.Length + 380 - 1) / 380);
			for (int i = 0; i < num; i++)
			{
				int num2 = i * 380;
				string value = text.Substring(num2, Math.Min(380, text.Length - num2));
				list.Add($"{"§DT1|"}r|{id}|{i}|{num}|{value}");
			}
			return list;
		}
	}
	public sealed class Wait
	{
		public readonly float Seconds;

		public Wait(float seconds)
		{
			Seconds = seconds;
		}
	}
	public static class Scheduler
	{
		private sealed class Routine
		{
			public readonly Stack<IEnumerator> Stack = new Stack<IEnumerator>();

			public float WakeAt;

			public string Name;
		}

		private static readonly List<Routine> routines = new List<Routine>();

		private static readonly List<Routine> pending = new List<Routine>();

		public static Action<string> OnError;

		public static void Start(IEnumerator routine, string name = null)
		{
			Routine routine2 = new Routine
			{
				Name = (name ?? "routine")
			};
			routine2.Stack.Push(routine);
			pending.Add(routine2);
		}

		public static void Tick()
		{
			if (pending.Count > 0)
			{
				routines.AddRange(pending);
				pending.Clear();
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			for (int num = routines.Count - 1; num >= 0; num--)
			{
				Routine routine = routines[num];
				if (!(realtimeSinceStartup < routine.WakeAt))
				{
					try
					{
						while (routine.Stack.Count > 0)
						{
							IEnumerator enumerator = routine.Stack.Peek();
							if (!enumerator.MoveNext())
							{
								routine.Stack.Pop();
								continue;
							}
							object current = enumerator.Current;
							if (current is IEnumerator item)
							{
								routine.Stack.Push(item);
								continue;
							}
							if (current is Wait wait)
							{
								routine.WakeAt = realtimeSinceStartup + wait.Seconds;
							}
							break;
						}
					}
					catch (Exception value)
					{
						OnError?.Invoke($"{routine.Name}: {value}");
						routine.Stack.Clear();
					}
					if (routine.Stack.Count == 0)
					{
						routines.RemoveAt(num);
					}
				}
			}
		}
	}
	public class SchedulerDriver : MonoBehaviour
	{
		public SchedulerDriver(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Update()
		{
			Scheduler.Tick();
		}
	}
}
namespace DraculaTrainingRoom.Client
{
	internal static class BenchCamera
	{
		[HarmonyPatch(typeof(TopdownCameraSystem), "OnUpdate")]
		private static class Patch
		{
			private static void Postfix(TopdownCameraSystem __instance)
			{
				//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_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: 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_004d: 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_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_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_0095: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: 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_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: 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_015e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: 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_01e1: Unknown result type (might be due to invalid IL or missing references)
				if (!Active && logged)
				{
					return;
				}
				Ecs.World = ((ComponentSystemBase)__instance).World;
				EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
				EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite(Il2CppType.Of<TopdownCameraState>()) });
				NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					TopdownCameraState val3 = current.Read<TopdownCameraState>();
					if (!logged)
					{
						logged = true;
						TestHarness.Log($"camera: zoom {val3.Current.Zoom} pitch {val3.Current.Pitch} range zoom {val3.ZoomSettings.MinZoom}..{val3.ZoomSettings.MaxZoom} pitch {val3.ZoomSettings.MinPitch}..{val3.ZoomSettings.MaxPitch}");
					}
					if (Active)
					{
						val3.ZoomSettings.MaxZoom = Math.Max(val3.ZoomSettings.MaxZoom, Zoom);
						val3.ZoomSettings.MaxPitch = Math.Max(val3.ZoomSettings.MaxPitch, Pitch);
						val3.Target.Zoom = (val3.Current.Zoom = Zoom);
						val3.Target.Pitch = (val3.Current.Pitch = Pitch);
						current.Write<TopdownCameraState>(val3);
					}
				}
				val2.Dispose();
			}
		}

		public static bool Active;

		public static float Zoom = 40f;

		public static float Pitch = 1.4f;

		private static bool logged;
	}
	internal static class BenchInput
	{
		[HarmonyPatch(typeof(GameplayInputSystem), "OnUpdate")]
		private static class MovePatch
		{
			private static void Postfix(GameplayInputSystem __instance)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: 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_004f: 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_009a: 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_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Expected I4, but got Unknown
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Expected I4, but got Unknown
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Expected I4, but got Unknown
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				if (!TestHarness.Enabled || !Active)
				{
					return;
				}
				Calls++;
				((SystemBase)__instance).CompleteDependency();
				Ecs.World = ((ComponentSystemBase)__instance).World;
				Entity localCharacter = Core.LocalCharacter;
				if (!(localCharacter == Entity.Null) && localCharacter.Has<EntityInput>())
				{
					EntityInput data = localCharacter.Read<EntityInput>();
					if (math.lengthsq(Move) > 0f)
					{
						data.Movement = Move;
					}
					if (Aim.HasValue)
					{
						data.AimPosition = Aim.Value;
						data.AimPositionPlane = Aim.Value;
					}
					if (Hover != Entity.Null)
					{
						data.HoveredEntity = Hover;
						data.HoveredEntityNetworkId = Hover.Read<NetworkId>();
					}
					ref SyncedButtonInputAction inputsDown = ref data.State.InputsDown;
					inputsDown |= down;
					ref SyncedButtonInputAction inputsPressed = ref data.State.InputsPressed;
					inputsPressed |= pressed;
					ref SyncedButtonInputAction inputsUp = ref data.State.InputsUp;
					inputsUp |= up;
					down = (SyncedButtonInputAction)0;
					up = (SyncedButtonInputAction)0;
					localCharacter.Write<EntityInput>(data);
				}
			}
		}

		public static float2 Move;

		public static float3? Aim;

		public static Entity Hover = Entity.Null;

		public static int Calls;

		private static SyncedButtonInputAction pressed;

		private static SyncedButtonInputAction down;

		private static SyncedButtonInputAction up;

		private static byte[] keyboard;

		private static bool Active
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: 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_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Invalid comparison between Unknown and I4
				if (!(math.lengthsq(Move) > 0f) && !Aim.HasValue && !(Hover != Entity.Null) && (int)pressed == 0 && (int)down == 0)
				{
					return (int)up > 0;
				}
				return true;
			}
		}

		public static void Press(SyncedButtonInputAction a)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			down |= a;
			pressed |= a;
		}

		public static void Release(SyncedButtonInputAction a)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			pressed = (SyncedButtonInputAction)(pressed & (ushort)(~a));
			up |= a;
		}

		public static IEnumerator Tap(SyncedButtonInputAction a, float hold = 0.15f)
		{
			//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)
			Press(a);
			yield return new Wait(hold);
			Release(a);
			yield return null;
		}

		public unsafe static void Key(Key key, bool down)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected I4, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			Keyboard current = Keyboard.current;
			if (current == null)
			{
				Core.Log.LogWarning((object)"bench input: no keyboard");
				return;
			}
			InputSettings settings = InputSystem.settings;
			if ((int)settings.backgroundBehavior != 2)
			{
				settings.backgroundBehavior = (BackgroundBehavior)2;
			}
			InputStateBlock stateBlock = ((InputControl)current).stateBlock;
			int alignedSizeInBytes = (int)((InputStateBlock)(ref stateBlock)).alignedSizeInBytes;
			if (keyboard == null)
			{
				keyboard = new byte[alignedSizeInBytes];
			}
			int num = (int)key;
			if (down)
			{
				keyboard[num / 8] |= (byte)(1 << num % 8);
			}
			else
			{
				keyboard[num / 8] &= (byte)(~(1 << num % 8));
			}
			int num2 = 24 + alignedSizeInBytes;
			IntPtr intPtr = Marshal.AllocHGlobal(num2);
			try
			{
				byte* ptr = (byte*)(void*)intPtr;
				for (int i = 0; i < num2; i++)
				{
					ptr[i] = 0;
				}
				*(int*)ptr = 1398030676;
				((short*)ptr)[2] = (short)(ushort)num2;
				((short*)ptr)[3] = (short)(ushort)((InputDevice)current).deviceId;
				((double*)ptr)[1] = InputState.currentTime;
				((int*)ptr)[5] = ((InputStateBlock)(ref stateBlock)).format.m_Code;
				for (int j = 0; j < alignedSizeInBytes; j++)
				{
					ptr[24 + j] = keyboard[j];
				}
				InputSystem.QueueEvent(new InputEventPtr((InputEvent*)ptr));
			}
			finally
			{
				Marshal.FreeHGlobal(intPtr);
			}
		}
	}
	internal enum GearSlot
	{
		Headgear,
		Chest,
		Gloves,
		Legs,
		Footgear,
		Cloak,
		Jewelry,
		Bag
	}
	internal sealed class CatalogItem
	{
		public int Guid;

		public string Internal;

		public string Name;

		public Sprite Icon;

		public float Level;

		public int Tier;

		public int MaxStack;

		public GearSlot Slot;

		public WeaponType Weapon;

		public int[] StatMods = Array.Empty<int>();

		public int[] Infusions = Array.Empty<int>();

		public string Family;

		public string Set;

		public int EquipmentSet;

		public bool Boss;

		public bool HasBonuses => StatMods.Length != 0;
	}
	internal sealed class GearSet
	{
		public string Key;

		public string Name;

		public Sprite Icon;

		public float Level;

		public CatalogItem Chest;

		public bool NamedByGame;

		public readonly List<CatalogItem> Pieces = new List<CatalogItem>();
	}
	internal sealed class JewelAbility
	{
		public int Guid;

		public string Internal;

		public string Name;

		public Sprite Icon;

		public string School;

		public int[] Mods = Array.Empty<int>();
	}
	internal sealed class BloodTypeEntry
	{
		public int Guid;

		public string Internal;

		public string Name;

		public Sprite Icon;
	}
	internal static class Catalog
	{
		public static readonly List<CatalogItem> Gear = new List<CatalogItem>();

		public static readonly List<GearSet> Sets = new List<GearSet>();

		public static readonly List<CatalogItem> Weapons = new List<CatalogItem>();

		public static readonly List<CatalogItem> Consumables = new List<CatalogItem>();

		public static readonly List<JewelAbility> Jewels = new List<JewelAbility>();

		public static readonly List<BloodTypeEntry> BloodTypes = new List<BloodTypeEntry>();

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

		public static int BloodMerlot;

		public static int MixedBloodMerlot;

		private static bool ready;

		private static int builtSession = -1;

		private static string builtLanguage;

		private static readonly Dictionary<int, string> internalNames = new Dictionary<int, string>();

		private static readonly Regex TierRx = new Regex("_T(\\d\\d)", RegexOptions.Compiled);

		private static readonly Regex SetRx = new Regex("^Item_(Chest|Gloves|Legs|Boots)_(.+)$", RegexOptions.Compiled);

		private static readonly GearSlot[] SetSlots = new GearSlot[4]
		{
			GearSlot.Chest,
			GearSlot.Gloves,
			GearSlot.Legs,
			GearSlot.Footgear
		};

		private static readonly string[] Excluded = new string[10] { "_Shattered", "_Trader_Template", "Debug", "DEBUG", "_Test", "Dummy", "_Unused", "_Deprecated", "_OLD", "Cosmetic" };

		private static readonly string[] SchoolNames = new string[6] { "Blood", "Chaos", "Frost", "Illusion", "Storm", "Unholy" };

		private static readonly Regex ValueToken = new Regex("(<color=[^>]*>)?\\{value\\}%?(</color>)?\\s*", RegexOptions.Compiled);

		private static int valueLogs;

		private static readonly HashSet<string> ExcludedBlood = new HashSet<string> { "BloodType_None", "BloodType_GateBoss", "BloodType_VBlood", "BloodType_DraculaTheImmortal" };

		public static bool Ready
		{
			get
			{
				if (ready && builtSession == Core.Session)
				{
					return Lang.Same(builtLanguage, Lang.Current);
				}
				return false;
			}
		}

		public static bool Building { get; private set; }

		public static event Action Cleared;

		public static string Internal(int guid)
		{
			if (!internalNames.TryGetValue(guid, out var value))
			{
				return guid.ToString();
			}
			return value;
		}

		public static IEnumerator Build()
		{
			if (Ready || Building)
			{
				yield break;
			}
			Building = true;
			float t0 = Time.realtimeSinceStartup;
			World world = Core.ClientWorld;
			int session = Core.Session;
			string language = Lang.Current;
			Clear();
			Ecs.World = world;
			PrefabCollectionSystem pcs = world.GetExistingSystemManaged<PrefabCollectionSystem>();
			ManagedDataRegistry reg = ((ManagedDataSystem_Base)world.GetExistingSystemManaged<ManagedDataSystem>()).ManagedDataRegistry;
			Enumerator<string, PrefabGUID> enumerator = pcs._SpawnableNameToPrefabGuidDictionary.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<string, PrefabGUID> current = enumerator.Current;
				Dictionary<int, string> dictionary = internalNames;
				PrefabGUID value = current.Value;
				dictionary[((PrefabGUID)(ref value)).GuidHash] = current.Key;
			}
			NativeArray<PrefabGUID> keyArray = pcs._PrefabGuidToEntityMap.GetKeyArray(AllocatorHandle.op_Implicit((Allocator)2));
			List<PrefabGUID> guids = new List<PrefabGUID>(keyArray.Length);
			Enumerator<PrefabGUID> enumerator2 = keyArray.GetEnumerator();
			ConvertedAssetData val = default(ConvertedAssetData);
			while (enumerator2.MoveNext())
			{
				PrefabGUID current2 = enumerator2.Current;
				guids.Add(current2);
				if (!internalNames.ContainsKey(((PrefabGUID)(ref current2)).GuidHash) && pcs._PrefabDataLookup.TryGetValue(current2, ref val))
				{
					internalNames[((PrefabGUID)(ref current2)).GuidHash] = ((FixedString128Bytes)(ref val.AssetName)).Value;
				}
			}
			keyArray.Dispose();
			yield return null;
			BloodMerlot = Find("Item_Consumable_PrisonPotion_Bloodwine");
			MixedBloodMerlot = Find("Item_Consumable_PrisonPotion_Mixed");
			int n = 0;
			Entity val2 = default(Entity);
			bool flag = default(bool);
			foreach (PrefabGUID item in guids)
			{
				PrefabGUID g = item;
				int num = n + 1;
				n = num;
				if (num % 400 == 0)
				{
					yield return null;
				}
				if (!pcs._PrefabGuidToEntityMap.TryGetValue(g, ref val2))
				{
					continue;
				}
				string text = Internal(((PrefabGUID)(ref g)).GuidHash);
				try
				{
					if (text.StartsWith("Item_") && val2.Has<ItemData>())
					{
						AddItem(g, val2, text, reg);
					}
					else if (text.StartsWith("BloodType_"))
					{
						AddBloodType(g, text, reg);
					}
					else if (text.StartsWith("AB_") && val2.Has<AbilityJewelTemplate>())
					{
						AddJewelAbility(g, val2, text, reg);
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log = Core.Log;
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(11, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("catalog: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val3);
				}
			}
			Entity val4 = default(Entity);
			foreach (CatalogItem weapon in Weapons)
			{
				if (pcs._PrefabGuidToEntityMap.TryGetValue(new PrefabGUID(weapon.Guid), ref val4) && val4.Has<LegendaryItemGeneratorTemplate>())
				{
					Dictionary<string, int[]> dictionary2 = ParseGenerators(Dump(world, val4), "LegendaryItemGeneratorTemplate");
					weapon.StatMods = (dictionary2.TryGetValue("StatModsGenerator", out var value2) ? value2 : Array.Empty<int>());
					weapon.Infusions = (dictionary2.TryGetValue("Ability0ModsGenerator", out var value3) ? value3 : Array.Empty<int>());
					yield return null;
				}
			}
			Entity e = default(Entity);
			foreach (JewelAbility jewel in Jewels)
			{
				if (pcs._PrefabGuidToEntityMap.TryGetValue(new PrefabGUID(jewel.Guid), ref e))
				{
					Dictionary<string, int[]> dictionary3 = ParseGenerators(Dump(world, e), "AbilityJewelTemplate");
					jewel.Mods = (dictionary3.TryGetValue("JewelItemGenerator", out var value4) ? value4 : Array.Empty<int>());
				}
			}
			Jewels.RemoveAll((JewelAbility j) => j.Mods.Length == 0);
			Dictionary<int, string> schools = SchoolOfSpells(pcs);
			if (schools.Count > 0)
			{
				Jewels.RemoveAll((JewelAbility j) => !schools.ContainsKey(j.Guid));
				foreach (JewelAbility jewel2 in Jewels)
				{
					jewel2.School = schools[jewel2.Guid];
				}
			}
			foreach (int item2 in Weapons.SelectMany((CatalogItem w) => w.StatMods.Concat(w.Infusions)).Concat(Jewels.SelectMany((JewelAbility j) => j.Mods)).Distinct())
			{
				ModNames[item2] = ModLabel(Internal(item2));
			}
			Gear.Sort((CatalogItem a, CatalogItem b) => (a.Slot == b.Slot) ? ((a.Boss == b.Boss) ? ((a.Level == b.Level) ? string.CompareOrdinal(a.Set ?? a.Internal, b.Set ?? b.Internal) : b.Level.CompareTo(a.Level)) : b.Boss.CompareTo(a.Boss)) : a.Slot.CompareTo(b.Slot));
			BuildSets();
			Weapons.Sort((CatalogItem a, CatalogItem b) => (a.Weapon == b.Weapon) ? b.Level.CompareTo(a.Level) : string.CompareOrdinal(((object)Unsafe.As<WeaponType, WeaponType>(ref a.Weapon)/*cast due to .constrained prefix*/).ToString(), ((object)Unsafe.As<WeaponType, WeaponType>(ref b.Weapon)/*cast due to .constrained prefix*/).ToString()));
			Consumables.Sort((CatalogItem a, CatalogItem b) => string.CompareOrdinal(a.Name, b.Name));
			Jewels.Sort((JewelAbility a, JewelAbility b) => (!(a.School != b.School)) ? string.CompareOrdinal(a.Name, b.Name) : string.CompareOrdinal(a.School, b.School));
			BloodTypes.Sort((BloodTypeEntry a, BloodTypeEntry b) => string.CompareOrdinal(a.Name, b.Name));
			ready = true;
			builtSession = session;
			builtLanguage = language;
			Building = false;
			ManualLogSource log2 = Core.Log;
			BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(99, 8, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("catalog: ");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(Gear.Count);
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" gear, ");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(Weapons.Count);
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" weapons (");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(Weapons.Count((CatalogItem w) => w.HasBonuses));
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" with bonuses), ");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(Consumables.Count);
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" consumables, ");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(BloodTypes.Count);
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" blood types, ");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(Jewels.Count);
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" jewel abilities, ");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(ModNames.Count);
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" mods in ");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(Time.realtimeSinceStartup - t0, "F1");
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" s");
			}
			log2.LogInfo(val5);
		}

		private static void Clear()
		{
			ready = false;
			Gear.Clear();
			Sets.Clear();
			Weapons.Clear();
			Consumables.Clear();
			Jewels.Clear();
			BloodTypes.Clear();
			ModNames.Clear();
			internalNames.Clear();
			Catalog.Cleared?.Invoke();
		}

		private static Dictionary<int, string> SchoolOfSpells(PrefabCollectionSystem pcs)
		{
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<int, string> dictionary = new Dictionary<int, string>();
			try
			{
				Entity entity = default(Entity);
				foreach (KeyValuePair<int, string> kv in internalNames)
				{
					if (kv.Value.EndsWith("SpellSchoolAsset") && pcs._PrefabGuidToEntityMap.TryGetValue(new PrefabGUID(kv.Key), ref entity) && entity.Has<SpellSchoolAbility>())
					{
						string value = SchoolNames.FirstOrDefault((string n) => kv.Value.Contains(n)) ?? Pretty(kv.Value.Replace("SpellSchoolAsset", ""));
						Enumerator<SpellSchoolAbility> enumerator2 = entity.Buffer<SpellSchoolAbility>().GetEnumerator();
						while (enumerator2.MoveNext())
						{
							SpellSchoolAbility current = enumerator2.Current;
							PrefabGUID abilityGroup = current.AbilityGroup;
							dictionary[((PrefabGUID)(ref abilityGroup)).GuidHash] = value;
						}
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Core.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(24, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("catalog: spell schools: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
			return dictionary;
		}

		private static void BuildSets()
		{
			Sets.Clear();
			foreach (IGrouping<string, CatalogItem> item in from i in Gear
				where i.Set != null
				group i by i.Set)
			{
				List<CatalogItem> list = item.OrderBy((CatalogItem i) => Array.IndexOf(SetSlots, i.Slot)).ToList();
				if (list.Count >= 2 && list.Select((CatalogItem i) => i.Slot).Distinct().Count() == list.Count)
				{
					GearSet gearSet = new GearSet
					{
						Key = item.Key,
						Level = list.Max((CatalogItem i) => i.Level),
						Chest = list[0],
						Icon = list[0].Icon
					};
					gearSet.Pieces.AddRange(list);
					gearSet.Name = SetName(list[0].EquipmentSet) ?? CommonWords(list.Select((CatalogItem i) => i.Name).ToList()) ?? Pretty(item.Key);
					Sets.Add(gearSet);
				}
			}
			Sets.Sort((GearSet a, GearSet b) => (a.Level == b.Level) ? string.CompareOrdinal(a.Key, b.Key) : b.Level.CompareTo(a.Level));
		}

		private static string SetName(int setGuid)
		{
			//IL_0021: 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_0041: 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_0050: 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)
			if (setGuid == 0)
			{
				return null;
			}
			try
			{
				ManagedDataRegistry managedDataRegistry = ((ManagedDataSystem_Base)Core.ClientWorld.GetExistingSystemManaged<ManagedDataSystem>()).ManagedDataRegistry;
				PrefabGUID val = default(PrefabGUID);
				((PrefabGUID)(ref val))..ctor(setGuid);
				string text = null;
				ManagedItemData orDefault = managedDataRegistry.GetOrDefault<ManagedItemData>(val, (ManagedItemData)null);
				if (orDefault != null)
				{
					text = Localized(orDefault.Name);
				}
				if (string.IsNullOrWhiteSpace(text))
				{
					ManagedAbilityGroupData orDefault2 = managedDataRegistry.GetOrDefault<ManagedAbilityGroupData>(val, (ManagedAbilityGroupData)null);
					if (orDefault2 != null)
					{
						text = Localized(orDefault2.Name);
					}
				}
				if (string.IsNullOrWhiteSpace(text))
				{
					ManagedBlueprintData orDefault3 = managedDataRegistry.GetOrDefault<ManagedBlueprintData>(val, (ManagedBlueprintData)null);
					if (orDefault3 != null)
					{
						text = Localized(orDefault3.Name);
					}
				}
				return (string.IsNullOrWhiteSpace(text) || text.StartsWith("[")) ? null : text;
			}
			catch
			{
				return null;
			}
		}

		private static string CommonWords(List<string> names)
		{
			List<string[]> words = names.Select((string n) => n.Split(' ')).ToList();
			int k;
			for (k = 0; words.All((string[] w) => w.Length > k && w[k] == words[0][k]); k++)
			{
			}
			if (k > 0)
			{
				return string.Join(" ", words[0].Take(k));
			}
			for (k = 0; words.All((string[] w) => w.Length > k && w[w.Length - 1 - k] == words[0][words[0].Length - 1 - k]); k++)
			{
			}
			if (k == 0)
			{
				return null;
			}
			string text = string.Join(" ", words[0].Skip(words[0].Length - k));
			return char.ToUpper(text[0]) + text.Substring(1);
		}

		public static List<string> SecondaryTraits(int bloodGuid, float quality = 100f)
		{
			return (from b in BloodBuffGuids(bloodGuid, primary: false)
				select BloodBuffText(b, quality) ?? Pretty(Internal(b).Replace("AB_BloodBuff_", ""))).ToList();
		}

		public static List<string> PrimaryBonuses(int bloodGuid, float quality)
		{
			return (from b in BloodBuffGuids(bloodGuid, primary: true)
				select BloodBuffText(b, quality) ?? Pretty(Internal(b).Replace("AB_BloodBuff_", ""))).ToList();
		}

		public static float BonusThreshold(int index)
		{
			try
			{
				return BloodBuffUtility.GetQualityThreshold(index);
			}
			catch
			{
				return index switch
				{
					0 => 0f, 
					1 => 30f, 
					2 => 60f, 
					3 => 90f, 
					_ => 100f, 
				};
			}
		}

		public static string BloodBuffs(int bloodGuid, bool primary, float quality = 100f)
		{
			List<string> list = (from b in BloodBuffGuids(bloodGuid, primary)
				select BloodBuffText(b, quality) into t
				where t != null
				select "• " + t).ToList();
			if (list.Count != 0)
			{
				return string.Join("\n", list);
			}
			return null;
		}

		private static string BloodBuffText(int buff, float quality)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			World clientWorld = Core.ClientWorld;
			ManagedDataRegistry managedDataRegistry = ((ManagedDataSystem_Base)clientWorld.GetExistingSystemManaged<ManagedDataSystem>()).ManagedDataRegistry;
			PrefabCollectionSystem existingSystemManaged = clientWorld.GetExistingSystemManaged<PrefabCollectionSystem>();
			Entity val = default(Entity);
			existingSystemManaged._PrefabGuidToEntityMap.TryGetValue(new PrefabGUID(buff), ref val);
			int[] array = new int[2]
			{
				buff,
				NamedBloodBuff(buff)
			};
			bool flag = default(bool);
			foreach (int num in array)
			{
				try
				{
					ManagedDescriptionData orDefault = managedDataRegistry.GetOrDefault<ManagedDescriptionData>(new PrefabGUID(num), (ManagedDescriptionData)null);
					if (orDefault == null)
					{
						continue;
					}
					Entity val2 = val;
					if (val2 == Entity.Null && !existingSystemManaged._PrefabGuidToEntityMap.TryGetValue(new PrefabGUID(num), ref val2))
					{
						continue;
					}
					string text = null;
					try
					{
						DescriptionWrapper val3 = new DescriptionWrapper
						{
							Prefab = val2,
							DescriptionBuilder = orDefault.Description
						};
						text = BloodBuffUtility.GetBuffDescription(clientWorld.EntityManager, Core.LocalCharacter, val3, quality).Text;
					}
					catch (Exception ex)
					{
						if (valueLogs++ < 3)
						{
							ManualLogSource log = Core.Log;
							BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(23, 2, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("catalog: blood value ");
								((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num);
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": ");
								((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
							}
							log.LogWarning(val4);
						}
					}
					if (string.IsNullOrWhiteSpace(text) || text.Contains("{value}"))
					{
						Regex valueToken = ValueToken;
						LocalizedStringBuilderBase description = orDefault.Description;
						text = valueToken.Replace(((LocalizedStringBuilderBase)(ref description)).Build(clientWorld.EntityManager, val2).Text ?? "", "");
					}
					text = text.Trim();
					if (text.Length == 0)
					{
						continue;
					}
					return text.StartsWith("<") ? text : (char.ToUpper(text[0]) + text.Substring(1));
				}
				catch (Exception ex2)
				{
					ManualLogSource log2 = Core.Log;
					BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(22, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("catalog: blood buff ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num);
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex2.Message);
					}
					log2.LogWarning(val4);
				}
			}
			return null;
		}

		private static int NamedBloodBuff(int buff)
		{
			string text = Internal(buff);
			if (!text.EndsWith("_Secondary"))
			{
				return buff;
			}
			int num = Find(text.Substring(0, text.Length - "_Secondary".Length));
			if (num == 0)
			{
				return buff;
			}
			return num;
		}

		private static List<int> BloodBuffGuids(int bloodGuid, bool primary)
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = new List<int>();
			try
			{
				Entity entity = default(Entity);
				if (!Core.ClientWorld.GetExistingSystemManaged<PrefabCollectionSystem>()._PrefabGuidToEntityMap.TryGetValue(new PrefabGUID(bloodGuid), ref entity))
				{
					return list;
				}
				PrefabGUID buffType;
				if (primary && entity.Has<PrimaryUnitBloodTypeBuffs>())
				{
					Enumerator<PrimaryUnitBloodTypeBuffs> enumerator = entity.Buffer<PrimaryUnitBloodTypeBuffs>().GetEnumerator();
					while (enumerator.MoveNext())
					{
						PrimaryUnitBloodTypeBuffs current = enumerator.Current;
						buffType = current.BuffType;
						list.Add(((PrefabGUID)(ref buffType)).GuidHash);
					}
				}
				if (!primary && entity.Has<SecondaryUnitBloodTypeBuffs>())
				{
					Enumerator<SecondaryUnitBloodTypeBuffs> enumerator2 = entity.Buffer<SecondaryUnitBloodTypeBuffs>().GetEnumerator();
					while (enumerator2.MoveNext())
					{
						SecondaryUnitBloodTypeBuffs current2 = enumerator2.Current;
						buffType = current2.BuffType;
						list.Add(((PrefabGUID)(ref buffType)).GuidHash);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Core.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(23, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("catalog: blood buffs ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(bloodGuid);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
			return list;
		}

		public static CatalogItem FindItem(int guid)
		{
			return Gear.FirstOrDefault((CatalogItem i) => i.Guid == guid) ?? Weapons.FirstOrDefault((CatalogItem i) => i.Guid == guid) ?? Consumables.FirstOrDefault((CatalogItem i) => i.Guid == guid);
		}

		public static string ItemName(int guid)
		{
			return FindItem(guid)?.Name ?? Internal(guid);
		}

		public static Sprite ItemIcon(int guid)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			CatalogItem catalogItem = FindItem(guid);
			if (catalogItem != null)
			{
				return catalogItem.Icon;
			}
			try
			{
				ManagedItemData orDefault = ((ManagedDataSystem_Base)Core.ClientWorld.GetExistingSystemManaged<ManagedDataSystem>()).ManagedDataRegistry.GetOrDefault<ManagedItemData>(new PrefabGUID(guid), (ManagedItemData)null);
				return (orDefault != null) ? orDefault.Icon : null;
			}
			catch
			{
				return null;
			}
		}

		public static string ItemDescription(int guid)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				World clientWorld = Core.ClientWorld;
				ManagedItemData orDefault = ((ManagedDataSystem_Base)clientWorld.GetExistingSystemManaged<ManagedDataSystem>()).ManagedDataRegistry.GetOrDefault<ManagedItemData>(new PrefabGUID(guid), (ManagedItemData)null);
				PrefabCollectionSystem existingSystemManaged = clientWorld.GetExistingSystemManaged<PrefabCollectionSystem>();
				Entity val = default(Entity);
				if (orDefault == null || !existingSystemManaged._PrefabGuidToEntityMap.TryGetValue(new PrefabGUID(guid), ref val))
				{
					return null;
				}
				LocalizedStringBuilderBase description = orDefault.Description;
				return ((LocalizedStringBuilderBase)(ref description)).Build(clientWorld.EntityManager, val).Text;
			}
			catch
			{
				return null;
			}
		}

		private static int Find(string internalName)
		{
			foreach (KeyValuePair<int, string> internalName2 in internalNames)
			{
				if (internalName2.Value == internalName)
				{
					return internalName2.Key;
				}
			}
			return 0;
		}

		private static bool IsExcluded(string internalName)
		{
			return Excluded.Any(internalName.Contains);
		}

		private static string Localized(LocalizationKey key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return Localization.Get(key, false);
			}
			catch
			{
				return null;
			}
		}

		private static void AddItem(PrefabGUID g, Entity e, string internalName, ManagedDataRegistry reg)
		{
			//IL_0009: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Invalid comparison between Unknown and I4
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected I4, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Invalid comparison between Unknown and I4
			//IL_017c: 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)
			if (IsExcluded(internalName))
			{
				return;
			}
			ItemData val = e.Read<ItemData>();
			ManagedItemData orDefault = reg.GetOrDefault<ManagedItemData>(g, (ManagedItemData)null);
			string text = ((orDefault == null) ? null : Localized(orDefault.Name));
			if (string.IsNullOrWhiteSpace(text) || text.StartsWith("["))
			{
				return;
			}
			CatalogItem obj = new CatalogItem
			{
				Guid = ((PrefabGUID)(ref g)).GuidHash,
				Internal = internalName,
				Name = text,
				Icon = orDefault.Icon,
				MaxStack = Math.Max(1, val.MaxAmount)
			};
			Match match = TierRx.Match(internalName);
			obj.Tier = ((match != null && match.Success) ? int.Parse(match.Groups[1].Value) : 0);
			CatalogItem catalogItem = obj;
			if (e.Has<EquippableData>())
			{
				EquippableData val2 = e.Read<EquippableData>();
				catalogItem.EquipmentSet = ((PrefabGUID)(ref val2.EquipmentSet)).GuidHash;
				if (e.Has<ArmorLevelSource>())
				{
					catalogItem.Level = e.Read<ArmorLevelSource>().Level;
				}
				if (e.Has<WeaponLevelSource>())
				{
					catalogItem.Level = e.Read<WeaponLevelSource>().Level;
				}
				if (e.Has<SpellLevelSource>())
				{
					catalogItem.Level = e.Read<SpellLevelSource>().Level;
				}
				EquipmentType equipmentType = val2.EquipmentType;
				switch ((int)equipmentType)
				{
				default:
					return;
				case 2:
					if ((int)val2.WeaponType != 0 && (int)val2.WeaponType != 8)
					{
						catalogItem.Weapon = val2.WeaponType;
						Weapons.Add(catalogItem);
					}
					return;
				case 0:
					catalogItem.Slot = GearSlot.Headgear;
					break;
				case 1:
					catalogItem.Slot = GearSlot.Chest;
					break;
				case 9:
					catalogItem.Slot = GearSlot.Gloves;
					break;
				case 5:
					catalogItem.Slot = GearSlot.Legs;
					break;
				case 4:
					catalogItem.Slot = GearSlot.Footgear;
					break;
				case 8:
					catalogItem.Slot = GearSlot.Cloak;
					break;
				case 3:
					if (internalName.Contains("BloodKey"))
					{
						return;
					}
					catalogItem.Boss = internalName.Contains("SoulShard");
					catalogItem.Slot = GearSlot.Jewelry;
					break;
				case 10:
					catalogItem.Slot = GearSlot.Bag;
					break;
				case 6:
				case 7:
					return;
				}
				if (catalogItem.Slot == GearSlot.Bag && catalogItem.Level == 0f)
				{
					catalogItem.Level = catalogItem.Tier;
				}
				Match match2 = SetRx.Match(internalName);
				bool flag = match2.Success;
				if (flag)
				{
					GearSlot slot = catalogItem.Slot;
					bool flag2 = (uint)(slot - 1) <= 3u;
					flag = flag2;
				}
				if (flag)
				{
					catalogItem.Set = match2.Groups[2].Value;
				}
				Gear.Add(catalogItem);
			}
			else if ((int)val.ItemType == 1 && ((PrefabGUID)(ref g)).GuidHash != BloodMerlot && ((PrefabGUID)(ref g)).GuidHash != MixedBloodMerlot)
			{
				catalogItem.Family = TierRx.Replace(internalName, "");
				Consumables.Add(catalogItem);
			}
		}

		private static void AddBloodType(PrefabGUID g, string internalName, ManagedDataRegistry reg)
		{
			//IL_000f: 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)
			if (!ExcludedBlood.Contains(internalName))
			{
				ManagedUnitBloodTypeData orDefault = reg.GetOrDefault<ManagedUnitBloodTypeData>(g, (ManagedUnitBloodTypeData)null);
				string text = ((orDefault == null) ? null : Localized(orDefault.Name));
				if (string.IsNullOrWhiteSpace(text) || text.StartsWith("["))
				{
					text = Pretty(internalName.Substring("BloodType_".Length));
				}
				BloodTypes.Add(new BloodTypeEntry
				{
					Guid = ((PrefabGUID)(ref g)).GuidHash,
					Internal = internalName,
					Name = text,
					Icon = ((orDefault != null) ? orDefault.Icon : null)
				});
			}
		}

		private unsafe static void AddJewelAbility(PrefabGUID g, Entity e, string internalName, ManagedDataRegistry reg)
		{
			//IL_0017: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if (!internalName.Contains("Recast") && !IsExcluded(internalName))
			{
				ManagedAbilityGroupData orDefault = reg.GetOrDefault<ManagedAbilityGroupData>(g, (ManagedAbilityGroupData)null);
				string text = ((orDefault == null) ? null : Localized(orDefault.Name));
				if (string.IsNullOrWhiteSpace(text))
				{
					text = Pretty(internalName.Replace("AB_", "").Replace("_AbilityGroup", ""));
				}
				string[] array = internalName.Split('_');
				object obj;
				if (!e.Has<VBloodAbilityData>())
				{
					obj = ((array.Length > 1) ? array[1] : "?");
				}
				else
				{
					VBloodAbilityData val = e.Read<VBloodAbilityData>();
					obj = ((object)(*(AbilitySchoolType*)(&val.AbilitySchool))/*cast due to .constrained prefix*/).ToString();
				}
				string school = (string)obj;
				Jewels.Add(new JewelAbility
				{
					Guid = ((PrefabGUID)(ref g)).GuidHash,
					Internal = internalName,
					Name = text,
					Icon = ((orDefault != null) ? orDefault.Icon : null),
					School = school
				});
			}
		}

		private static string Dump(World world, Entity e)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder val = new StringBuilder();
			EntityDebuggingUtility.DumpEntity(world, e, true, val);
			return ((Object)val).ToString();
		}

		public static Dictionary<string, int[]> ParseGenerators(string dump, string component)
		{
			Dictionary<string, int[]> result = new Dictionary<string, int[]>();
			string[] array = dump.Split('\n');
			bool flag = false;
			string gen = null;
			List<int> ids = new List<int>();
			string[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				string text = array2[i].TrimEnd('\r');
				if (text.StartsWith("["))
				{
					if (flag)
					{
						Flush();
						gen = null;
					}
					flag = text.EndsWith("." + component + "]");
				}
				else
				{
					if (!flag)
					{
						continue;
					}
					if (text.StartsWith(" - ") && text.Contains("Generator"))
					{
						Flush();
						gen = text.Substring(3).Split(' ')[0];
						continue;
					}
					int num = text.IndexOf("_Value ", StringComparison.Ordinal);
					if (gen != null && num >= 0 && int.TryParse(text.Substring(num + 7).Trim(), out var result2) && result2 != 0)
					{
						ids.Add(result2);
					}
				}
			}
			if (flag)
			{
				Flush();
			}
			return result;
			void Flush()
			{
				if (gen != null)
				{
					result[gen] = ids.Distinct().ToArray();
				}
				ids = new List<int>();
			}
		}

		public static string ModLabel(string internalName)
		{
			string text = internalName;
			string[] array = new string[4] { "StatMod_", "SpellMod_Weapon_", "SpellMod_Shared_", "SpellMod_" };
			foreach (string text2 in array)
			{
				if (text.StartsWith(text2))
				{
					text = text.Substring(text2.Length);
					break;
				}
			}
			return Pretty(text);
		}

		public static string Pretty(string s)
		{
			return Regex.Replace(s.Replace('_', ' '), "(?<=[a-z])(?=[A-Z])", " ").Trim();
		}
	}
	internal static class ClientChannel
	{
		private sealed class Pending
		{
			public Action<bool, string> Callback;

			public float SentAt;
		}

		public sealed class Call
		{
			public bool Done;

			public bool Ok;

			public string Body;
		}

		[HarmonyPatch(typeof(ClientChatSystem), "OnUpdate")]
		private static class ChatPatch
		{
			private static void Prefix(ClientChatSystem __instance)
			{
				//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_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_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: 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_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				Ecs.World = ((ComponentSystemBase)__instance).World;
				EntityQuery receiveChatMessagesQuery = __instance._ReceiveChatMessagesQuery;
				NativeArray<Entity> val = ((EntityQuery)(ref receiveChatMessagesQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				try
				{
					Enumerator<Entity> enumerator = val.GetEnumerator();
					while (enumerator.MoveNext())
					{
						Entity current = enumerator.Current;
						if (current.Has<ChatMessageServerEvent>())
						{
							ChatMessageServerEvent val2 = current.Read<ChatMessageServerEvent>();
							string value = ((FixedString512Bytes)(ref val2.MessageText)).Value;
							if (Protocol.IsOurs(value))
							{
								EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
								((EntityManager)(ref entityManager)).DestroyEntity(current);
								Receive(value);
							}
						}
					}
				}
				finally
				{
					val.Dispose();
				}
			}
		}

		private static readonly Dictionary<int, Pending> pending = new Dictionary<int, Pending>();

		private static readonly Dictionary<string, Action<string>> topics = new Dictionary<string, Action<string>>(StringComparer.Ordinal);

		private static readonly Protocol.Assembler assembler = new Protocol.Assembler();

		private static int nextId = 1;

		public static bool Connected
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				if (Core.LocalCharacter != Entity.Null)
				{
					return Core.LocalUser != Entity.Null;
				}
				return false;
			}
		}

		public static void OnPush(string topic, Action<string> handler)
		{
			topics[topic] = handler;
		}

		public static void Send(string command, string body, Action<bool, string> callback = null)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			int num = nextId++;
			if (callback != null)
			{
				pending[num] = new Pending
				{
					Callback = callback,
					SentAt = Time.realtimeSinceStartup
				};
			}
			string text = Protocol.Request(num, command, body);
			EntityManager entityManager = Core.EntityManager;
			Entity entity = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[4]
			{
				ComponentType.ReadOnly(Il2CppType.Of<FromCharacter>()),
				ComponentType.ReadOnly(Il2CppType.Of<NetworkEventType>()),
				ComponentType.ReadOnly(Il2CppType.Of<SendNetworkEventTag>()),
				ComponentType.ReadOnly(Il2CppType.Of<ChatMessageEvent>())
			});
			entity.Write<FromCharacter>(new FromCharacter
			{
				Character = Core.LocalCharacter,
				User = Core.LocalUser
			});
			entity.Write<NetworkEventType>(new NetworkEventType
			{
				EventId = NetworkEvents.EventId_ChatMessageEvent,
				IsAdminEvent = false,
				IsDebugEvent = false
			});
			entity.Write<ChatMessageEvent>(new ChatMessageEvent
			{
				MessageText = new FixedString512Bytes(text),
				MessageType = (ChatMessageType)4,
				ReceiverEntity = Core.LocalUser.Read<NetworkId>()
			});
		}

		public static IEnumerator Ask(string command, string body, Call result, float timeout = 15f)
		{
			Send(command, body, delegate(bool ok, string b)
			{
				result.Ok = ok;
				result.Body = b;
				result.Done = true;
			});
			float t0 = Time.realtimeSinceStartup;
			while (!result.Done && Time.realtimeSinceStartup - t0 < timeout)
			{
				yield return null;
			}
			if (!result.Done)
			{
				result.Ok = false;
				result.Body = "timeout";
			}
		}

		private static void Receive(string text)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			if (!assembler.Feed(text, out var id, out var ok, out var body))
			{
				return;
			}
			if (id == 0)
			{
				int num = body.IndexOf('|');
				string key = ((num < 0) ? body : body.Substring(0, num));
				if (topics.TryGetValue(key, out var value))
				{
					value((num < 0) ? "" : body.Substring(num + 1));
				}
			}
			else
			{
				if (!pending.Remove(id, out var value2))
				{
					return;
				}
				try
				{
					value2.Callback(ok, body);
				}
				catch (Exception ex)
				{
					ManualLogSource log = Core.Log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(22, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("reply handler failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					log.LogError(val);
				}
			}
		}
	}
	internal static class Core
	{
		private static World client;

		private static MonoBehaviour host;

		public static ManualLogSource Log => Plugin.LogInstance;

		public static string DataDir => Path.Combine(Paths.BepInExRootPath, "DraculaTrainingRoom");

		public static int Session { get; private set; }

		public static World ClientWorld
		{
			get
			{
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Expected O, but got Unknown
				if (client != null && client.IsCreated)
				{
					return client;
				}
				client = null;
				Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
				while (enumerator.MoveNext())
				{
					World current = enumerator.Current;
					if (current.Name.StartsWith("Client") && current.IsCreated)
					{
						client = current;
						break;
					}
				}
				if (client != null)
				{
					Ecs.World = client;
					Session++;
					ManualLogSource log = Log;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("client world ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(client.Name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (session ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Session);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
					}
					log.LogInfo(val);
				}
				return client;
			}
		}

		public static EntityManager EntityManager => ClientWorld.EntityManager;

		public static Entity LocalCharacter
		{
			get
			{
				//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_001b: 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)
				World clientWorld = ClientWorld;
				Entity result = Entity.Null;
				if (clientWorld != null && ConsoleShared.TryGetLocalCharacterInCurrentWorld(ref result, clientWorld))
				{
					return result;
				}
				return Entity.Null;
			}
		}

		public static Entity LocalUser
		{
			get
			{
				//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_001b: 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)
				World clientWorld = ClientWorld;
				Entity result = Entity.Null;
				if (clientWorld != null && ConsoleShared.TryGetLocalUserInCurrentWorld(ref result, clientWorld))
				{
					return result;
				}
				return Entity.Null;
			}
		}

		public static Coroutine StartIl2CppCoroutine(IEnumerator routine)
		{
			StartCoroutine(Empty());
			return host.StartCoroutine(routine);
		}

		private static IEnumerator Empty()
		{
			yield break;
		}

		public static Coroutine StartCoroutine(IEnumerator routine)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if ((Object)(object)host == (Object)null)
			{
				GameObject val = new GameObject("DraculaTrainingRoom.Client");
				host = (MonoBehaviour)(object)val.AddComponent<IgnorePhysicsDebugSystem>();
				Object.DontDestroyOnLoad((Object)val);
			}
			return host.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
		}
	}
	[HarmonyPatch(typeof(SalvagestationSubMenuMapper), "OnUpdate")]
	internal static class DevourerTimer
	{
		private const int InstantDevourer = -1719849142;

		private static int logs;

		private static void Postfix(SalvagestationSubMenuMapper __instance)
		{
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Ecs.World = ((ComponentSystemBase)__instance).World;
				SalvagestationSubMenu menu = __instance._Menu;
				if ((Object)(object)menu == (Object)null || !((Component)menu).gameObject.activeInHierarchy || (Object)(object)menu.RefinementProgress == (Object)null)
				{
					return;
				}
				Entity targetWorkstationEntity = __instance.GetTargetWorkstationEntity();
				if (!targetWorkstationEntity.Exists())
				{
					return;
				}
				PrefabGUID val = targetWorkstationEntity.Guid();
				if (((PrefabGUID)(ref val)).GuidHash != -1719849142 || !targetWorkstationEntity.Has<Salvagestation>())
				{
					return;
				}
				Entity entity = targetWorkstationEntity.Read<Salvagestation>().InputInventoryEntity._Entity;
				bool flag = false;
				if (entity.Exists() && entity.Has<InventoryBuffer>())
				{
					Enumerator<InventoryBuffer> enumerator = entity.Buffer<InventoryBuffer>().GetEnumerator();
					while (enumerator.MoveNext())
					{
						InventoryBuffer current = enumerator.Current;
						val = current.ItemType;
						if (((PrefabGUID)(ref val)).GuidHash != 0 && current.Amount > 0)
						{
							flag = true;
							break;
						}
					}
				}
				LocalizedText timer = menu.RefinementProgress.Timer;
				string text = (flag ? "1s" : "");
				if (timer.GetText() != text)
				{
					timer.ForceSet(text);
				}
			}
			catch (Exception ex)
			{
				if (logs++ < 3)
				{
					ManualLogSource log = Core.Log;
					bool flag2 = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(16, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("devourer timer: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val2);
				}
			}
		}
	}
	internal static class HostedServerWait
	{
		[HarmonyPatch(typeof(ClientBootstrapSystem), "OnUpdate")]
		private static class RetryPatch
		{
			private static void Prefix(ClientBootstrapSystem __instance)
			{
				if (pid != 0 && __instance.RetryAttempts != 0 && Waiting())
				{
					if (!announced)
					{
						announced = true;
						Core.Log.LogInfo((object)"hosted wait: the modded server is still starting (BepInEx prepares its files on the first launch), retrying until it is ready");
					}
					__instance.RetryAttempts = 0;
				}
			}
		}

		private static readonly TimeSpan MaxWait = TimeSpan.FromMinutes(10.0);

		private static uint pid;

		private static DateTime started;

		private static string readyFile;

		private static bool announced;

		public static string ReadyFile(string serverBep)
		{
			return Path.Combine(serverBep, "DraculaTrainingRoom", "hosted_ready.txt");
		}

		public static void Clear()
		{
			readyFile = null;
			pid = 0u;
		}

		public static void Launching(string serverBep)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			readyFile = ReadyFile(serverBep);
			try
			{
				if (File.Exists(readyFile))
				{
					File.Delete(readyFile);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Core.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(13, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("hosted wait: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
			pid = 0u;
		}

		public static void Launched(uint processId)
		{
			if (readyFile != null && processId != 0)
			{
				pid = processId;
				started = DateTime.UtcNow;
				announced = false;
			}
		}

		private static bool Waiting()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			if (pid == 0)
			{
				return false;
			}
			string text = null;
			if (File.Exists(readyFile))
			{
				text = "the server is ready";
			}
			else if (DateTime.UtcNow - started > MaxWait)
			{
				text = $"still not ready after {MaxWait.TotalMinutes:F0} min";
			}
			else
			{
				try
				{
					using Process process = Process.GetProcessById((int)pid);
					if (process.HasExited)
					{
						text = "the server process has exited";
					}
				}
				catch (ArgumentException)
				{
					text = "the server process has exited";
				}
			}
			if (text == null)
			{
				return true;
			}
			ManualLogSource log = Core.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("hosted wait: stop extending the connection attempts, ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
			}
			log.LogInfo(val);
			pid = 0u;
			return false;
		}
	}
	internal static class Lang
	{
		private static readonly Dictionary<string, (string en, string fr)> strings = new Dictionary<string, (string, string)>
		{
			["tab.appearance"] = ("Appearance", "Apparence"),
			["tab.gear"] = ("Armour & jewellery", "Armures & bijoux"),
			["tab.weapons"] = ("Weapons", "Armes"),
			["tab.consumables"] = ("Consumables", "Consommables"),
			["tab.blood"] = ("Blood potions", "Potions de sang"),
			["tab.jewels"] = ("Jewels", "Joyaux"),
			["all"] = ("All", "Tout"),
			["best"] = ("Best only", "Meilleurs seulement"),
			["quantity"] = ("Quantity", "Quantité"),
			["stack"] = ("Stack", "Pile"),
			["tier"] = ("Tier", "Rang"),
			["power"] = ("Effect", "Effet"),
			["quality"] = ("Quality", "Qualité"),
			["primary"] = ("Primary blood", "Sang principal"),
			["secondary"] = ("Blood infusion", "Infusion de sang"),
			["none"] = ("None", "Aucun"),
			["trait"] = ("Secondary trait", "Trait secondaire"),
			["create"] = ("Create", "Créer"),
			["infusion"] = ("Infusion", "Infusion"),
			["bonuses"] = ("Bonuses (up to 4)", "Bonus (jusqu'à 4)"),
			["mods"] = ("Modifiers (up to 4)", "Modificateurs (jusqu'à 4)"),
			["pick.weapon"] = ("Pick a weapon. Weapons without bonuses go straight to your inventory.", "Choisissez une arme. Les armes sans bonus vont directement dans l'inventaire."),
			["pick.jewel"] = ("Pick a spell.", "Choisissez un sort."),
			["received"] = ("Received", "Reçu"),
			["failed"] = ("Failed", "Échec"),
			["loading"] = ("Reading the game data…", "Lecture des données du jeu…"),
			["slot.Headgear"] = ("Headgear", "Couvre-chefs"),
			["slot.Chest"] = ("Chest", "Torse"),
			["slot.Gloves"] = ("Gloves", "Gants"),
			["slot.Legs"] = ("Legs", "Jambes"),
			["slot.Footgear"] = ("Boots", "Bottes"),
			["slot.Cloak"] = ("Cloaks", "Capes"),
			["slot.Jewelry"] = ("Amulets", "Amulettes"),
			["slot.Bag"] = ("Bags", "Sacs"),
			["devourer.name"] = ("The Instant Devourer", "The Instant Devourer"),
			["devourer.desc"] = ("Destroys whatever it is given, one item per second. Nothing comes back.", "Détruit tout ce qu'on lui donne, un objet par seconde. Rien n'est rendu."),
			["devourer.status"] = ("Instant: 1 item per second", "Instantané : 1 objet par seconde"),
			["mirror.name"] = ("Tchern's Mirror", "Tchern's Mirror"),
			["portal.name"] = ("Return portal", "Portail de retour"),
			["slot.Sets"] = ("Sets", "Ensembles"),
			["pieces"] = ("pieces", "pièces"),
			["boss"] = ("Boss amulet", "Amulette de boss"),
			["preview"] = ("What you will get", "Ce que vous obtiendrez"),
			["hint.equip"] = ("Armour, cloaks, amulets and bags go to their slot when it is empty, else to the inventory.", "Armures, capes, amulettes et sacs vont dans leur emplacement s'il est vide, sinon dans l'inventaire."),
			["tip.tab.appearance"] = ("Change your vampire's look, as with the 'Omen' Standing Mirror.", "Changer l'apparence du vampire, comme avec le miroir sur pied « présage »."),
			["tip.tab.gear"] = ("Any armour piece, armour set, cloak, hat, amulet (boss amulets included) or bag.", "N'importe quelle pièce ou ensemble d'armure, cape, chapeau, amulette (amulettes de boss comprises) ou sac."),
			["tip.tab.weapons"] = ("Any weapon. Legendary and artifact weapons: pick their infusion and bonuses.", "N'importe quelle arme. Armes légendaires et artefacts : choisissez l'infusion et les bonus."),
			["tip.tab.consumables"] = ("Any consumable: potions, elixirs, coatings, food...", "N'importe quel consommable : potions, élixirs, enduits, nourriture..."),
			["tip.tab.blood"] = ("Blood conversion potions, plain or mixed. Drinking one gives you that blood.", "Potions de conversion sanguine, simples ou mixées. En boire une vous donne ce sang."),
			["tip.tab.jewels"] = ("A jewel for any spell, with the modifiers you choose.", "Un joyau pour n'importe quel sort, avec les modificateurs de votre choix."),
			["tip.sets"] = ("Whole armour sets: one click gives the chest, gloves, legs and boots.", "Ensembles d'armure complets : un clic donne le torse, les gants, les jambes et les bottes."),
			["tip.best.gear"] = ("Only the highest gear level of each slot (boss amulets are always listed).", "Seulement le plus haut niveau d'équipement de chaque emplacement (les amulettes de boss sont toujours listées)."),
			["tip.best.weapons"] = ("Only the highest level of each weapon type.", "Seulement le plus haut niveau de chaque type d'arme."),
			["tip.best.consumables"] = ("Only the best tier of each consumable.", "Seulement le meilleur rang de chaque consommable."),
			["tip.power"] = ("How strong the modifiers are: 100 % is the best roll the game can give. Hover a modifier to read its value.", "Force des modificateurs : 100 % est le meilleur tirage possible. Survolez un modificateur pour lire sa valeur."),
			["tip.tier.weapon"] = ("The weapon's tier: higher tiers raise the bonuses.", "Le rang de l'arme : un rang plus élevé augmente les bonus."),
			["tip.tier.jewel"] = ("The jewel's tier: tier 4 is the best.", "Le rang du joyau : le rang 4 est le meilleur."),
			["tip.quality"] = ("Blood quality: 100 % unlocks every bonus of the blood type.", "Qualité du sang : 100 % débloque tous les bonus du type de sang."),
			["tip.quality.secondary"] = ("Quality of the secondary blood: the strength of the trait it brings.", "Qualité du sang secondaire : la force du trait qu'il apporte."),
			["tip.trait"] = ("The trait of the blood infusion that the mixed potion keeps.", "Le trait de l'infusion de sang que garde la potion mixée."),
			["trait.short"] = ("Trait", "Trait"),
			["trait.locked"] = ("Needs an infusion of at least {0} % quality.", "Demande une infusion d'au moins {0} % de qualité."),
			["infusion.bonus"] = ("Infusion bonus:", "Bonus d'infusion :"),
			["tip.infusion.bonus"] = ("Not chosen: added on top of the trait when the infusion's quality is 90 % or more.", "Pas à choisir : il s'ajoute au trait quand la qualité de l'infusion atteint 90 %."),
			["blood.desc"] = ("As with the Blood Homogenizer: the primary blood keeps all its benefits and quality, the blood infusion adds one chosen trait. Its quality decides the traits on offer, and from 90 % its infusion bonus. Potions are made here, no ingredients needed.", "Comme avec l'homogénéisateur de sang : le sang principal garde tous ses bienfaits et sa qualité, l'infusion de sang ajoute un trait choisi. Sa qualité décide des traits proposés et, dès 90 %, de son bonus d'infusion. Les potions sont créées ici, sans ingrédients."),
			["tip.quantity"] = ("How many to receive per click.", "Combien en recevoir par clic.")
		};

		public static string Current
		{
			get
			{
				try
				{
					return Localization._CurrentLanguage_k__BackingField ?? "";
				}
				catch
				{
					return "";
				}
			}
		}

		public static bool French => Current.IndexOf("french", StringComparison.OrdinalIgnoreCase) >= 0;

		public static bool Same(string a, string b)
		{
			return string.Equals(a, b, StringComparison.OrdinalIgnoreCase);
		}

		public static string T(string key)
		{
			if (!strings.TryGetValue(key, out (string, string) value))
			{
				return key;
			}
			if (!French)
			{
				return value.Item1;
			}
			return value.Item2;
		}

		public static string FrenchText(string key)
		{
			if (!strings.TryGetValue(key, out (string, string) value))
			{
				return key;
			}
			return value.Item2;
		}

		public static string EnglishText(string key)
		{
			if (!strings.TryGetValue(key, out (string, string) value))
			{
				return key;
			}
			return value.Item1;
		}
	}
	internal static class MirrorWindow
	{
		public sealed class GearFilter
		{
			public string Slot { get; set; } = "All";

			public bool Best { get; set; } = true;
		}

		public sealed class WeaponFilter
		{
			public string Type { get; set; } = "All";

			public bool Best { get; set; } = true;

			public int Tier { get; set; } = 3;

			public int Power { get; set; } = 100;
		}

		public sealed class ConsumableFilter
		{
			public bool Best { get; set; } = true;

			public int Quantity { get; set; } = 1;
		}

		public sealed class BloodFilter
		{
			public string Primary { get; set; } = "BloodType_Rogue";

			public int Quality { get; set; } = 100;

			public string Secondary { get; set; } = "";

			public int SecondaryQuality { get; set; } = 100;

			public int Trait { get; set; }

			public int Quantity { get; set; } = 1;
		}

		public sealed class JewelFilter
		{
			public string School { get; set; } = "All";

			public int Tier { get; set; } = 3;

			public int Power { get; set; } = 100;
		}

		public enum Tab
		{
			Appearance,
			Gear,
			Weapons,
			Consumables,
			Blood,
			Jewels
		}

		public static GearFilter Gear = new GearFilter();

		public static WeaponFilter Weapons = new WeaponFilter();

		public static ConsumableFilter Consumables = new ConsumableFilter();

		public static BloodFilter Blood = new BloodFilter();

		public static JewelFilter Jewels = new JewelFilter();

		private static readonly Tab[] Tabs = (Tab[])Enum.GetValues(typeof(Tab));

		private static GameObject root;

		private static RectTransform content;

		private static RectTransform tabBar;

		private static readonly Dictionary<Tab, UIKit.ChipButton> tabChips = new Dictionary<Tab, UIKit.ChipButton>();

		private static readonly Dictionary<Tab, VanillaUI.Widget> tabWidgets = new Dictionary<Tab, VanillaUI.Widget>();

		private static int tabBarSession = -1;

		private static string tabBarLanguage;

		private static TextMeshProUGUI status;

		private static bool filtersLoaded;

		private static bool filtersLoading;

		private static int openedSession = -1;

		private static Tab builtTab = (Tab)(-1);

		private static readonly List<(Action<bool> paint, Func<bool> selected)> cells = new List<(Action<bool>, Func<bool>)>();

		private static RectTransform rightPanel;

		private static Action<RectTransform> rightBuilder;

		private static CatalogItem selectedWeapon;

		private static int selectedInfusion;

		private static readonly List<int> selectedStatMods = new List<int>();

		private static JewelAbility selectedJewel;

		private static readonly List<int> selectedJewelMods = new List<int>();

		private const float SideMargin = 80f;

		private const float WindowWidth = 620f;

		private const float FilterWidth = 280f;

		private static RectTransform detailWindow;

		private static Action createAction;

		private const string SetsFilter = "Sets";

		private static readonly int[] TraitQuality = new int[4] { 0, 30, 60, 90 };

		private static readonly string[] Roman = new string[5] { "I", "II", "III", "IV", "V" };

		private static BloodMixerSubMenu mixerMenu;

		private static int mixerMenuSession = -1;

		private static readonly string[] Schoo

plugins/Dracula_Training_Room/DraculaTrainingRoom.Server.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Text;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Gameplay.Scripting;
using ProjectM.Gameplay.Systems;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Scripting;
using ProjectM.Shared;
using ProjectM.Terrain;
using ProjectM.Tiles;
using StunShared.UI;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DraculaTrainingRoom.Server")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DraculaTrainingRoom.Server")]
[assembly: AssemblyTitle("DraculaTrainingRoom.Server")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DraculaTrainingRoom
{
	internal static class Ecs
	{
		public static World World;

		private static EntityManager EM => World.EntityManager;

		public unsafe static T Read<T>(this Entity entity) where T : struct
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager eM = EM;
			return Unsafe.Read<T>(((EntityManager)(ref eM)).GetComponentDataRawRO(entity, val.TypeIndex));
		}

		public unsafe static void Write<T>(this Entity entity, T data) where T : struct
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager eM = EM;
			Unsafe.Write(((EntityManager)(ref eM)).GetComponentDataRawRW(entity, val.TypeIndex), data);
		}

		public static bool Has<T>(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			return ((EntityManager)(ref eM)).HasComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0));
		}

		public static bool TryRead<T>(this Entity entity, out T value) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (entity.Exists() && entity.Has<T>())
			{
				value = entity.Read<T>();
				return true;
			}
			value = default(T);
			return false;
		}

		public static void Add<T>(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			((EntityManager)(ref eM)).AddComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0));
		}

		public static void Remove<T>(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			((EntityManager)(ref eM)).RemoveComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0));
		}

		public static DynamicBuffer<T> Buffer<T>(this Entity entity) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			return ((EntityManager)(ref eM)).GetBuffer<T>(entity, false);
		}

		public static bool Exists(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (entity != Entity.Null)
			{
				EntityManager eM = EM;
				return ((EntityManager)(ref eM)).Exists(entity);
			}
			return false;
		}

		public static PrefabGUID Guid(this Entity entity)
		{
			//IL_0000: 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_0010: 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)
			if (!entity.Has<PrefabGUID>())
			{
				return new PrefabGUID(0);
			}
			return entity.Read<PrefabGUID>();
		}

		public static EntityQuery Query(EntityQueryOptions options, params Type[] all)
		{
			//IL_0003: 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_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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryBuilder val = default(EntityQueryBuilder);
			((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2));
			foreach (Type type in all)
			{
				((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.From(type), (AccessMode)1));
			}
			((EntityQueryBuilder)(ref val)).WithOptions(options);
			EntityManager eM = EM;
			EntityQuery result = ((EntityManager)(ref eM)).CreateEntityQuery(ref val);
			((EntityQueryBuilder)(ref val)).Dispose();
			return result;
		}

		public static List<Entity> ToList(this EntityQuery q)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			NativeArray<Entity> val = ((EntityQuery)(ref q)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			List<Entity> list = new List<Entity>(val.Length);
			Enumerator<Entity> enumerator = val.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				list.Add(current);
			}
			val.Dispose();
			return list;
		}
	}
	public static class MirrorProtocol
	{
		public const string Give = "mirror.give";

		public const string Weapon = "mirror.weapon";

		public const string Jewel = "mirror.jewel";

		public const string Blood = "mirror.blood";

		public const string FiltersGet = "mirror.filters.get";

		public const string FiltersSet = "mirror.filters.set";

		public const int MaxTier = 3;

		public const int MaxPower = 1000;
	}
	public static class ModInfo
	{
		public const string Version = "1.0.0";
	}
	public static class Protocol
	{
		public sealed class Assembler
		{
			private readonly Dictionary<int, string[]> parts = new Dictionary<int, string[]>();

			public bool Feed(string text, out int id, out bool ok, out string body)
			{
				id = 0;
				ok = false;
				body = null;
				if (!IsOurs(text))
				{
					return false;
				}
				string[] array = text.Substring("§DT1|".Length).Split('|', 5);
				if (array.Length < 5 || array[0] != "r")
				{
					return false;
				}
				if (!int.TryParse(array[1], out id) || !int.TryParse(array[2], out var result) || !int.TryParse(array[3], out var result2))
				{
					return false;
				}
				if (!parts.TryGetValue(id, out var value) || value.Length != result2)
				{
					value = (parts[id] = new string[result2]);
				}
				value[result] = array[4];
				string[] array3 = value;
				for (int i = 0; i < array3.Length; i++)
				{
					if (array3[i] == null)
					{
						return false;
					}
				}
				parts.Remove(id);
				string text2 = string.Concat(value);
				ok = text2.StartsWith("1|", StringComparison.Ordinal);
				body = ((text2.Length >= 2) ? text2.Substring(2) : "");
				return true;
			}
		}

		public const string Prefix = "§DT1|";

		public const int ChunkChars = 380;

		public const int MaxRequestBytes = 500;

		public static bool IsOurs(string text)
		{
			return text?.StartsWith("§DT1|", StringComparison.Ordinal) ?? false;
		}

		public static string Request(int id, string command, string body)
		{
			string text = $"{"§DT1|"}q|{id}|{command}|{body ?? ""}";
			if (Encoding.UTF8.GetByteCount(text) > 500)
			{
				throw new ArgumentException("request too long: " + command);
			}
			return text;
		}

		public static bool TryParseRequest(string text, out int id, out string command, out string body)
		{
			id = 0;
			command = (body = null);
			if (!IsOurs(text))
			{
				return false;
			}
			string[] array = text.Substring("§DT1|".Length).Split('|', 4);
			if (array.Length < 4 || array[0] != "q" || !int.TryParse(array[1], out id))
			{
				return false;
			}
			command = array[2];
			body = array[3];
			return true;
		}

		public static List<string> Reply(int id, bool ok, string body)
		{
			string text = (ok ? "1|" : "0|") + body;
			List<string> list = new List<string>();
			int num = Math.Max(1, (text.Length + 380 - 1) / 380);
			for (int i = 0; i < num; i++)
			{
				int num2 = i * 380;
				string value = text.Substring(num2, Math.Min(380, text.Length - num2));
				list.Add($"{"§DT1|"}r|{id}|{i}|{num}|{value}");
			}
			return list;
		}
	}
	public sealed class Wait
	{
		public readonly float Seconds;

		public Wait(float seconds)
		{
			Seconds = seconds;
		}
	}
	public static class Scheduler
	{
		private sealed class Routine
		{
			public readonly Stack<IEnumerator> Stack = new Stack<IEnumerator>();

			public float WakeAt;

			public string Name;
		}

		private static readonly List<Routine> routines = new List<Routine>();

		private static readonly List<Routine> pending = new List<Routine>();

		public static Action<string> OnError;

		public static void Start(IEnumerator routine, string name = null)
		{
			Routine routine2 = new Routine
			{
				Name = (name ?? "routine")
			};
			routine2.Stack.Push(routine);
			pending.Add(routine2);
		}

		public static void Tick()
		{
			if (pending.Count > 0)
			{
				routines.AddRange(pending);
				pending.Clear();
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			for (int num = routines.Count - 1; num >= 0; num--)
			{
				Routine routine = routines[num];
				if (!(realtimeSinceStartup < routine.WakeAt))
				{
					try
					{
						while (routine.Stack.Count > 0)
						{
							IEnumerator enumerator = routine.Stack.Peek();
							if (!enumerator.MoveNext())
							{
								routine.Stack.Pop();
								continue;
							}
							object current = enumerator.Current;
							if (current is IEnumerator item)
							{
								routine.Stack.Push(item);
								continue;
							}
							if (current is Wait wait)
							{
								routine.WakeAt = realtimeSinceStartup + wait.Seconds;
							}
							break;
						}
					}
					catch (Exception value)
					{
						OnError?.Invoke($"{routine.Name}: {value}");
						routine.Stack.Clear();
					}
					if (routine.Stack.Count == 0)
					{
						routines.RemoveAt(num);
					}
				}
			}
		}
	}
	public class SchedulerDriver : MonoBehaviour
	{
		public SchedulerDriver(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Update()
		{
			Scheduler.Tick();
		}
	}
}
namespace DraculaTrainingRoom.Server
{
	internal static class Arena
	{
		private sealed class Track
		{
			public Layout.Zone Zone;

			public BloodSnapshot? Blood;

			public bool Resetting;
		}

		private static readonly Dictionary<ulong, Track> tracks = new Dictionary<ulong, Track>();

		public static PrefabGUID WoundedBuff;

		private static EntityQuery users;

		public static void Start()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			WoundedBuff = Core.GuidByName("Buff_General_Vampire_Wounded_Buff");
			users = Ecs.Query((EntityQueryOptions)0, typeof(User));
			Scheduler.Start(Loop(), "arena");
		}

		private static IEnumerator Loop()
		{
			bool flag = default(bool);
			while (true)
			{
				yield return new Wait(0.1f);
				foreach (Entity item in users.ToList())
				{
					User val = item.Read<User>();
					if (!val.IsConnected)
					{
						continue;
					}
					Entity entity = val.LocalCharacter._Entity;
					if (!entity.Exists() || !entity.Has<Translation>())
					{
						continue;
					}
					try
					{
						Update(item, val, entity);
					}
					catch (Exception ex)
					{
						ManualLogSource log = Core.Log;
						BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("arena update failed: ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
						}
						log.LogError(val2);
					}
				}
			}
		}

		private static void Update(Entity userEntity, User user, Entity c)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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)
			Track value;
			bool flag = !tracks.TryGetValue(user.PlatformId, out value);
			if (flag)
			{
				value = (tracks[user.PlatformId] = new Track());
			}
			PlayerSetup.EnsureSetUp(userEntity, user, c);
			if (flag)
			{
				PlayerOps.RepairInteractSlots(c);
			}
			if (value.Resetting)
			{
				return;
			}
			if (flag && !Layout.OnBalcony(c.Read<Translation>().Value))
			{
				Reset(userEntity, c, value, "joined away from the balcony");
				return;
			}
			float3 value2 = c.Read<Translation>().Value;
			Layout.Zone zone = Layout.Classify(value2);
			if (zone == Layout.Zone.Balcony && value.Zone == Layout.Zone.Arena && value2.x >= 692f)
			{
				zone = Layout.Zone.Arena;
			}
			if (Buffs.Has(c, WoundedBuff) || c.Read<Health>().IsDead)
			{
				Reset(userEntity, c, value, "defeated");
			}
			else
			{
				if (zone == value.Zone)
				{
					return;
				}
				if (value.Zone == Layout.Zone.Balcony && zone == Layout.Zone.Arena)
				{
					value.Blood = BloodSnapshot.Of(c);
					value.Zone = zone;
					ManualLogSource log = Core.Log;
					bool flag2 = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(34, 2, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("dt-arena: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<FixedString64Bytes>(user.CharacterName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" entered the arena with ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<BloodSnapshot?>(value.Blood);
					}
					log.LogInfo(val);
					ServerChannel.Push(userEntity, "arena", "enter");
				}
				else
				{
					Reset(userEntity, c, value, (zone == Layout.Zone.Elsewhere) ? "left the Shadow Realm" : "left the arena");
				}
			}
		}

		public static void RequestReset(Entity character, string reason)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (character.Exists() && character.Has<PlayerCharacter>())
			{
				Entity userEntity = character.Read<PlayerCharacter>().UserEntity;
				User val = userEntity.Read<User>();
				if (!tracks.TryGetValue(val.PlatformId, out var value))
				{
					value = (tracks[val.PlatformId] = new Track());
				}
				if (!value.Resetting)
				{
					Reset(userEntity, character, value, reason);
				}
			}
		}

		private static void Reset(Entity userEntity, Entity c, Track t, string reason)
		{
			//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)
			t.Resetting = true;
			Scheduler.Start(ResetRoutine(userEntity, c, t, reason), "reset");
		}

		private static IEnumerator ResetRoutine(Entity userEntity, Entity c, Track t, string reason)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			float t2 = Time.realtimeSinceStartup;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2;
			if (c.Read<Health>().IsDead)
			{
				ServerBootstrapSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<ServerBootstrapSystem>();
				EntityCommandBuffer val = ((EntityCommandBufferSystem)Core.Server.GetExistingSystemManaged<EndSimulationEntityCommandBufferSystem>()).CreateCommandBuffer();
				existingSystemManaged.RespawnCharacter(val, userEntity, new Nullable_Unboxed<float3>(Layout.BalconySpawn), c, Entity.Null, -1);
				Entity dead = c;
				while (Time.realtimeSinceStartup - t2 < 5f)
				{
					yield return new Wait(0.1f);
					Entity entity = userEntity.Read<User>().LocalCharacter._Entity;
					if (entity.Exists() && (entity != dead || !entity.Read<Health>().IsDead))
					{
						c = entity;
						break;
					}
				}
				ManualLogSource log = Core.Log;
				val2 = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("dt-arena: respawned dead character (");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(c.Read<Health>().IsDead ? "FAILED" : "ok");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
				}
				log.LogInfo(val2);
			}
			int stable = 0;
			while (stable < 5 && Time.realtimeSinceStartup - t2 < 5f)
			{
				if (!c.Exists())
				{
					t.Resetting = false;
					yield break;
				}
				bool num = Buffs.Remove(c, WoundedBuff);
				RemoveFightBuffs(c);
				PlayerOps.HealFull(c);
				float3 value = c.Read<Translation>().Value;
				if (!num && Layout.OnBalcony(value))
				{
					float2 xz = ((float3)(ref value)).xz;
					float3 balconySpawn = Layout.BalconySpawn;
					if (math.distance(xz, ((float3)(ref balconySpawn)).xz) < 2f)
					{
						stable++;
						goto IL_0211;
					}
				}
				stable = 0;
				PlayerOps.Teleport(c, Layout.BalconySpawn);
				goto IL_0211;
				IL_0211:
				yield return new Wait(0.1f);
			}
			PlayerOps.RepairAll(c);
			if (t.Blood.HasValue)
			{
				PlayerOps.RestoreBlood(userEntity, c, t.Blood.Value);
			}
			t.Blood = null;
			t.Zone = Layout.Zone.Balcony;
			t.Resetting = false;
			Dracula.Reset();
			User val3 = userEntity.Read<User>();
			ManualLogSource log2 = Core.Log;
			val2 = new BepInExInfoLogInterpolatedStringHandler(41, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("dt-arena: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<FixedString64Bytes>(val3.CharacterName);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(reason);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", back on the balcony after ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(Time.realtimeSinceStartup - t2, "F1");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" s");
			}
			log2.LogInfo(val2);
			ServerChannel.Push(userEntity, "arena", "reset|" + reason);
		}

		private static void RemoveFightBuffs(Entity c)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			List<PrefabGUID> list = new List<PrefabGUID>();
			Enumerator<BuffBuffer> enumerator = c.Buffer<BuffBuffer>().GetEnumerator();
			while (enumerator.MoveNext())
			{
				BuffBuffer current = enumerator.Current;
				string text = Core.Name(current.PrefabGuid);
				if (text.Contains("Dracula") || text.StartsWith("Buff_InCombat") || text.Contains("EndGame"))
				{
					list.Add(current.PrefabGuid);
				}
			}
			foreach (PrefabGUID item in list)
			{
				Buffs.Remove(c, item);
			}
		}
	}
	internal static class Buffs
	{
		public static readonly PrefabGUID CoffinSleeping = new PrefabGUID(845443603);

		public static bool TryGet(Entity character, PrefabGUID buff, out Entity buffEntity)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			buffEntity = Entity.Null;
			if (!character.Has<BuffBuffer>())
			{
				return false;
			}
			Enumerator<BuffBuffer> enumerator = character.Buffer<BuffBuffer>().GetEnumerator();
			while (enumerator.MoveNext())
			{
				BuffBuffer current = enumerator.Current;
				PrefabGUID prefabGuid = current.PrefabGuid;
				if (((PrefabGUID)(ref prefabGuid)).GuidHash == ((PrefabGUID)(ref buff)).GuidHash && current.Entity.Exists())
				{
					buffEntity = current.Entity;
					return true;
				}
			}
			return false;
		}

		public static bool Has(Entity character, PrefabGUID buff)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Entity buffEntity;
			return TryGet(character, buff, out buffEntity);
		}

		public static bool Remove(Entity character, PrefabGUID buff)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (!TryGet(character, buff, out var buffEntity))
			{
				return false;
			}
			DestroyUtility.Destroy(Core.EntityManager, buffEntity, (DestroyDebugReason)13, "", 0);
			return true;
		}

		public static void Apply(Entity user, Entity character, PrefabGUID buff)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			FromCharacter val = new FromCharacter
			{
				User = user,
				Character = character
			};
			Core.DebugEvents.ApplyBuff(val, new ApplyBuffDebugEvent
			{
				BuffPrefabGUID = buff
			});
		}
	}
	internal static class Core
	{
		private static readonly Dictionary<int, string> names = new Dictionary<int, string>();

		private static MonoBehaviour host;

		private static Dictionary<string, int> byName;

		public static World Server { get; private set; }

		public static EntityManager EntityManager => Server.EntityManager;

		public static PrefabCollectionSystem PrefabCollection { get; private set; }

		public static ServerScriptMapper ScriptMapper { get; private set; }

		public static ServerGameManager GameManager => ScriptMapper._ServerGameManager;

		public static DebugEventsSystem DebugEvents { get; private set; }

		public static ManualLogSource Log => Plugin.LogInstance;

		public static bool Ready { get; private set; }

		public static string DataDir => Path.Combine(Paths.BepInExRootPath, "DraculaTrainingRoom");

		public static IEnumerable<KeyValuePair<int, string>> AllNames => names;

		public static void Initialize()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_0113: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			if (Ready)
			{
				return;
			}
			Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
			while (enumerator.MoveNext())
			{
				World current = enumerator.Current;
				if (current.Name == "Server")
				{
					Server = current;
				}
			}
			if (Server == null)
			{
				Log.LogError((object)"No Server world");
				return;
			}
			Ecs.World = Server;
			PrefabCollection = Server.GetExistingSystemManaged<PrefabCollectionSystem>();
			ScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
			DebugEvents = Server.GetExistingSystemManaged<DebugEventsSystem>();
			Enumerator<string, PrefabGUID> enumerator2 = PrefabCollection._SpawnableNameToPrefabGuidDictionary.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				KeyValuePair<string, PrefabGUID> current2 = enumerator2.Current;
				Dictionary<int, string> dictionary = names;
				PrefabGUID value = current2.Value;
				dictionary[((PrefabGUID)(ref value)).GuidHash] = current2.Key;
			}
			NativeArray<PrefabGUID> keyArray = PrefabCollection._PrefabGuidToEntityMap.GetKeyArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<PrefabGUID> enumerator3 = keyArray.GetEnumerator();
			ConvertedAssetData val = default(ConvertedAssetData);
			while (enumerator3.MoveNext())
			{
				PrefabGUID current3 = enumerator3.Current;
				if (!names.ContainsKey(((PrefabGUID)(ref current3)).GuidHash) && PrefabCollection._PrefabDataLookup.TryGetValue(current3, ref val))
				{
					names[((PrefabGUID)(ref current3)).GuidHash] = ((FixedString128Bytes)(ref val.AssetName)).Value;
				}
			}
			keyArray.Dispose();
			Directory.CreateDirectory(Path.Combine(DataDir, "probe"));
			Ready = true;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(26, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Core ready: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(names.Count);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" named prefabs");
			}
			log.LogInfo(val2);
		}

		public static string Name(PrefabGUID guid)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (names.TryGetValue(((PrefabGUID)(ref guid)).GuidHash, out var value))
			{
				return value;
			}
			ConvertedAssetData val = default(ConvertedAssetData);
			value = (PrefabCollection._PrefabDataLookup.TryGetValue(guid, ref val) ? ((FixedString128Bytes)(ref val.AssetName)).Value : ((PrefabGUID)(ref guid)).GuidHash.ToString());
			names[((PrefabGUID)(ref guid)).GuidHash] = value;
			return value;
		}

		public static bool TryPrefab(PrefabGUID guid, out Entity prefab)
		{
			//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_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)
			prefab = Entity.Null;
			return PrefabCollection._PrefabGuidToEntityMap.TryGetValue(guid, ref prefab);
		}

		public static PrefabGUID GuidByName(string name)
		{
			//IL_0073: 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)
			if (byName == null)
			{
				byName = new Dictionary<string, int>(StringComparer.Ordinal);
				foreach (KeyValuePair<int, string> name2 in names)
				{
					byName[name2.Value] = name2.Key;
				}
			}
			if (!byName.TryGetValue(name, out var value))
			{
				return new PrefabGUID(0);
			}
			return new PrefabGUID(value);
		}

		public static Coroutine StartCoroutine(IEnumerator routine)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if ((Object)(object)host == (Object)null)
			{
				GameObject val = new GameObject("DraculaTrainingRoom");
				host = (MonoBehaviour)(object)val.AddComponent<IgnorePhysicsDebugSystem>();
				Object.DontDestroyOnLoad((Object)val);
			}
			return host.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
		}
	}
	internal static class Dracula
	{
		private static EntityQuery vbloods;

		private static EntityQuery thrones;

		private static List<Entity> All()
		{
			//IL_0000: 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_000d: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0078: Unknown result type (might be due to invalid IL or missing references)
			if (vbloods == default(EntityQuery))
			{
				vbloods = Ecs.Query((EntityQueryOptions)2, typeof(VBloodUnit), typeof(Translation));
			}
			List<Entity> list = new List<Entity>();
			foreach (Entity item in vbloods.ToList())
			{
				if (Core.Name(item.Guid()).Contains("Dracula"))
				{
					list.Add(item);
				}
			}
			return list;
		}

		private static Entity Throne()
		{
			//IL_0000: 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_000d: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			if (thrones == default(EntityQuery))
			{
				thrones = Ecs.Query((EntityQueryOptions)2, typeof(Script_Dracula_SpawnerData), typeof(Translation));
			}
			foreach (Entity item in thrones.ToList())
			{
				if (Layout.InThroneRoom(item.Read<Translation>().Value))
				{
					return item;
				}
			}
			return Entity.Null;
		}

		public static Entity Find()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0070: 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)
			Entity entity = Throne();
			if (entity.Exists())
			{
				Entity draculaInstance = entity.Read<Script_Dracula_SpawnerData>().DraculaInstance;
				if (draculaInstance.Exists())
				{
					return draculaInstance;
				}
			}
			Entity result = Entity.Null;
			foreach (Entity item in All())
			{
				if (!item.Read<Health>().IsDead)
				{
					return item;
				}
				result = item;
			}
			return result;
		}

		public static void Reset()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//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_0032: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_013f: 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_0145: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Invalid comparison between Unknown and I4
			//IL_0116: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			Entity entity = Throne();
			if (!entity.Exists())
			{
				Core.Log.LogInfo((object)"dt-dracula: the throne room is not loaded yet");
				return;
			}
			Script_Dracula_SpawnerData val = entity.Read<Script_Dracula_SpawnerData>();
			Entity draculaInstance = val.DraculaInstance;
			DraculaState state = val.State;
			bool flag = default(bool);
			foreach (Entity item in All())
			{
				if (!(item == draculaInstance))
				{
					ManualLogSource log = Core.Log;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(57, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("dt-dracula: removing a Dracula the throne does not own (");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(item.Read<Health>().IsDead ? "corpse" : "alive");
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
					}
					log.LogInfo(val2);
					DestroyUtility.Destroy(Core.EntityManager, item, (DestroyDebugReason)0, "", 0);
				}
			}
			bool flag2 = draculaInstance.Exists() && !draculaInstance.Read<Health>().IsDead;
			if (flag2)
			{
				Health val3 = draculaInstance.Read<Health>();
				if (val3.Value < val3.MaxHealth._Value)
				{
					val3.Value = val3.MaxHealth._Value;
					draculaInstance.Write<Health>(val3);
				}
			}
			if (!flag2 || (int)val.State != 2)
			{
				val.State = (DraculaState)1;
				entity.Write<Script_Dracula_SpawnerData>(val);
			}
			Core.Log.LogInfo((object)(flag2 ? $"dt-dracula: ready on his throne (was {state})" : "dt-dracula: the throne will seat a new Dracula"));
		}

		public unsafe static string State()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0069: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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)
			//IL_0103: 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)
			Entity entity = Find();
			if (!entity.Exists())
			{
				return "{\"found\":false}";
			}
			Health val = entity.Read<Health>();
			float3 value = entity.Read<Translation>().Value;
			List<string> list = new List<string>();
			Enumerator<BuffBuffer> enumerator = entity.Buffer<BuffBuffer>().GetEnumerator();
			while (enumerator.MoveNext())
			{
				BuffBuffer current = enumerator.Current;
				list.Add(Core.Name(current.PrefabGuid));
			}
			Entity entity2 = Throne();
			object obj;
			if (!entity2.Exists())
			{
				obj = "none";
			}
			else
			{
				Script_Dracula_SpawnerData val2 = entity2.Read<Script_Dracula_SpawnerData>();
				obj = ((object)(*(DraculaState*)(&val2.State))/*cast due to .constrained prefix*/).ToString();
			}
			string text = (string)obj;
			return FormattableString.Invariant(FormattableStringFactory.Create("{{\"found\":true,\"count\":{0},\"throne\":\"{1}\",\"health\":[{2},{3}],\"dead\":{4},\"pos\":[{5},{6},{7}],\"buffs\":\"{8}\"}}", All().Count, text, val.Value, val.MaxHealth._Value, val.IsDead ? "true" : "false", value.x, value.y, value.z, string.Join(",", list)));
		}
	}
	[HarmonyPatch(typeof(ActivateDraculaWarpRiftSystem), "OnUpdate")]
	internal static class EndGamePortal
	{
		private static EntityQuery query;

		private static PrefabGUID exitBuff;

		private static void Prefix()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_0024: 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_0031: 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_0071: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (!Core.Ready)
			{
				return;
			}
			try
			{
				if (((PrefabGUID)(ref exitBuff)).GuidHash == 0)
				{
					exitBuff = Core.GuidByName("AB_Interact_WarpRift_EndGame_Exit_Buff");
				}
				if (query == default(EntityQuery))
				{
					query = Ecs.Query((EntityQueryOptions)0, typeof(ActivateDraculaWarpRift), typeof(PrefabGUID), typeof(Buff));
				}
				foreach (Entity item in query.ToList())
				{
					if (!(item.Guid() != exitBuff))
					{
						Entity target = item.Read<Buff>().Target;
						item.Remove<ActivateDraculaWarpRift>();
						Core.Log.LogInfo((object)"dt-arena: end-game portal used");
						Arena.RequestReset(target, "took the return portal");
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Core.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(17, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("end-game portal: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}
	}
	internal static class Layout
	{
		public enum Zone
		{
			Balcony,
			Arena,
			Elsewhere
		}

		public static readonly float3 BalconySpawn = new float3(682f, 25f, -2827.5f);

		public static readonly float3 DraculaSpawn = new float3(736f, 15f, -2827.5f);

		public static readonly float3 ArenaCenter = new float3(720f, 15f, -2827.5f);

		public static readonly float3 DevourerPos = new float3(678.5f, 25f, -2831.5f);

		public static readonly float3 MirrorPos = new float3(678.5f, 25f, -2823.5f);

		public const float BalconyMinHeight = 20f;

		public const float BalconyEdgeX = 692f;

		public static bool InThroneRoom(float3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (p.x > 640f && p.x < 770f && p.z > -2870f)
			{
				return p.z < -2785f;
			}
			return false;
		}

		public static bool OnBalcony(float3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (InThroneRoom(p))
			{
				return p.y > 20f;
			}
			return false;
		}

		public static bool InArena(float3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (InThroneRoom(p))
			{
				return p.y <= 20f;
			}
			return false;
		}

		public static bool InDemise(float3 p)
		{
			//IL_0000: 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)
			if (math.abs(p.x - 736f) < 70f)
			{
				return math.abs(p.z + 2987.5f) < 70f;
			}
			return false;
		}

		public static Zone Classify(float3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (!OnBalcony(p))
			{
				if (!InArena(p) && !InDemise(p))
				{
					return Zone.Elsewhere;
				}
				return Zone.Arena;
			}
			return Zone.Balcony;
		}
	}
	internal static class LoadOptimizations
	{
		[HarmonyPatch(typeof(SystemData), "SetInitializeTerrainFlags")]
		private static class TerrainFlagsPatch
		{
			private static void Prefix(World world, ref InitializeTerrainFlags initializeTerrainFlags)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Expected O, but got Unknown
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				InitializeTerrainFlags val = initializeTerrainFlags;
				if (OnlyChunksAroundPlayers)
				{
					initializeTerrainFlags = (InitializeTerrainFlags)((uint)initializeTerrainFlags & 0xFFFFFFFAu);
				}
				ManualLogSource logInstance = Plugin.LogInstance;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(32, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("dt-load: terrain flags of ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>((world != null) ? world.Name : null);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<InitializeTerrainFlags>(val);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" -> ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<InitializeTerrainFlags>(initializeTerrainFlags);
				}
				logInstance.LogInfo(val2);
			}
		}

		public static bool OnlyChunksAroundPlayers = true;

		public static void AnchorShadowRealm()
		{
			//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_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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (OnlyChunksAroundPlayers)
			{
				float3[] array = (float3[])(object)new float3[2]
				{
					Layout.BalconySpawn,
					new float3(736f, 15f, -2987.5f)
				};
				foreach (float3 value in array)
				{
					EntityManager entityManager = Core.EntityManager;
					((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[2]
					{
						ComponentType.ReadWrite(Il2CppType.Of<ChunkLoader>()),
						ComponentType.ReadWrite(Il2CppType.Of<Translation>())
					}).Write<Translation>(new Translation
					{
						Value = value
					});
				}
				Core.Log.LogInfo((object)"dt-load: Shadow Realm anchored (chunk loaders on the balcony and the Demise scene)");
			}
		}
	}
	internal static class MirrorService
	{
		private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;

		private static readonly EquipmentType[] AutoEquipped;

		public static void Register()
		{
			ServerChannel.Register("mirror.give", Give);
			ServerChannel.Register("mirror.weapon", Weapon);
			ServerChannel.Register("mirror.jewel", Jewel);
			ServerChannel.Register("mirror.blood", Blood);
			ServerChannel.Register("mirror.filters.get", (Request r) => (true, JsonSerializer.Serialize(FiltersOf(r.User))));
			ServerChannel.Register("mirror.filters.set", delegate(Request r)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				int num = r.Body.IndexOf('|');
				if (num <= 0)
				{
					return (false, "bad filter");
				}
				FiltersOf(r.User)[r.Body.Substring(0, num)] = r.Body.Substring(num + 1);
				ModState.Current?.Save();
				return (true, "");
			});
		}

		private static Dictionary<string, string> FiltersOf(Entity userEntity)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			ModState current = ModState.Current;
			string key = userEntity.Read<User>().PlatformId.ToString(Inv);
			if (!current.Filters.TryGetValue(key, out var value))
			{
				value = (current.Filters[key] = new Dictionary<string, string>());
			}
			return value;
		}

		private static int[] Ints(string body)
		{
			return (from s in body.Split(' ', StringSplitOptions.RemoveEmptyEntries)
				select int.Parse(s, Inv)).ToArray();
		}

		private static (bool, string) Give(Request r)
		{
			//IL_0016: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			int[] array = Ints(r.Body);
			PrefabGUID val = default(PrefabGUID);
			((PrefabGUID)(ref val))..ctor(array[0]);
			if (!Core.TryPrefab(val, out var prefab) || !prefab.Has<ItemData>())
			{
				return (false, "not an item");
			}
			int num = Math.Max(1, (array.Length <= 1) ? 1 : array[1]);
			ServerGameManager gameManager = Core.GameManager;
			AddItemResponse val2 = ((ServerGameManager)(ref gameManager)).TryAddInventoryItem(r.Character, val, num);
			ManualLogSource log = Core.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(22, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("dt-mirror: gave ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" x ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(Core.Name(val));
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<AddItemResult>(val2.Result);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")");
			}
			log.LogInfo(val3);
			if ((int)val2.Result != 0)
			{
				return (false, "inventory full");
			}
			bool flag2 = EquipIfSlotEmpty(r.Character, prefab, val2.Slot);
			return (true, Core.Name(val) + (flag2 ? " equipped" : ""));
		}

		private static bool EquipIfSlotEmpty(Entity character, Entity prefab, int inventorySlot)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0057: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			if (inventorySlot < 0 || !prefab.Has<EquippableData>())
			{
				return false;
			}
			EquipmentType equipmentType = prefab.Read<EquippableData>().EquipmentType;
			if (Array.IndexOf(AutoEquipped, equipmentType) >= 0)
			{
				Equipment val = character.Read<Equipment>();
				if (!((Equipment)(ref val)).IsEquipped(equipmentType))
				{
					EntityManager entityManager = Core.EntityManager;
					Entity entity = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[4]
					{
						ComponentType.ReadWrite<FromCharacter>(),
						ComponentType.ReadWrite<ReceiveNetworkEventTag>(),
						ComponentType.ReadWrite<NetworkEventType>(),
						ComponentType.ReadWrite<EquipItemEvent>()
					});
					entity.Write<FromCharacter>(new FromCharacter
					{
						User = character.Read<PlayerCharacter>().UserEntity,
						Character = character
					});
					entity.Write<NetworkEventType>(new NetworkEventType
					{
						IsAdminEvent = false,
						IsDebugEvent = false,
						EventId = 0
					});
					entity.Write<EquipItemEvent>(new EquipItemEvent
					{
						SlotIndex = inventorySlot,
						IsCosmetic = false
					});
					ManualLogSource log = Core.Log;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("dt-mirror: equipping inventory slot ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(inventorySlot);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<EquipmentType>(equipmentType);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
					}
					log.LogInfo(val2);
					return true;
				}
			}
			return false;
		}

		private static (bool, string) Weapon(Request r)
		{
			//IL_000e: 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_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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_01c4: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_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_0159: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			int[] array = Ints(r.Body);
			CreateLegendaryWeaponDebugEvent val = new CreateLegendaryWeaponDebugEvent
			{
				WeaponPrefabGuid = new PrefabGUID(array[0]),
				Tier = array[1],
				InfuseSpellMod = new PrefabGUID(array[2]),
				StatMod1 = new PrefabGUID(array[3]),
				StatMod1Power = (float)array[4] / 1000f,
				StatMod2 = new PrefabGUID(array[5]),
				StatMod2Power = (float)array[6] / 1000f,
				StatMod3 = new PrefabGUID(array[7]),
				StatMod3Power = (float)array[8] / 1000f,
				StatMod4 = new PrefabGUID(array[9]),
				StatMod4Power = (float)array[10] / 1000f
			};
			Core.DebugEvents.CreateLegendaryWeaponEvent(r.User.Read<User>().Index, ref val);
			ManualLogSource log = Core.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(41, 7, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("dt-mirror: weapon ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Core.Name(val.WeaponPrefabGuid));
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" tier ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(val.Tier);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" infuse ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Core.Name(val.InfuseSpellMod));
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("mods ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Core.Name(val.StatMod1));
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Core.Name(val.StatMod2));
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Core.Name(val.StatMod3));
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Core.Name(val.StatMod4));
			}
			log.LogInfo(val2);
			return (true, Core.Name(val.WeaponPrefabGuid));
		}

		private static (bool, string) Jewel(Request r)
		{
			//IL_000e: 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_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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			int[] array = Ints(r.Body);
			CreateJewelDebugEventV2 val = new CreateJewelDebugEventV2
			{
				AbilityPrefabGuid = new PrefabGUID(array[0]),
				Tier = array[1],
				SpellMod1 = new PrefabGUID(array[2]),
				SpellMod1Power = (float)array[3] / 1000f,
				SpellMod2 = new PrefabGUID(array[4]),
				SpellMod2Power = (float)array[5] / 1000f,
				SpellMod3 = new PrefabGUID(array[6]),
				SpellMod3Power = (float)array[7] / 1000f,
				SpellMod4 = new PrefabGUID(array[8]),
				SpellMod4Power = (float)array[9] / 1000f,
				Equip = false
			};
			Core.DebugEvents.CreateJewelEvent(r.User.Read<User>().Index, ref val);
			ManualLogSource log = Core.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("dt-mirror: jewel ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Core.Name(val.AbilityPrefabGuid));
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" tier ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(val.Tier);
			}
			log.LogInfo(val2);
			return (true, Core.Name(val.AbilityPrefabGuid));
		}

		private static (bool, string) Blood(Request r)
		{
			//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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			int[] array = Ints(r.Body);
			PrefabGUID val = default(PrefabGUID);
			((PrefabGUID)(ref val))..ctor(array[0]);
			ServerGameManager gameManager = Core.GameManager;
			Entity newEntity = ((ServerGameManager)(ref gameManager)).TryAddInventoryItem(r.Character, val, 1).NewEntity;
			if (!newEntity.Exists() || !newEntity.Has<StoredBlood>())
			{
				return (false, "inventory full");
			}
			StoredBlood val2 = new StoredBlood
			{
				PrimaryBloodType = new PrefabGUID(array[1]),
				BloodQuality = Math.Clamp(array[2], 0, 100)
			};
			if (array.Length > 3 && array[3] != 0)
			{
				PrefabGUID val3 = default(PrefabGUID);
				((PrefabGUID)(ref val3))..ctor(array[3]);
				int num = Math.Clamp(array[4], 0, 100);
				Entity prefab;
				int val4 = Math.Min(Math.Min((Core.TryPrefab(val3, out prefab) && prefab.Has<SecondaryUnitBloodTypeBuffs>()) ? prefab.Buffer<SecondaryUnitBloodTypeBuffs>().Length : 3, 3) - 1, (num >= 60) ? 2 : ((num >= 30) ? 1 : 0));
				val2.SecondaryBlood = new SecondaryBloodData
				{
					Type = val3,
					Quality = num,
					BuffIndex = (byte)Math.Clamp(array[5], 0, Math.Max(0, val4))
				};
			}
			newEntity.Write<StoredBlood>(val2);
			ManualLogSource log = Core.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(29, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("dt-mirror: blood potion ");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(Core.Name(val2.PrimaryBloodType));
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(val2.BloodQuality);
				((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("% / ");
				((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(Core.Name(val2.SecondaryBlood.Type));
			}
			log.LogInfo(val5);
			return (true, Core.Name(val));
		}

		static MirrorService()
		{
			EquipmentType[] array = new EquipmentType[8];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			AutoEquipped = (EquipmentType[])(object)array;
		}
	}
	internal sealed class ModState
	{
		[HarmonyPatch(typeof(ServerBootstrapSystem), "InitializeServer")]
		private static class InitializeServerPatch
		{
			private static void Prefix(ServerRuntimeSettings runtimeSettings)
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				string value = ((FixedString512Bytes)(ref runtimeSettings.SaveDirectoryPath)).Value;
				bool hasValue = runtimeSettings.SaveToLoad.HasValue;
				SaveDirectory = value;
				string path = PathOf(value);
				ManualLogSource log = Core.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(40, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Save directory ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(value);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", loading existing save: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(hasValue);
				}
				log.LogInfo(val);
				if (File.Exists(path))
				{
					Current = Load(value);
					Core.Log.LogInfo((object)"DraculaTrainingRoom save recognised");
					return;
				}
				if (hasValue)
				{
					Core.Log.LogError((object)"dt-guard: this save was not made with DraculaTrainingRoom; refusing to load it. Stopping the server.");
					foreach (ILogListener listener in Logger.Listeners)
					{
						((IDisposable)listener).Dispose();
					}
					Environment.Exit(3);
				}
				Current = new ModState();
				Current.Save();
				Core.Log.LogInfo((object)"dt-guard: new DraculaTrainingRoom world");
			}
		}

		public const string FileName = "DraculaTrainingRoom.json";

		public const int CurrentVersion = 1;

		[JsonIgnore]
		public static ModState Current;

		[JsonIgnore]
		public static string SaveDirectory;

		public int Version { get; set; } = 1;

		public string CreatedUtc { get; set; } = DateTime.UtcNow.ToString("o");

		public bool WorldPrepared { get; set; }

		public HashSet<ulong> PlayersSetUp { get; set; } = new HashSet<ulong>();

		public Dictionary<string, Dictionary<string, string>> Filters { get; set; } = new Dictionary<string, Dictionary<string, string>>();

		private static string PathOf(string dir)
		{
			return Path.Combine(dir, "DraculaTrainingRoom.json");
		}

		public static ModState Load(string dir)
		{
			return JsonSerializer.Deserialize<ModState>(File.ReadAllText(PathOf(dir))) ?? new ModState();
		}

		public void Save()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			if (SaveDirectory == null)
			{
				return;
			}
			try
			{
				Directory.CreateDirectory(SaveDirectory);
				string text = PathOf(SaveDirectory) + ".tmp";
				File.WriteAllText(text, JsonSerializer.Serialize(this, new JsonSerializerOptions
				{
					WriteIndented = true
				}));
				File.Move(text, PathOf(SaveDirectory), overwrite: true);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Core.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(18, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not write ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("DraculaTrainingRoom.json");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogError(val);
			}
		}
	}
	internal struct BloodSnapshot
	{
		public PrefabGUID Type;

		public float Quality;

		public float Value;

		public PrefabGUID SecondaryType;

		public float SecondaryQuality;

		public byte SecondaryBuffIndex;

		public static BloodSnapshot Of(Entity character)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001e: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			Blood val = character.Read<Blood>();
			return new BloodSnapshot
			{
				Type = val.BloodType,
				Quality = val.Quality,
				Value = val.Value,
				SecondaryType = val.SecondaryBlood.Type,
				SecondaryQuality = val.SecondaryBlood.Quality,
				SecondaryBuffIndex = val.SecondaryBlood.BuffIndex
			};
		}

		public override string ToString()
		{
			//IL_000d: 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)
			return $"{Core.Name(Type)} {Quality:F0}% ({Value:F1}) / {Core.Name(SecondaryType)} {SecondaryQuality:F0}% #{SecondaryBuffIndex}";
		}
	}
	internal static class PlayerOps
	{
		public static FromCharacter From(Entity user, Entity character)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new FromCharacter
			{
				User = user,
				Character = character
			};
		}

		public static void Teleport(Entity character, float3 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			character.Write<Translation>(new Translation
			{
				Value = pos
			});
			character.Write<LastTranslation>(new LastTranslation
			{
				Value = pos
			});
		}

		public static void RepairAll(Entity character)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			NativeList<Entity> val = default(NativeList<Entity>);
			val..ctor(AllocatorHandle.op_Implicit((Allocator)2));
			Equipment val2 = character.Read<Equipment>();
			((Equipment)(ref val2)).GetAllEquipmentEntities(val, true);
			Enumerator<Entity> enumerator = val.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Repair(enumerator.Current);
			}
			val.Dispose();
			Entity entity = default(Entity);
			if (InventoryUtilities.TryGetInventoryEntity(Core.GameManager, character, ref entity, 0))
			{
				DynamicBuffer<InventoryBuffer> val3 = entity.Buffer<InventoryBuffer>();
				for (int i = 0; i < val3.Length; i++)
				{
					Repair(val3[i].ItemEntity._Entity);
				}
			}
		}

		private static void Repair(Entity item)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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)
			if (item.Exists() && item.Has<Durability>())
			{
				Durability val = item.Read<Durability>();
				if (!(val.Value >= val.MaxDurability))
				{
					val.Value = val.MaxDurability;
					item.Write<Durability>(val);
				}
			}
		}

		public static void RestoreBlood(Entity user, Entity character, BloodSnapshot s)
		{
			//IL_000c: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			VariousMigratedDebugEventsSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<VariousMigratedDebugEventsSystem>();
			ConsumeBloodAdminEvent val = new ConsumeBloodAdminEvent
			{
				PrimaryType = s.Type,
				PrimaryQuality = s.Quality,
				SecondaryType = s.SecondaryType,
				SecondaryQuality = s.SecondaryQuality,
				SecondaryBuffIndex = s.SecondaryBuffIndex,
				Amount = (int)math.ceil(s.Value)
			};
			existingSystemManaged.HandleConsumeBloodEvent(val, From(user, character));
			Blood data = character.Read<Blood>();
			data.Value = s.Value;
			character.Write<Blood>(data);
		}

		public static void HealFull(Entity character)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_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)
			Health val = character.Read<Health>();
			val.Value = val.MaxHealth._Value;
			val.MaxRecoveryHealth = val.MaxHealth._Value;
			character.Write<Health>(val);
		}

		public static void UnlockEverything(Entity user, Entity character)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_000d: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			FromCharacter val = From(user, character);
			Core.DebugEvents.UnlockAllVBloods(val);
			Core.DebugEvents.UnlockAllResearch(val);
			Core.DebugEvents.CompleteAllAchievements(val);
		}

		public static string InteractSlots(Entity character)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (migh