Decompiled source of Eclipse v1.0.0

Eclipse.dll

Decompiled 5 days 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.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using Eclipse.Services;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.UI;
using Stunlock.Core;
using TMPro;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
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("Eclipse")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Eclipse")]
[assembly: AssemblyTitle("Eclipse")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Eclipse
{
	internal class Core
	{
		private static World Client;

		private static MonoBehaviour monoBehaviour;

		public static bool hasInitialized;

		public static EntityManager EntityManager => Client.EntityManager;

		public static CanvasService CanvasService { get; internal set; }

		public static PrefabCollectionSystem PrefabCollectionSystem { get; internal set; }

		public static ManualLogSource Log => Plugin.LogInstance;

		public static void Initialize(GameDataManager __instance)
		{
			if (!hasInitialized)
			{
				Client = ((ComponentSystemBase)__instance).World;
				PrefabCollectionSystem = Client.GetExistingSystemManaged<PrefabCollectionSystem>();
				hasInitialized = true;
			}
		}

		public static void SetCanvas(UICanvasBase canvas)
		{
			CanvasService = new CanvasService(canvas);
		}

		public static void StartCoroutine(IEnumerator routine)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if ((Object)(object)monoBehaviour == (Object)null)
			{
				GameObject val = new GameObject("Eclipse");
				monoBehaviour = (MonoBehaviour)(object)val.AddComponent<IgnorePhysicsDebugSystem>();
				Object.DontDestroyOnLoad((Object)val);
			}
			monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
		}
	}
	internal static class Extensions
	{
		public delegate void ActionRef<T>(ref T item);

		private static EntityManager EntityManager => Core.EntityManager;

		private static PrefabCollectionSystem PrefabCollectionSystem => Core.PrefabCollectionSystem;

		public static void With<T>(this Entity entity, ActionRef<T> action) where T : struct
		{
			//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_0014: 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)
			T item = entity.ReadRW<T>();
			action(ref item);
			EntityManager entityManager = EntityManager;
			((EntityManager)(ref entityManager)).SetComponentData<T>(entity, item);
		}

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

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

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

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

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

		public static bool TryGetComponent<T>(this Entity entity, out T componentData) where T : struct
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			componentData = default(T);
			if (entity.Has<T>())
			{
				componentData = entity.Read<T>();
				return true;
			}
			return false;
		}

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

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

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

		public static string LookupName(this PrefabGUID prefabGUID)
		{
			//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_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)
			object obj;
			if (!PrefabCollectionSystem.PrefabGuidToNameDictionary.ContainsKey(prefabGUID))
			{
				obj = "Guid Not Found";
			}
			else
			{
				string text = PrefabCollectionSystem.PrefabGuidToNameDictionary[prefabGUID];
				PrefabGUID val = prefabGUID;
				obj = text + " " + ((object)(PrefabGUID)(ref val)).ToString();
			}
			return obj.ToString();
		}

		public static void LogComponentTypes(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = EntityManager;
			Enumerator<ComponentType> enumerator = ((EntityManager)(ref entityManager)).GetComponentTypes(entity, (Allocator)2).GetEnumerator();
			Core.Log.LogInfo((object)"===");
			bool flag = default(bool);
			while (enumerator.MoveNext())
			{
				ComponentType current = enumerator.Current;
				ManualLogSource log = Core.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(0, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ComponentType>(current);
				}
				log.LogInfo(val);
			}
			Core.Log.LogInfo((object)"===");
		}

		public static bool Exists(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = EntityManager;
			return ((EntityManager)(ref entityManager)).Exists(entity);
		}
	}
	[BepInPlugin("io.zfolmt.Eclipse", "Eclipse", "1.0.0")]
	internal class Plugin : BasePlugin
	{
		private Harmony _harmony;

		public static readonly List<string> DirectoryPaths = new List<string> { Path.Combine(Paths.ConfigPath, "Eclipse") };

		public static readonly List<string> FilePaths = new List<string>
		{
			Path.Combine(DirectoryPaths[0], "game_objects.json"),
			Path.Combine(DirectoryPaths[0], "sprites.json")
		};

		private static ConfigEntry<bool> leveling;

		private static ConfigEntry<bool> prestige;

		private static ConfigEntry<bool> legacies;

		private static ConfigEntry<bool> expertise;

		private static ConfigEntry<bool> quests;

		internal static Plugin Instance { get; private set; }

		public static Harmony Harmony => Instance._harmony;

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

		public static bool Leveling => leveling.Value;

		public static bool Prestige => prestige.Value;

		public static bool Legacies => legacies.Value;

		public static bool Expertise => expertise.Value;

		public static bool Quests => quests.Value;

		public override void Load()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			Instance = this;
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			InitConfig();
			ManualLogSource log = Core.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(82, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Eclipse");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] loaded! Note that mod will not continue to initialization on dedicated servers.");
			}
			log.LogInfo(val);
		}

		private static void InitConfig()
		{
			foreach (string directoryPath in DirectoryPaths)
			{
				CreateDirectory(directoryPath);
			}
			leveling = InitConfigEntry("UIOptions", "ExperienceBar", defaultValue: false, "Enable/Disable the experience bar, requires both ClientCompanion/LevelingSystem to be enabled in Bloodcraft.");
			prestige = InitConfigEntry("UIOptions", "ShowPrestige", defaultValue: false, "Enable/Disable showing prestige level in front of experience bar, requires both ClientCompanion/PrestigeSystem to be enabled in Bloodcraft .");
			legacies = InitConfigEntry("UIOptions", "LegacyBar", defaultValue: false, "Enable/Disable the legacy bar, requires both ClientCompanion/LegacySystem to be enabled in Bloodcraft.");
			expertise = InitConfigEntry("UIOptions", "ExpertiseBar", defaultValue: false, "Enable/Disable the expertise bar, requires both ClientCompanion/ExpertiseSystem to be enabled in Bloodcraft.");
			quests = InitConfigEntry("UIOptions", "QuestTracker", defaultValue: false, "Enable/Disable the quest tracker, requires both ClientCompanion/QuestSystem to be enabled in Bloodcraft.");
		}

		private static ConfigEntry<T> InitConfigEntry<T>(string section, string key, T defaultValue, string description)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<T> val = ((BasePlugin)Instance).Config.Bind<T>(section, key, defaultValue, description);
			string text = Path.Combine(Paths.ConfigPath, "io.zfolmt.Eclipse.cfg");
			ConfigEntry<T> val2 = default(ConfigEntry<T>);
			if (File.Exists(text) && new ConfigFile(text, true).TryGetEntry<T>(section, key, ref val2))
			{
				val.Value = val2.Value;
			}
			return val;
		}

		public override bool Unload()
		{
			((BasePlugin)this).Config.Clear();
			_harmony.UnpatchSelf();
			return true;
		}

		private static void CreateDirectory(string path)
		{
			if (!Directory.Exists(path))
			{
				Directory.CreateDirectory(path);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "io.zfolmt.Eclipse";

		public const string PLUGIN_NAME = "Eclipse";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Eclipse.Services
{
	internal class CanvasService
	{
		public enum UIElement
		{
			Experience,
			Legacy,
			Expertise,
			Daily,
			Weekly
		}

		public static class GameObjectUtilities
		{
			public static GameObject FindTargetUIObject(Transform root, string targetName)
			{
				Stack<(Transform, int)> stack = new Stack<(Transform, int)>();
				stack.Push((root, 0));
				HashSet<Transform> hashSet = new HashSet<Transform>();
				Il2CppArrayBase<Transform> componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
				List<Transform> list = new List<Transform>();
				foreach (Transform item in componentsInChildren)
				{
					list.Add(item);
				}
				List<Transform> list2 = list;
				while (stack.Count > 0)
				{
					var (val, num) = stack.Pop();
					if (!hashSet.Add(val))
					{
						continue;
					}
					if (((Object)((Component)val).gameObject).name.Equals(targetName, StringComparison.OrdinalIgnoreCase))
					{
						return ((Component)val).gameObject;
					}
					foreach (Transform item2 in list2)
					{
						if ((Object)(object)item2.parent == (Object)(object)val)
						{
							stack.Push((item2, num + 1));
						}
					}
				}
				return null;
			}

			public static void FindLoadedObjects<T>() where T : Object
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Expected O, but got Unknown
				Il2CppReferenceArray<Object> val = Resources.FindObjectsOfTypeAll(Il2CppType.Of<T>());
				ManualLogSource log = Core.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Found ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(((Il2CppArrayBase<Object>)(object)val).Length);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Il2CppType.Of<T>().FullName);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'s!");
				}
				log.LogInfo(val2);
				foreach (Object item in (Il2CppArrayBase<Object>)(object)val)
				{
					ManualLogSource log2 = Core.Log;
					val2 = new BepInExInfoLogInterpolatedStringHandler(8, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Sprite: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(item.name);
					}
					log2.LogInfo(val2);
				}
			}

			public static void DeactivateChildrenExceptNamed(Transform root, string targetName)
			{
				Stack<(Transform, int)> stack = new Stack<(Transform, int)>();
				stack.Push((root, 0));
				HashSet<Transform> hashSet = new HashSet<Transform>();
				Il2CppArrayBase<Transform> componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>();
				List<Transform> list = new List<Transform>();
				foreach (Transform item in componentsInChildren)
				{
					list.Add(item);
				}
				List<Transform> list2 = list;
				while (stack.Count > 0)
				{
					var (val, num) = stack.Pop();
					if (!hashSet.Add(val))
					{
						continue;
					}
					foreach (Transform item2 in list2)
					{
						if ((Object)(object)item2.parent == (Object)(object)val)
						{
							stack.Push((item2, num + 1));
						}
						if (!((Object)item2).name.Equals(targetName))
						{
							((Component)item2).gameObject.SetActive(false);
						}
					}
				}
			}

			public static void FindGameObjects(Transform root, string filePath = "", bool includeInactive = false)
			{
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
				Stack<(Transform, int)> stack = new Stack<(Transform, int)>();
				stack.Push((root, 0));
				HashSet<Transform> hashSet = new HashSet<Transform>();
				Il2CppArrayBase<Transform> componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(includeInactive);
				List<Transform> list = new List<Transform>();
				foreach (Transform item in componentsInChildren)
				{
					list.Add(item);
				}
				List<Transform> list2 = list;
				if (string.IsNullOrEmpty(filePath))
				{
					while (stack.Count > 0)
					{
						var (val, num) = stack.Pop();
						if (!hashSet.Add(val))
						{
							continue;
						}
						FindGameObjectComponents(((Component)val).gameObject);
						new string('|', num);
						foreach (Transform item2 in list2)
						{
							if ((Object)(object)item2.parent == (Object)(object)val)
							{
								stack.Push((item2, num + 1));
							}
						}
					}
					return;
				}
				if (!File.Exists(filePath))
				{
					File.Create(filePath).Dispose();
				}
				using StreamWriter streamWriter = new StreamWriter(filePath, append: false);
				while (stack.Count > 0)
				{
					var (val2, num2) = stack.Pop();
					if (!hashSet.Add(val2))
					{
						continue;
					}
					List<string> values = FindGameObjectComponents(((Component)val2).gameObject);
					string value = new string('|', num2);
					DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(8, 4);
					defaultInterpolatedStringHandler.AppendFormatted(value);
					defaultInterpolatedStringHandler.AppendFormatted(((Object)((Component)val2).gameObject).name);
					defaultInterpolatedStringHandler.AppendLiteral(" | ");
					defaultInterpolatedStringHandler.AppendFormatted(string.Join(",", values));
					defaultInterpolatedStringHandler.AppendLiteral(" | [");
					Scene scene = ((Component)val2).gameObject.scene;
					defaultInterpolatedStringHandler.AppendFormatted(((Scene)(ref scene)).name);
					defaultInterpolatedStringHandler.AppendLiteral("]");
					streamWriter.WriteLine(defaultInterpolatedStringHandler.ToStringAndClear());
					foreach (Transform item3 in list2)
					{
						if ((Object)(object)item3.parent == (Object)(object)val2)
						{
							stack.Push((item3, num2 + 1));
						}
					}
				}
			}

			public static List<string> FindGameObjectComponents(GameObject parentObject)
			{
				List<string> list = new List<string>();
				int componentCount = parentObject.GetComponentCount();
				for (int i = 0; i < componentCount; i++)
				{
					list.Add($"{((Object)parentObject.GetComponentAtIndex(i)).GetIl2CppType().FullName}({i})");
				}
				return list;
			}

			public static void FindSpritesByName(List<string> SpriteNames)
			{
				foreach (KeyValuePair<string, Sprite> item in ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).Where((Sprite sprite) => SpriteNames.Contains(((Object)sprite).name)).ToDictionary((Sprite sprite) => SpriteNames.First((string pair) => pair == ((Object)sprite).name), (Sprite sprite) => sprite))
				{
					SpriteMap[item.Key] = item.Value;
				}
			}
		}

		private static readonly bool ExperienceBar = Plugin.Leveling;

		private static readonly bool LegacyBar = Plugin.Legacies;

		private static readonly bool ExpertiseBar = Plugin.Expertise;

		private static readonly bool QuestTracker = Plugin.Quests;

		private static readonly Dictionary<int, string> RomanNumerals = new Dictionary<int, string>
		{
			{ 100, "C" },
			{ 90, "XC" },
			{ 50, "L" },
			{ 40, "XL" },
			{ 10, "X" },
			{ 9, "IX" },
			{ 5, "V" },
			{ 4, "IV" },
			{ 1, "I" }
		};

		private static readonly List<string> SpriteNames = new List<string> { "BloodIcon_Cursed", "BloodIcon_Small_Cursed", "BloodIcon_Small_Holy", "BloodIcon_Warrior", "BloodIcon_Small_Warrior", "Poneti_Icon_Hammer_30", "Poneti_Icon_Bag", "Poneti_Icon_Res_93" };

		private static readonly Dictionary<string, Sprite> SpriteMap = new Dictionary<string, Sprite>();

		private static readonly WaitForSeconds Delay = new WaitForSeconds(1f);

		private static UICanvasBase UICanvasBase;

		private static Canvas Canvas;

		private static GameObject ExperienceBarGameObject;

		private static GameObject ExperienceInformationPanel;

		private static LocalizedText ExperienceHeader;

		private static LocalizedText ExperienceText;

		private static LocalizedText ExperienceFirstText;

		private static LocalizedText ExperienceClassText;

		private static LocalizedText ExperienceSecondText;

		private static Image ExperienceFill;

		public static float ExperienceProgress = 0f;

		public static int ExperienceLevel = 0;

		public static int ExperiencePrestige = 0;

		public static int ExperienceMaxLevel = 90;

		public static DataService.PlayerClass ClassType = DataService.PlayerClass.None;

		private static GameObject LegacyBarGameObject;

		private static GameObject LegacyInformationPanel;

		private static LocalizedText FirstLegacyStat;

		private static LocalizedText SecondLegacyStat;

		private static LocalizedText ThirdLegacyStat;

		private static LocalizedText LegacyHeader;

		private static LocalizedText LegacyText;

		private static Image LegacyFill;

		public static string LegacyType;

		public static float LegacyProgress = 0f;

		public static int LegacyLevel = 0;

		public static int LegacyPrestige = 0;

		public static int LegacyMaxLevel = 100;

		public static List<string> LegacyBonusStats = new List<string> { "", "", "" };

		private static GameObject ExpertiseBarGameObject;

		private static GameObject ExpertiseInformationPanel;

		private static LocalizedText FirstExpertiseStat;

		private static LocalizedText SecondExpertiseStat;

		private static LocalizedText ThirdExpertiseStat;

		private static LocalizedText ExpertiseHeader;

		private static LocalizedText ExpertiseText;

		private static Image ExpertiseFill;

		public static string ExpertiseType;

		public static float ExpertiseProgress = 0f;

		public static int ExpertiseLevel = 0;

		public static int ExpertisePrestige = 0;

		public static int ExpertiseMaxLevel = 100;

		public static List<string> ExpertiseBonusStats = new List<string> { "", "", "" };

		private static GameObject DailyQuestObject;

		private static LocalizedText DailyQuestHeader;

		private static LocalizedText DailyQuestSubHeader;

		private static Image DailyQuestIcon;

		public static DataService.TargetType DailyTargetType = DataService.TargetType.Kill;

		public static int DailyProgress = 0;

		public static int DailyGoal = 0;

		public static string DailyTarget = "";

		public static bool DailyVBlood = false;

		private static GameObject WeeklyQuestObject;

		private static LocalizedText WeeklyQuestHeader;

		private static LocalizedText WeeklyQuestSubHeader;

		private static Image WeeklyQuestIcon;

		public static DataService.TargetType WeeklyTargetType = DataService.TargetType.Kill;

		public static int WeeklyProgress = 0;

		public static int WeeklyGoal = 0;

		public static string WeeklyTarget = "";

		public static bool WeeklyVBlood = false;

		private static readonly float ScreenWidth = Screen.width;

		private static readonly float ScreenHeight = Screen.height;

		private static int Layer;

		private static int BarNumber;

		private static float WindowOffset;

		private const float BarHeightSpacing = 0.075f;

		private const float BarWidthSpacing = 0.075f;

		public static readonly List<GameObject> ActiveObjects = new List<GameObject>();

		public static bool Active = false;

		public static bool KillSwitch = false;

		public CanvasService(UICanvasBase canvas)
		{
			UICanvasBase = canvas;
			Canvas = GameObject.Find("HUDCanvas(Clone)/BottomBarCanvas").GetComponent<Canvas>();
			Layer = ((Component)Canvas).gameObject.layer;
			BarNumber = 0;
			WindowOffset = 0f;
			GameObjectUtilities.FindSpritesByName(SpriteNames);
			InitializeBloodButton();
			InitializeUI();
		}

		private static void InitializeUI()
		{
			//IL_0021: 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_0095: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			if (ExperienceBar)
			{
				ConfigureProgressBar(ref ExperienceBarGameObject, ref ExperienceInformationPanel, ref ExperienceFill, ref ExperienceText, ref ExperienceHeader, UIElement.Experience, Color.green, ref ExperienceFirstText, ref ExperienceClassText, ref ExperienceSecondText);
			}
			if (LegacyBar)
			{
				ConfigureProgressBar(ref LegacyBarGameObject, ref LegacyInformationPanel, ref LegacyFill, ref LegacyText, ref LegacyHeader, UIElement.Legacy, Color.red, ref FirstLegacyStat, ref SecondLegacyStat, ref ThirdLegacyStat);
			}
			if (ExpertiseBar)
			{
				ConfigureProgressBar(ref ExpertiseBarGameObject, ref ExpertiseInformationPanel, ref ExpertiseFill, ref ExpertiseText, ref ExpertiseHeader, UIElement.Expertise, Color.grey, ref FirstExpertiseStat, ref SecondExpertiseStat, ref ThirdExpertiseStat);
			}
			if (QuestTracker)
			{
				ConfigureQuestWindow(ref DailyQuestObject, UIElement.Daily, Color.green, ref DailyQuestHeader, ref DailyQuestSubHeader, ref DailyQuestIcon);
				ConfigureQuestWindow(ref WeeklyQuestObject, UIElement.Weekly, Color.magenta, ref WeeklyQuestHeader, ref WeeklyQuestSubHeader, ref WeeklyQuestIcon);
			}
		}

		private static void InitializeBloodButton()
		{
			((UnityEvent)GameObject.Find("HUDCanvas(Clone)/BottomBarCanvas/BottomBar(Clone)/Content/BloodOrbParent/BloodOrb/BlackBackground/Blood").AddComponent<SimpleStunButton>().onClick).AddListener(UnityAction.op_Implicit((Action)ToggleUIObjects));
		}

		public static IEnumerator CanvasUpdateLoop()
		{
			while (!KillSwitch)
			{
				if (!Active)
				{
					yield return Delay;
					continue;
				}
				if (ExperienceBar)
				{
					UpdateBar(ExperienceProgress, ExperienceLevel, ExperienceMaxLevel, ExperiencePrestige, ExperienceText, ExperienceHeader, ExperienceFill, UIElement.Experience);
					UpdateClass(ClassType, ExperienceClassText);
				}
				if (LegacyBar)
				{
					UpdateBar(LegacyProgress, LegacyLevel, LegacyMaxLevel, LegacyPrestige, LegacyText, LegacyHeader, LegacyFill, UIElement.Legacy, LegacyType);
					UpdateStats(LegacyBonusStats, new List<LocalizedText> { FirstLegacyStat, SecondLegacyStat, ThirdLegacyStat }, GetBloodStatInfo);
				}
				if (ExpertiseBar)
				{
					UpdateBar(ExpertiseProgress, ExpertiseLevel, ExpertiseMaxLevel, ExpertisePrestige, ExpertiseText, ExpertiseHeader, ExpertiseFill, UIElement.Expertise, ExpertiseType);
					UpdateStats(ExpertiseBonusStats, new List<LocalizedText> { FirstExpertiseStat, SecondExpertiseStat, ThirdExpertiseStat }, GetWeaponStatInfo);
				}
				if (QuestTracker)
				{
					UpdateQuests(DailyQuestObject, DailyQuestSubHeader, DailyQuestIcon, DailyTargetType, DailyTarget, DailyProgress, DailyGoal, DailyVBlood);
					UpdateQuests(WeeklyQuestObject, WeeklyQuestSubHeader, WeeklyQuestIcon, WeeklyTargetType, WeeklyTarget, WeeklyProgress, WeeklyGoal, WeeklyVBlood);
				}
				yield return Delay;
			}
			Active = false;
		}

		private static void UpdateBar(float progress, int level, int maxLevel, int prestiges, LocalizedText levelText, LocalizedText barHeader, Image fill, UIElement element, string type = "")
		{
			string text = level.ToString();
			if (type == "Frailed")
			{
				text = "N/A";
			}
			if (level == maxLevel)
			{
				fill.fillAmount = 1f;
			}
			else
			{
				fill.fillAmount = progress;
			}
			if (levelText.GetText() != text)
			{
				levelText.ForceSet(text);
			}
			if (prestiges != 0)
			{
				string text2 = "";
				if (element.Equals(UIElement.Experience))
				{
					text2 = $"{element} {IntegerToRoman(prestiges)}";
				}
				else if (element.Equals(UIElement.Legacy))
				{
					text2 = type + " " + IntegerToRoman(prestiges);
				}
				else if (element.Equals(UIElement.Expertise))
				{
					text2 = type + " " + IntegerToRoman(prestiges);
				}
				barHeader.ForceSet(text2);
			}
			else if (!string.IsNullOrEmpty(type) && barHeader.GetText() != type)
			{
				barHeader.ForceSet(type);
			}
		}

		private static void UpdateClass(DataService.PlayerClass classType, LocalizedText classText)
		{
			if (classType != 0)
			{
				if (!((Behaviour)classText).enabled)
				{
					((Behaviour)classText).enabled = true;
				}
				classText.ForceSet(classType.ToString());
			}
			else
			{
				classText.ForceSet("");
				((Behaviour)classText).enabled = false;
			}
		}

		private static void UpdateStats(List<string> bonusStats, List<LocalizedText> statTexts, Func<string, string> getStatInfo)
		{
			for (int i = 0; i < 3; i++)
			{
				if (bonusStats[i] != "None")
				{
					if (!((Behaviour)statTexts[i]).enabled)
					{
						((Behaviour)statTexts[i]).enabled = true;
					}
					string text = getStatInfo(bonusStats[i]);
					statTexts[i].ForceSet(text);
				}
				else if (bonusStats[i] == "None" && ((Behaviour)statTexts[i]).enabled)
				{
					statTexts[i].ForceSet("");
					((Behaviour)statTexts[i]).enabled = false;
				}
			}
		}

		private static void UpdateQuests(GameObject questObject, LocalizedText questSubHeader, Image questIcon, DataService.TargetType targetType, string target, int progress, int goal, bool isVBlood)
		{
			if (progress != goal)
			{
				if (!questObject.gameObject.active)
				{
					questObject.gameObject.active = true;
				}
				questSubHeader.ForceSet($"<color=white>{target}</color>: {progress}/<color=yellow>{goal}</color>");
				Sprite value3;
				Sprite value4;
				if (targetType.Equals(DataService.TargetType.Kill))
				{
					Sprite value2;
					if (isVBlood && ((Object)questIcon.sprite).name != "BloodIcon_Cursed" && SpriteMap.TryGetValue("BloodIcon_Cursed", out var value))
					{
						if (!((Component)questIcon).gameObject.active)
						{
							((Component)questIcon).gameObject.active = true;
						}
						questIcon.sprite = value;
					}
					else if (!isVBlood && ((Object)questIcon.sprite).name != "BloodIcon_Warrior" && SpriteMap.TryGetValue("BloodIcon_Warrior", out value2))
					{
						if (!((Component)questIcon).gameObject.active)
						{
							((Component)questIcon).gameObject.active = true;
						}
						questIcon.sprite = value2;
					}
				}
				else if (targetType.Equals(DataService.TargetType.Craft) && ((Object)questIcon.sprite).name != "Poneti_Icon_Hammer_30" && SpriteMap.TryGetValue("Poneti_Icon_Hammer_30", out value3))
				{
					if (!((Component)questIcon).gameObject.active)
					{
						((Component)questIcon).gameObject.active = true;
					}
					questIcon.sprite = value3;
				}
				else if (targetType.Equals(DataService.TargetType.Gather) && ((Object)questIcon.sprite).name != "Poneti_Icon_Res_93" && SpriteMap.TryGetValue("Poneti_Icon_Res_93", out value4))
				{
					if (!((Component)questIcon).gameObject.active)
					{
						((Component)questIcon).gameObject.active = true;
					}
					questIcon.sprite = value4;
				}
			}
			else
			{
				questObject.gameObject.active = false;
				((Component)questIcon).gameObject.active = false;
			}
		}

		private static string GetWeaponStatInfo(string statType)
		{
			if (Enum.TryParse<DataService.WeaponStatType>(statType, out var result) && DataService.WeaponStatValues.TryGetValue(result, out var value))
			{
				float num = ClassSynergy(result, ClassType, DataService.ClassStatSynergies);
				value *= (1f + DataService.PrestigeStatMultiplier * (float)ExpertisePrestige) * num * ((float)ExpertiseLevel / (float)ExpertiseMaxLevel);
				return FormatWeaponStat(result, value);
			}
			return "";
		}

		private static string GetBloodStatInfo(string statType)
		{
			if (Enum.TryParse<DataService.BloodStatType>(statType, out var result) && DataService.BloodStatValues.TryGetValue(result, out var value))
			{
				float num = ClassSynergy(result, ClassType, DataService.ClassStatSynergies);
				value *= (1f + DataService.PrestigeStatMultiplier * (float)LegacyPrestige) * num * ((float)LegacyLevel / (float)LegacyMaxLevel);
				return $"<color=#00FFFF>{DataService.BloodStatTypeAbbreviations[result]}</color>: <color=#90EE90>{(value * 100f).ToString("F0") + "%"}</color>";
			}
			return "";
		}

		private static void ConfigureQuestWindow(ref GameObject questObject, UIElement questType, Color headerColor, ref LocalizedText header, ref LocalizedText subHeader, ref Image questIcon)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_01d0: 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)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			questObject = Object.Instantiate<GameObject>(((Component)UICanvasBase.BottomBarParentPrefab.FakeTooltip).gameObject);
			RectTransform component = questObject.GetComponent<RectTransform>();
			Object.DontDestroyOnLoad((Object)(object)questObject);
			SceneManager.MoveGameObjectToScene(questObject, SceneManager.GetSceneByName("VRisingWorld"));
			((Transform)component).SetParent(((Component)Canvas).transform, false);
			((Component)component).gameObject.layer = Layer;
			questObject.SetActive(true);
			GameObjectUtilities.DeactivateChildrenExceptNamed(GameObjectUtilities.FindTargetUIObject(questObject.transform, "InformationEntries").transform, "TooltipHeader");
			GameObject obj = GameObjectUtilities.FindTargetUIObject(questObject.transform, "TooltipHeader");
			obj.SetActive(true);
			GameObject val = GameObjectUtilities.FindTargetUIObject(obj.transform, "Icon&Name");
			val.SetActive(true);
			GameObjectUtilities.FindTargetUIObject(val.transform, "LevelFrame").SetActive(false);
			GameObjectUtilities.FindTargetUIObject(questObject.transform, "Tooltip_ReforgeCost").SetActive(false);
			GameObject val2 = GameObjectUtilities.FindTargetUIObject(obj.transform, "TooltipIcon");
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(component2.anchorMin.x, 0.55f);
			component2.anchorMax = new Vector2(component2.anchorMax.x, 0.55f);
			component2.pivot = new Vector2(component2.pivot.x, 0.55f);
			questIcon = val2.GetComponent<Image>();
			if (questType.Equals(UIElement.Daily))
			{
				if (SpriteMap.ContainsKey("BloodIcon_Small_Warrior"))
				{
					questIcon.sprite = SpriteMap["BloodIcon_Small_Warrior"];
				}
			}
			else if (questType.Equals(UIElement.Weekly) && SpriteMap.ContainsKey("BloodIcon_Warrior"))
			{
				questIcon.sprite = SpriteMap["BloodIcon_Warrior"];
			}
			component2.sizeDelta = new Vector2(component2.sizeDelta.x * 0.35f, component2.sizeDelta.y * 0.35f);
			GameObject val3 = GameObjectUtilities.FindTargetUIObject(val.transform, "TooltipSubHeader");
			header = GameObjectUtilities.FindTargetUIObject(val.transform, "TooltipHeader").GetComponent<LocalizedText>();
			TextMeshProUGUI text = header.Text;
			((TMP_Text)text).fontSize = ((TMP_Text)text).fontSize * 2f;
			((Graphic)header.Text).color = headerColor;
			subHeader = val3.GetComponent<LocalizedText>();
			((TMP_Text)subHeader.Text).enableAutoSizing = false;
			((TMP_Text)subHeader.Text).autoSizeTextContainer = false;
			((TMP_Text)subHeader.Text).enableWordWrapping = false;
			ContentSizeFitter component3 = val3.GetComponent<ContentSizeFitter>();
			component3.horizontalFit = (FitMode)0;
			component3.verticalFit = (FitMode)0;
			component.sizeDelta = new Vector2(component.sizeDelta.x * 0.65f, component.sizeDelta.y);
			component.anchorMin = new Vector2(1f, WindowOffset);
			component.anchorMax = new Vector2(1f, WindowOffset);
			component.pivot = new Vector2(1f, WindowOffset);
			component.anchoredPosition = new Vector2(0f, WindowOffset);
			header.ForceSet(questType.ToString() + " Quest");
			subHeader.ForceSet("UnitName: 0/0");
			ActiveObjects.Add(questObject);
			WindowOffset += 0.075f;
		}

		private static void ConfigureProgressBar(ref GameObject barGameObject, ref GameObject informationPanelObject, ref Image fill, ref LocalizedText level, ref LocalizedText header, UIElement element, Color fillColor, ref LocalizedText firstText, ref LocalizedText secondText, ref LocalizedText thirdText)
		{
			//IL_0024: 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_0077: 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_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_00cc: 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_0144: Unknown result type (might be due to invalid IL or missing references)
			barGameObject = Object.Instantiate<GameObject>(((Component)UICanvasBase.TargetInfoParent).gameObject);
			Object.DontDestroyOnLoad((Object)(object)barGameObject);
			SceneManager.MoveGameObjectToScene(barGameObject, SceneManager.GetSceneByName("VRisingWorld"));
			RectTransform component = barGameObject.GetComponent<RectTransform>();
			((Transform)component).SetParent(((Component)Canvas).transform, false);
			((Component)component).gameObject.layer = Layer;
			component.anchorMin = new Vector2(1f, 0.6f);
			component.anchorMax = new Vector2(1f, 0.6f);
			component.pivot = new Vector2(1f, 0.6f);
			float num = ScreenHeight * 0.075f;
			Rect rect = component.rect;
			float num2 = (((Rect)(ref rect)).height + num) * (float)BarNumber;
			float num3 = ScreenWidth * 0.075f;
			component.anchoredPosition = new Vector2(0f - num3, 0f - num2);
			((Transform)component).localScale = new Vector3(0.7f, 0.7f, 1f);
			fill = GameObjectUtilities.FindTargetUIObject(((Component)component).transform, "Fill").GetComponent<Image>();
			level = GameObjectUtilities.FindTargetUIObject(((Component)component).transform, "LevelText").GetComponent<LocalizedText>();
			header = GameObjectUtilities.FindTargetUIObject(((Component)component).transform, "Name").GetComponent<LocalizedText>();
			fill.fillAmount = 0f;
			((Graphic)fill).color = fillColor;
			level.ForceSet("0");
			header.ForceSet(element.ToString());
			TextMeshProUGUI text = header.Text;
			((TMP_Text)text).fontSize = ((TMP_Text)text).fontSize * 1.5f;
			GameObjectUtilities.FindTargetUIObject(((Component)component).transform, "DamageTakenFill").GetComponent<Image>().fillAmount = 0f;
			GameObjectUtilities.FindTargetUIObject(((Component)component).transform, "AbsorbFill").GetComponent<Image>().fillAmount = 0f;
			informationPanelObject = GameObjectUtilities.FindTargetUIObject(((Component)component).transform, "InformationPanel");
			ConfigureInformationPanel(ref informationPanelObject, ref firstText, ref secondText, ref thirdText, element);
			BarNumber++;
			barGameObject.SetActive(true);
			ActiveObjects.Add(barGameObject);
		}

		private static void ConfigureInformationPanel(ref GameObject informationPanelObject, ref LocalizedText firstText, ref LocalizedText secondText, ref LocalizedText thirdText, UIElement element)
		{
			if (element == UIElement.Experience)
			{
				ConfigureExperiencePanel(ref informationPanelObject, ref firstText, ref secondText, ref thirdText);
			}
			else
			{
				ConfigureDefaultPanel(ref informationPanelObject, ref firstText, ref secondText, ref thirdText);
			}
		}

		private static void ConfigureExperiencePanel(ref GameObject panel, ref LocalizedText firstText, ref LocalizedText secondText, ref LocalizedText thirdText)
		{
			secondText = GameObjectUtilities.FindTargetUIObject(panel.transform, "ProffesionInfo").GetComponent<LocalizedText>();
			TextMeshProUGUI text = secondText.Text;
			((TMP_Text)text).fontSize = ((TMP_Text)text).fontSize * 1.2f;
			secondText.ForceSet("");
			((Behaviour)secondText).enabled = false;
			firstText = GameObjectUtilities.FindTargetUIObject(panel.transform, "BloodInfo").GetComponent<LocalizedText>();
			firstText.ForceSet("");
			((Behaviour)firstText).enabled = false;
			thirdText = GameObjectUtilities.FindTargetUIObject(panel.transform, "PlatformUserName").GetComponent<LocalizedText>();
			thirdText.ForceSet("");
			((Behaviour)thirdText).enabled = false;
		}

		private static void ConfigureDefaultPanel(ref GameObject panel, ref LocalizedText firstText, ref LocalizedText secondText, ref LocalizedText thirdText)
		{
			firstText = GameObjectUtilities.FindTargetUIObject(panel.transform, "BloodInfo").GetComponent<LocalizedText>();
			TextMeshProUGUI text = firstText.Text;
			((TMP_Text)text).fontSize = ((TMP_Text)text).fontSize * 1.1f;
			firstText.ForceSet("");
			((Behaviour)firstText).enabled = false;
			secondText = GameObjectUtilities.FindTargetUIObject(panel.transform, "ProffesionInfo").GetComponent<LocalizedText>();
			TextMeshProUGUI text2 = secondText.Text;
			((TMP_Text)text2).fontSize = ((TMP_Text)text2).fontSize * 1.1f;
			secondText.ForceSet("");
			((Behaviour)secondText).enabled = false;
			thirdText = GameObjectUtilities.FindTargetUIObject(panel.transform, "PlatformUserName").GetComponent<LocalizedText>();
			TextMeshProUGUI text3 = thirdText.Text;
			((TMP_Text)text3).fontSize = ((TMP_Text)text3).fontSize * 1.1f;
			thirdText.ForceSet("");
			((Behaviour)thirdText).enabled = false;
		}

		private static float ClassSynergy<T>(T statType, DataService.PlayerClass classType, Dictionary<DataService.PlayerClass, (List<DataService.WeaponStatType> WeaponStatTypes, List<DataService.BloodStatType> BloodStatTypes)> classStatSynergy)
		{
			if (classType.Equals(DataService.PlayerClass.None))
			{
				return 1f;
			}
			if (typeof(T) == typeof(DataService.WeaponStatType) && classStatSynergy[classType].WeaponStatTypes.Contains((DataService.WeaponStatType)(object)statType))
			{
				return DataService.ClassStatMultiplier;
			}
			if (typeof(T) == typeof(DataService.BloodStatType) && classStatSynergy[classType].BloodStatTypes.Contains((DataService.BloodStatType)(object)statType))
			{
				return DataService.ClassStatMultiplier;
			}
			return 1f;
		}

		private static string FormatWeaponStat(DataService.WeaponStatType weaponStat, float statValue)
		{
			string value = DataService.WeaponStatFormats[weaponStat] switch
			{
				"integer" => ((int)statValue).ToString(), 
				"decimal" => statValue.ToString("F2"), 
				"percentage" => (statValue * 100f).ToString("F0") + "%", 
				_ => statValue.ToString(), 
			};
			return $"<color=#00FFFF>{DataService.WeaponStatTypeAbbreviations[weaponStat]}</color>: <color=#90EE90>{value}</color>";
		}

		private static string IntegerToRoman(int num)
		{
			string text = string.Empty;
			foreach (KeyValuePair<int, string> romanNumeral in RomanNumerals)
			{
				while (num >= romanNumeral.Key)
				{
					text += romanNumeral.Value;
					num -= romanNumeral.Key;
				}
			}
			return text;
		}

		private static void ToggleUIObjects()
		{
			Active = !Active;
			foreach (GameObject activeObject in ActiveObjects)
			{
				activeObject.active = Active;
			}
		}
	}
	internal static class DataService
	{
		public enum TargetType
		{
			Kill,
			Craft,
			Gather
		}

		public enum BloodType
		{
			Worker,
			Warrior,
			Scholar,
			Rogue,
			Mutant,
			VBlood,
			Frailed,
			GateBoss,
			Draculin,
			Immortal,
			Creature,
			Brute
		}

		public enum WeaponType
		{
			Sword,
			Axe,
			Mace,
			Spear,
			Crossbow,
			GreatSword,
			Slashers,
			Pistols,
			Reaper,
			Longbow,
			Whip,
			Unarmed,
			FishingPole
		}

		public enum WeaponStatType
		{
			None,
			MaxHealth,
			MovementSpeed,
			PrimaryAttackSpeed,
			PhysicalLifeLeech,
			SpellLifeLeech,
			PrimaryLifeLeech,
			PhysicalPower,
			SpellPower,
			PhysicalCritChance,
			PhysicalCritDamage,
			SpellCritChance,
			SpellCritDamage
		}

		public enum BloodStatType
		{
			None,
			HealingReceived,
			DamageReduction,
			PhysicalResistance,
			SpellResistance,
			ResourceYield,
			CCReduction,
			SpellCooldownRecoveryRate,
			WeaponCooldownRecoveryRate,
			UltimateCooldownRecoveryRate,
			MinionDamage,
			ShieldAbsorb,
			BloodEfficiency
		}

		public enum PlayerClass
		{
			None,
			BloodKnight,
			DemonHunter,
			VampireLord,
			ShadowBlade,
			ArcaneSorcerer,
			DeathMage
		}

		internal class ExperienceData
		{
			public float Progress { get; set; } = float.Parse(percent, CultureInfo.InvariantCulture) / 100f;


			public int Level { get; set; } = int.Parse(level);


			public int Prestige { get; set; } = int.Parse(prestige);


			public PlayerClass Class { get; set; } = (PlayerClass)int.Parse(playerClass);


			public ExperienceData(string percent, string level, string prestige, string playerClass)
			{
			}
		}

		internal class LegacyData : ExperienceData
		{
			public string LegacyType { get; set; } = ((BloodType)int.Parse(legacyType)).ToString();


			public List<string> BonusStats { get; set; } = (from i in Enumerable.Range(0, bonusStats.Length / 2)
				select ((BloodStatType)int.Parse(bonusStats.Substring(i * 2, 2))).ToString()).ToList();


			public LegacyData(string percent, string level, string prestige, string legacyType, string bonusStats)
				: base(percent, level, prestige, legacyType)
			{
			}
		}

		internal class ExpertiseData : ExperienceData
		{
			public string ExpertiseType { get; set; } = ((WeaponType)int.Parse(expertiseType)).ToString();


			public List<string> BonusStats { get; set; } = (from i in Enumerable.Range(0, bonusStats.Length / 2)
				select ((WeaponStatType)int.Parse(bonusStats.Substring(i * 2, 2))).ToString()).ToList();


			public ExpertiseData(string percent, string level, string prestige, string expertiseType, string bonusStats)
				: base(percent, level, prestige, expertiseType)
			{
			}
		}

		internal class QuestData
		{
			public TargetType TargetType { get; set; } = (TargetType)int.Parse(type);


			public int Progress { get; set; } = int.Parse(progress);


			public int Goal { get; set; } = int.Parse(goal);


			public string Target { get; set; }

			public bool IsVBlood { get; set; }

			public QuestData(string type, string progress, string goal, string target, string isVBlood)
			{
				Target = target;
				IsVBlood = bool.Parse(isVBlood);
				base..ctor();
			}
		}

		internal class ConfigData
		{
			public float PrestigeStatMultiplier;

			public float ClassStatMultiplier;

			public int MaxPlayerLevel;

			public int MaxLegacyLevel;

			public int MaxExpertiseLevel;

			public Dictionary<WeaponStatType, float> WeaponStatValues;

			public Dictionary<BloodStatType, float> BloodStatValues;

			public Dictionary<PlayerClass, (List<WeaponStatType> WeaponStats, List<BloodStatType> bloodStats)> ClassStatSynergies;

			public ConfigData(string prestigeMultiplier, string statSynergyMultiplier, string maxPlayerLevel, string maxLegacyLevel, string maxExpertiseLevel, string weaponStatValues, string bloodStatValues, string classStatSynergies)
			{
				PrestigeStatMultiplier = float.Parse(prestigeMultiplier, CultureInfo.InvariantCulture);
				ClassStatMultiplier = float.Parse(statSynergyMultiplier, CultureInfo.InvariantCulture);
				MaxPlayerLevel = int.Parse(maxPlayerLevel);
				MaxLegacyLevel = int.Parse(maxLegacyLevel);
				MaxExpertiseLevel = int.Parse(maxExpertiseLevel);
				WeaponStatValues = weaponStatValues.Split(',').Select((string value, int index) => new
				{
					Index = index + 1,
					Value = float.Parse(value, CultureInfo.InvariantCulture)
				}).ToDictionary(x => (WeaponStatType)x.Index, x => x.Value);
				BloodStatValues = bloodStatValues.Split(',').Select((string value, int index) => new
				{
					Index = index + 1,
					Value = float.Parse(value, CultureInfo.InvariantCulture)
				}).ToDictionary(x => (BloodStatType)x.Index, x => x.Value);
				ClassStatSynergies = (from x in classStatSynergies.Split(',').Select((string value, int index) => new
					{
						Value = value,
						Index = index
					})
					group x by x.Index / 3).ToDictionary(g => (PlayerClass)int.Parse(g.ElementAt(0).Value), g => ((from j in Enumerable.Range(0, g.ElementAt(1).Value.Length / 2)
					select (WeaponStatType)int.Parse(g.ElementAt(1).Value.Substring(j * 2, 2))).ToList(), (from j in Enumerable.Range(0, g.ElementAt(2).Value.Length / 2)
					select (BloodStatType)int.Parse(g.ElementAt(2).Value.Substring(j * 2, 2))).ToList()));
			}
		}

		public static Dictionary<WeaponStatType, float> WeaponStatValues = new Dictionary<WeaponStatType, float>();

		public static readonly Dictionary<WeaponStatType, string> WeaponStatTypeAbbreviations = new Dictionary<WeaponStatType, string>
		{
			{
				WeaponStatType.MaxHealth,
				"HP"
			},
			{
				WeaponStatType.MovementSpeed,
				"MS"
			},
			{
				WeaponStatType.PrimaryAttackSpeed,
				"PAS"
			},
			{
				WeaponStatType.PhysicalLifeLeech,
				"PLL"
			},
			{
				WeaponStatType.SpellLifeLeech,
				"SLL"
			},
			{
				WeaponStatType.PrimaryLifeLeech,
				"PLL"
			},
			{
				WeaponStatType.PhysicalPower,
				"PP"
			},
			{
				WeaponStatType.SpellPower,
				"SP"
			},
			{
				WeaponStatType.PhysicalCritChance,
				"PCC"
			},
			{
				WeaponStatType.PhysicalCritDamage,
				"PCD"
			},
			{
				WeaponStatType.SpellCritChance,
				"SCC"
			},
			{
				WeaponStatType.SpellCritDamage,
				"SCD"
			}
		};

		public static readonly Dictionary<string, string> WeaponStatStringAbbreviations = new Dictionary<string, string>
		{
			{ "MaxHealth", "HP" },
			{ "MovementSpeed", "MS" },
			{ "PrimaryAttackSpeed", "PAS" },
			{ "PhysicalLifeLeech", "PLL" },
			{ "SpellLifeLeech", "SLL" },
			{ "PrimaryLifeLeech", "PLL" },
			{ "PhysicalPower", "PP" },
			{ "SpellPower", "SP" },
			{ "PhysicalCritChance", "PCC" },
			{ "PhysicalCritDamage", "PCD" },
			{ "SpellCritChance", "SCC" },
			{ "SpellCritDamage", "SCD" }
		};

		public static readonly Dictionary<WeaponStatType, string> WeaponStatFormats = new Dictionary<WeaponStatType, string>
		{
			{
				WeaponStatType.MaxHealth,
				"integer"
			},
			{
				WeaponStatType.MovementSpeed,
				"decimal"
			},
			{
				WeaponStatType.PrimaryAttackSpeed,
				"percentage"
			},
			{
				WeaponStatType.PhysicalLifeLeech,
				"percentage"
			},
			{
				WeaponStatType.SpellLifeLeech,
				"percentage"
			},
			{
				WeaponStatType.PrimaryLifeLeech,
				"percentage"
			},
			{
				WeaponStatType.PhysicalPower,
				"integer"
			},
			{
				WeaponStatType.SpellPower,
				"integer"
			},
			{
				WeaponStatType.PhysicalCritChance,
				"percentage"
			},
			{
				WeaponStatType.PhysicalCritDamage,
				"percentage"
			},
			{
				WeaponStatType.SpellCritChance,
				"percentage"
			},
			{
				WeaponStatType.SpellCritDamage,
				"percentage"
			}
		};

		public static Dictionary<BloodStatType, float> BloodStatValues = new Dictionary<BloodStatType, float>();

		public static readonly Dictionary<BloodStatType, string> BloodStatTypeAbbreviations = new Dictionary<BloodStatType, string>
		{
			{
				BloodStatType.HealingReceived,
				"HR"
			},
			{
				BloodStatType.DamageReduction,
				"DR"
			},
			{
				BloodStatType.PhysicalResistance,
				"PR"
			},
			{
				BloodStatType.SpellResistance,
				"SR"
			},
			{
				BloodStatType.ResourceYield,
				"RY"
			},
			{
				BloodStatType.CCReduction,
				"CCR"
			},
			{
				BloodStatType.SpellCooldownRecoveryRate,
				"SCR"
			},
			{
				BloodStatType.WeaponCooldownRecoveryRate,
				"WCR"
			},
			{
				BloodStatType.UltimateCooldownRecoveryRate,
				"UCR"
			},
			{
				BloodStatType.MinionDamage,
				"MD"
			},
			{
				BloodStatType.ShieldAbsorb,
				"SA"
			},
			{
				BloodStatType.BloodEfficiency,
				"BE"
			}
		};

		public static readonly Dictionary<string, string> BloodStatStringAbbreviations = new Dictionary<string, string>
		{
			{ "HealingReceived", "HR" },
			{ "DamageReduction", "DR" },
			{ "PhysicalResistance", "PR" },
			{ "SpellResistance", "SR" },
			{ "ResourceYield", "RY" },
			{ "CCReduction", "CCR" },
			{ "SpellCooldownRecoveryRate", "SCR" },
			{ "WeaponCooldownRecoveryRate", "WCR" },
			{ "UltimateCooldownRecoveryRate", "UCR" },
			{ "MinionDamage", "MD" },
			{ "ShieldAbsorb", "SA" },
			{ "BloodEfficiency", "BE" }
		};

		public static Dictionary<PlayerClass, (List<WeaponStatType> WeaponStats, List<BloodStatType> BloodStats)> ClassStatSynergies = new Dictionary<PlayerClass, (List<WeaponStatType>, List<BloodStatType>)>();

		public static float PrestigeStatMultiplier;

		public static float ClassStatMultiplier;

		public static List<string> ParseMessageString(string configString)
		{
			if (string.IsNullOrEmpty(configString))
			{
				return new List<string>();
			}
			List<string> list = new List<string>();
			string[] array = configString.Split(',');
			foreach (string item in array)
			{
				list.Add(item);
			}
			return list;
		}

		public static void ParseConfigData(List<string> configData)
		{
			int num = 0;
			ConfigData configData2 = new ConfigData(configData[num++], configData[num++], configData[num++], configData[num++], configData[num++], string.Join(",", configData.Skip(num).Take(12)), string.Join(",", configData.Skip(num += 12).Take(12)), string.Join(",", configData.Skip(num += 12)));
			PrestigeStatMultiplier = configData2.PrestigeStatMultiplier;
			ClassStatMultiplier = configData2.ClassStatMultiplier;
			CanvasService.ExperienceMaxLevel = configData2.MaxPlayerLevel;
			CanvasService.LegacyMaxLevel = configData2.MaxLegacyLevel;
			CanvasService.ExpertiseMaxLevel = configData2.MaxExpertiseLevel;
			WeaponStatValues = configData2.WeaponStatValues;
			BloodStatValues = configData2.BloodStatValues;
			ClassStatSynergies = configData2.ClassStatSynergies;
		}

		public static void ParsePlayerData(List<string> playerData)
		{
			int index = 0;
			ExperienceData experienceData = new ExperienceData(playerData[index++], playerData[index++], playerData[index++], playerData[index++]);
			LegacyData legacyData = new LegacyData(playerData[index++], playerData[index++], playerData[index++], playerData[index++], playerData[index++]);
			ExpertiseData expertiseData = new ExpertiseData(playerData[index++], playerData[index++], playerData[index++], playerData[index++], playerData[index++]);
			QuestData questData = new QuestData(playerData[index++], playerData[index++], playerData[index++], playerData[index++], playerData[index++]);
			QuestData questData2 = new QuestData(playerData[index++], playerData[index++], playerData[index++], playerData[index++], playerData[index]);
			CanvasService.ExperienceProgress = experienceData.Progress;
			CanvasService.ExperienceLevel = experienceData.Level;
			CanvasService.ExperiencePrestige = experienceData.Prestige;
			CanvasService.ClassType = experienceData.Class;
			CanvasService.LegacyProgress = legacyData.Progress;
			CanvasService.LegacyLevel = legacyData.Level;
			CanvasService.LegacyPrestige = legacyData.Prestige;
			CanvasService.LegacyType = legacyData.LegacyType;
			CanvasService.LegacyBonusStats = legacyData.BonusStats;
			CanvasService.ExpertiseProgress = expertiseData.Progress;
			CanvasService.ExpertiseLevel = expertiseData.Level;
			CanvasService.ExpertisePrestige = expertiseData.Prestige;
			CanvasService.ExpertiseType = expertiseData.ExpertiseType;
			CanvasService.ExpertiseBonusStats = expertiseData.BonusStats;
			CanvasService.DailyTargetType = questData.TargetType;
			CanvasService.DailyProgress = questData.Progress;
			CanvasService.DailyGoal = questData.Goal;
			CanvasService.DailyTarget = questData.Target;
			CanvasService.DailyVBlood = questData.IsVBlood;
			CanvasService.WeeklyTargetType = questData2.TargetType;
			CanvasService.WeeklyProgress = questData2.Progress;
			CanvasService.WeeklyGoal = questData2.Goal;
			CanvasService.WeeklyTarget = questData2.Target;
			CanvasService.WeeklyVBlood = questData2.IsVBlood;
		}
	}
}
namespace Eclipse.Patches
{
	[HarmonyPatch]
	internal static class ClientChatSystemPatch
	{
		public enum NetworkEventSubType
		{
			RegisterUser,
			ProgressToClient,
			ConfigsToClient
		}

		private static readonly bool ShouldInitialize = Plugin.Leveling || Plugin.Expertise || Plugin.Legacies || Plugin.Quests;

		public static bool UserRegistered = false;

		private static readonly Regex regexExtract = new Regex("^\\[(\\d+)\\]:");

		private static readonly Regex regexMAC = new Regex(";mac([^;]+)$");

		private static readonly byte[] sharedKey = Convert.FromBase64String("c2VjdXJlLXN1cGVyLXNlY3JldC1rZXktaGVyZQ==");

		private static readonly ComponentType[] NetworkEventComponents = (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>())
		};

		private static readonly NetworkEventType networkEventType = new NetworkEventType
		{
			IsAdminEvent = false,
			EventId = NetworkEvents.EventId_ChatMessageEvent,
			IsDebugEvent = false
		};

		public static Entity localCharacter = Entity.Null;

		public static Entity localUser = Entity.Null;

		private static EntityManager EntityManager => Core.EntityManager;

		[HarmonyPatch(typeof(ClientChatSystem), "OnUpdate")]
		[HarmonyPrefix]
		private static void OnUpdatePrefix(ClientChatSystem __instance)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_00bd: 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_00c7: 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_00d1: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00df: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			if (!Core.hasInitialized || !ShouldInitialize)
			{
				return;
			}
			if (!UserRegistered && localCharacter != Entity.Null && localUser != Entity.Null)
			{
				UserRegistered = true;
				try
				{
					string message = localUser.Read<User>().PlatformId.ToString();
					SendMessage(NetworkEventSubType.RegisterUser, message);
				}
				catch (Exception ex)
				{
					ManualLogSource log = Core.Log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Eclipse");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] failed to register user... ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					log.LogError(val);
				}
			}
			EntityQuery receiveChatMessagesQuery = __instance._ReceiveChatMessagesQuery;
			NativeArray<Entity> val2 = ((EntityQuery)(ref receiveChatMessagesQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (current.Has<ChatMessageServerEvent>())
					{
						ChatMessageServerEvent val3 = current.Read<ChatMessageServerEvent>();
						if (VerifyMAC(((FixedString512Bytes)(ref val3.MessageText)).Value, out var originalMessage))
						{
							HandleServerMessage(originalMessage);
							EntityManager entityManager = EntityManager;
							((EntityManager)(ref entityManager)).DestroyEntity(current);
						}
					}
				}
			}
			finally
			{
				val2.Dispose();
			}
		}

		private static void SendMessage(NetworkEventSubType subType, string message)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0092: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			string text = $"[{subType}]:{message}";
			string text2 = text + ";mac" + GenerateMAC(text);
			ChatMessageEvent val = default(ChatMessageEvent);
			val.MessageText = new FixedString512Bytes(text2);
			val.MessageType = (ChatMessageType)4;
			val.ReceiverEntity = localUser.Read<NetworkId>();
			ChatMessageEvent componentData = val;
			EntityManager entityManager = EntityManager;
			Entity entity = ((EntityManager)(ref entityManager)).CreateEntity(NetworkEventComponents);
			entity.Write<FromCharacter>(new FromCharacter
			{
				Character = localCharacter,
				User = localUser
			});
			entity.Write<NetworkEventType>(networkEventType);
			entity.Write<ChatMessageEvent>(componentData);
		}

		private static void HandleServerMessage(string message)
		{
			switch (int.Parse(regexExtract.Match(message).Groups[1].Value))
			{
			case 1:
				DataService.ParsePlayerData(DataService.ParseMessageString(regexExtract.Replace(message, "")));
				if (!CanvasService.Active)
				{
					if (CanvasService.KillSwitch)
					{
						CanvasService.KillSwitch = false;
					}
					CanvasService.Active = true;
					Core.StartCoroutine(CanvasService.CanvasUpdateLoop());
				}
				break;
			case 2:
				DataService.ParseConfigData(DataService.ParseMessageString(regexExtract.Replace(message, "")));
				break;
			}
		}

		public static bool VerifyMAC(string receivedMessage, out string originalMessage)
		{
			Match match = regexMAC.Match(receivedMessage);
			originalMessage = "";
			if (match.Success)
			{
				string value = match.Groups[1].Value;
				string text = regexMAC.Replace(receivedMessage, "");
				string s = GenerateMAC(text);
				if (CryptographicOperations.FixedTimeEquals(Encoding.UTF8.GetBytes(s), Encoding.UTF8.GetBytes(value)))
				{
					originalMessage = text;
					return true;
				}
			}
			return false;
		}

		public static string GenerateMAC(string message)
		{
			using HMACSHA256 hMACSHA = new HMACSHA256(sharedKey);
			byte[] bytes = Encoding.UTF8.GetBytes(message);
			return Convert.ToBase64String(hMACSHA.ComputeHash(bytes));
		}
	}
	[HarmonyPatch]
	internal static class InitializationPatches
	{
		private static readonly bool ShouldInitialize = Plugin.Leveling || Plugin.Expertise || Plugin.Legacies || Plugin.Quests;

		private static bool SetCanvas = false;

		private static EntityManager EntityManager => Core.EntityManager;

		[HarmonyPatch(typeof(GameDataManager), "OnUpdate")]
		[HarmonyPostfix]
		private static void OnUpdatePostfix(GameDataManager __instance)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				if (!ShouldInitialize || !__instance.GameDataInitialized || Core.hasInitialized)
				{
					return;
				}
				Core.Initialize(__instance);
				if (Core.hasInitialized)
				{
					ManualLogSource log = Core.Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("|");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Eclipse");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] initialized on client|");
					}
					log.LogInfo(val);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Core.Log;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(59, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Eclipse");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.0.0");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] failed to initialize on client, exiting on try-catch... ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				log2.LogError(val2);
			}
		}

		[HarmonyPatch(typeof(UICanvasSystem), "UpdateHideIfDisabled")]
		[HarmonyPostfix]
		private static void OnUpdatePostfix(UICanvasBase canvas)
		{
			if (!SetCanvas && Core.hasInitialized)
			{
				SetCanvas = true;
				Core.SetCanvas(canvas);
			}
		}

		[HarmonyPatch(typeof(CommonClientDataSystem), "OnUpdate")]
		[HarmonyPostfix]
		private static void OnUpdatePostfix(CommonClientDataSystem __instance)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			if (!Core.hasInitialized)
			{
				return;
			}
			EntityQuery val = __instance.__query_1840110765_0;
			NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				if (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (current.Has<LocalUser>())
					{
						ClientChatSystemPatch.localUser = current;
					}
				}
			}
			finally
			{
				val2.Dispose();
			}
			val = __instance.__query_1840110765_1;
			val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				if (enumerator.MoveNext())
				{
					Entity current2 = enumerator.Current;
					if (current2.Has<LocalCharacter>())
					{
						ClientChatSystemPatch.localCharacter = current2;
					}
				}
			}
			finally
			{
				val2.Dispose();
			}
		}

		[HarmonyPatch(typeof(ClientBootstrapSystem), "OnDestroy")]
		[HarmonyPrefix]
		private static void OnUpdatePrefix(ClientBootstrapSystem __instance)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			CanvasService.KillSwitch = true;
			CanvasService.Active = false;
			ClientChatSystemPatch.UserRegistered = false;
			ClientChatSystemPatch.localCharacter = Entity.Null;
			ClientChatSystemPatch.localUser = Entity.Null;
			SetCanvas = false;
			Core.hasInitialized = false;
			foreach (GameObject activeObject in CanvasService.ActiveObjects)
			{
				if ((Object)(object)activeObject != (Object)null)
				{
					Object.Destroy((Object)(object)activeObject);
				}
			}
			CanvasService.ActiveObjects.Clear();
		}
	}
}