Decompiled source of AugaLite v1.0.1

plugins\AugaLite.dll

Decompiled 4 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.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using AugaLite.Utilities;
using AugaUnity;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using fastJSON;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Auga")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Auga")]
[assembly: AssemblyCopyright("Copyright © Randy Knapp 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bcc7dd31-d943-4684-800e-176a97dddb8f")]
[assembly: AssemblyFileVersion("1.3.11.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.11.0")]
[module: UnverifiableCode]
namespace AugaLite
{
	[HarmonyPatch(typeof(FejdStartup))]
	public static class FejdStartup_Patch
	{
		[HarmonyPostfix]
		[HarmonyPatch("SetupGui")]
		private static void SetupGui(FejdStartup __instance)
		{
			__instance.m_moddedText.SetActive(false);
		}
	}
	public class AugaAssets
	{
		public GameObject Hud;

		public Texture2D Cursor;

		public GameObject MessageHud;

		public GameObject DamageText;
	}
	public class AugaColors
	{
		public string BrightestGold = "#FFBF1B";

		public string Topic = "#EAA800";

		public string Emphasis = "#1AACEF";

		public Color Healing = new Color(0.5f, 1f, 0.5f, 0.7f);

		public Color PlayerDamage = new Color(1f, 0f, 0f, 1f);

		public Color PlayerNoDamage = new Color(0.5f, 0.5f, 0.5f, 1f);

		public Color NormalDamage = new Color(1f, 1f, 1f, 1f);

		public Color ResistDamage = new Color(0.6f, 0.6f, 0.6f, 1f);

		public Color WeakDamage = new Color(1f, 1f, 0f, 1f);

		public Color ImmuneDamage = new Color(0.6f, 0.6f, 0.6f, 1f);

		public Color TooHard = new Color(0.8f, 0.7f, 0.7f, 1f);
	}
	[BepInPlugin("ZenDragon.AugaLite", "AugaLite", "1.0.1")]
	public class AugaLite : BaseUnityPlugin
	{
		public enum StatBarTextDisplayMode
		{
			JustValue,
			ValueAndMax,
			ValueMaxPercent,
			JustPercent
		}

		public enum StatBarTextPosition
		{
			Off = -1,
			Above,
			Below,
			Center,
			Start,
			End
		}

		public const string PluginID = "ZenDragon.AugaLite";

		public const string PluginName = "AugaLite";

		public const string Version = "1.0.1";

		private static ConfigEntry<bool> _loggingEnabled;

		private static ConfigEntry<LogLevel> _logLevel;

		public static ConfigEntry<bool> HealthBarShow;

		public static ConfigEntry<int> HealthBarFixedSize;

		public static ConfigEntry<StatBarTextDisplayMode> HealthBarTextDisplay;

		public static ConfigEntry<StatBarTextPosition> HealthBarTextPosition;

		public static ConfigEntry<bool> HealthBarShowTicks;

		public static ConfigEntry<bool> StaminaBarShow;

		public static ConfigEntry<int> StaminaBarFixedSize;

		public static ConfigEntry<StatBarTextDisplayMode> StaminaBarTextDisplay;

		public static ConfigEntry<StatBarTextPosition> StaminaBarTextPosition;

		public static ConfigEntry<bool> StaminaBarShowTicks;

		public static ConfigEntry<bool> EitrBarShow;

		public static ConfigEntry<int> EitrBarFixedSize;

		public static ConfigEntry<StatBarTextDisplayMode> EitrBarTextDisplay;

		public static ConfigEntry<StatBarTextPosition> EitrBarTextPosition;

		public static ConfigEntry<bool> EitrBarShowTicks;

		public static readonly AugaAssets Assets = new AugaAssets();

		public static readonly AugaColors Colors = new AugaColors();

		private static AugaLite _instance;

		private Harmony _harmony;

		public static AugaLite instance => _instance;

		public void Awake()
		{
			//IL_0086: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			_instance = this;
			if (int.TryParse(Assembly.GetExecutingAssembly().GetName().Version.ToString().Split(new char[1] { '.' })[3], out var result) && result > 0)
			{
				Debug.LogWarning((object)"==============================================================================");
				Debug.LogWarning((object)"You are using a PTB version of this mod. It will not work in prior versions.");
				Debug.LogWarning((object)$"Project Auga - Version {Assembly.GetExecutingAssembly().GetName().Version}");
				Debug.LogWarning((object)("Valheim - Version " + Version.GetVersionString(false)));
				if ((Version.CurrentVersion.m_minor != 217 || Version.CurrentVersion.m_patch < 27) && Version.CurrentVersion.m_minor <= 217)
				{
					Debug.LogError((object)">>>>>>>>> GAME VERSION MISMATCH - EXITING <<<<<<<<");
					Debug.LogWarning((object)"==============================================================================");
					Thread.Sleep(10000);
					Object.Destroy((Object)(object)this);
					return;
				}
				Debug.LogWarning((object)"GAME VERSION CHECK - PASSED");
				Debug.LogWarning((object)"==============================================================================");
			}
			LoadDependencies();
			LoadTranslations();
			LoadConfig();
			LoadAssets();
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "ZenDragon.AugaLite");
		}

		public void OnDestroy()
		{
			_instance = null;
		}

		private void LoadDependencies()
		{
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			LoadEmbeddedAssembly(callingAssembly, "fastJSON.dll");
			LoadEmbeddedAssembly(callingAssembly, "Unity.AugaLite.dll");
		}

		private static void LoadEmbeddedAssembly(Assembly assembly, string assemblyName)
		{
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(assembly.GetName().Name + "." + assemblyName);
			if (manifestResourceStream == null)
			{
				LogError("Could not load embedded assembly (" + assemblyName + ")!");
				return;
			}
			using (manifestResourceStream)
			{
				byte[] array = new byte[manifestResourceStream.Length];
				manifestResourceStream.Read(array, 0, array.Length);
				Assembly.Load(array);
			}
		}

		private static void LoadTranslations()
		{
			string text = LoadJsonText("translations.json");
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			foreach (KeyValuePair<string, object> item in (IDictionary<string, object>)JSON.Parse(text))
			{
				if (!string.IsNullOrEmpty(item.Key) && !string.IsNullOrEmpty(item.Value.ToString()))
				{
					Localization.instance.AddWord(item.Key, item.Value.ToString());
				}
			}
		}

		private void LoadConfig()
		{
			_loggingEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Logging", "LoggingEnabled", false, "Enable logging");
			_logLevel = ((BaseUnityPlugin)this).Config.Bind<LogLevel>("Logging", "LogLevel", (LogLevel)16, "Only log messages of the selected level or higher");
			HealthBarShow = ((BaseUnityPlugin)this).Config.Bind<bool>("StatBars", "HealthBarShow", true, "If false, hides the health bar completely.");
			HealthBarFixedSize = ((BaseUnityPlugin)this).Config.Bind<int>("StatBars", "HealthBarFixedSize", 0, "If greater than 0, forces the health bar to be that many pixels long, regardless of the player's max health.");
			HealthBarTextDisplay = ((BaseUnityPlugin)this).Config.Bind<StatBarTextDisplayMode>("StatBars", "HealthBarTextDisplay", StatBarTextDisplayMode.JustValue, "Changes how the label of the health bar is displayed.");
			HealthBarTextPosition = ((BaseUnityPlugin)this).Config.Bind<StatBarTextPosition>("StatBars", "HealthBarTextPosition", StatBarTextPosition.Center, "Changes where the label of the health bar is displayed.");
			HealthBarShowTicks = ((BaseUnityPlugin)this).Config.Bind<bool>("StatBars", "HealthBarShowTicks", false, "Show a faint line on the bar every 25 units");
			StaminaBarShow = ((BaseUnityPlugin)this).Config.Bind<bool>("StatBars", "StaminaBarShow", true, "If false, hides the stamina bar completely.");
			StaminaBarFixedSize = ((BaseUnityPlugin)this).Config.Bind<int>("StatBars", "StaminaBarFixedSize", 0, "If greater than 0, forces the stamina bar to be that many pixels long, regardless of the player's max stamina.");
			StaminaBarTextDisplay = ((BaseUnityPlugin)this).Config.Bind<StatBarTextDisplayMode>("StatBars", "StaminaBarTextDisplay", StatBarTextDisplayMode.JustValue, "Changes how the label of the stamina bar is displayed.");
			StaminaBarTextPosition = ((BaseUnityPlugin)this).Config.Bind<StatBarTextPosition>("StatBars", "StaminaBarTextPosition", StatBarTextPosition.Center, "Changes where the label of the stamina bar is displayed.");
			StaminaBarShowTicks = ((BaseUnityPlugin)this).Config.Bind<bool>("StatBars", "StaminaBarShowTicks", false, "Show a faint line on the bar every 25 units");
			EitrBarShow = ((BaseUnityPlugin)this).Config.Bind<bool>("StatBars", "EitrBarShow", true, "If false, hides the eitr bar completely.");
			EitrBarFixedSize = ((BaseUnityPlugin)this).Config.Bind<int>("StatBars", "EitrBarFixedSize", 0, "If greater than 0, forces the eitr bar to be that many pixels long, regardless of the player's max eitr. Eitr bar still hides if max eitr is zero.");
			EitrBarTextDisplay = ((BaseUnityPlugin)this).Config.Bind<StatBarTextDisplayMode>("StatBars", "EitrBarTextDisplay", StatBarTextDisplayMode.JustValue, "Changes how the label of the eitr bar is displayed.");
			EitrBarTextPosition = ((BaseUnityPlugin)this).Config.Bind<StatBarTextPosition>("StatBars", "EitrBarTextPosition", StatBarTextPosition.Center, "Changes where the label of the eitr bar is displayed.");
			EitrBarShowTicks = ((BaseUnityPlugin)this).Config.Bind<bool>("StatBars", "EitrBarShowTicks", false, "Show a faint line on the bar every 25 units");
		}

		private static void LoadAssets()
		{
			AssetBundle val = LoadAssetBundle("augaassets");
			Assets.Cursor = val.LoadAsset<Texture2D>("Cursor2");
			Assets.Hud = val.LoadAsset<GameObject>("HUD");
			Assets.MessageHud = val.LoadAsset<GameObject>("AugaMessageHud");
			Assets.DamageText = val.LoadAsset<GameObject>("AugaDamageText");
		}

		private static void ApplyCursor()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Cursor.SetCursor(Assets.Cursor, new Vector2(6f, 5f), (CursorMode)0);
		}

		public static AssetBundle LoadAssetBundle(string filename)
		{
			string assetPath = GetAssetPath(filename);
			if (!string.IsNullOrEmpty(assetPath))
			{
				return AssetBundle.LoadFromFile(assetPath);
			}
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			return AssetBundle.LoadFromStream(callingAssembly.GetManifestResourceStream(callingAssembly.GetName().Name + "." + filename));
		}

		public static string LoadJsonText(string filename)
		{
			string assetPath = GetAssetPath(filename);
			if (string.IsNullOrEmpty(assetPath))
			{
				return null;
			}
			return File.ReadAllText(assetPath);
		}

		public static string GetAssetPath(string assetName)
		{
			string text = Path.Combine(Paths.PluginPath, "Auga", assetName);
			if (!File.Exists(text))
			{
				text = Path.Combine(Path.GetDirectoryName(typeof(AugaLite).Assembly.Location) ?? string.Empty, assetName);
				if (!File.Exists(text))
				{
					LogError("Could not find asset (" + assetName + ")");
					return null;
				}
			}
			return text;
		}

		public static void Log(string message)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			if (_loggingEnabled.Value && (int)_logLevel.Value <= 16)
			{
				((BaseUnityPlugin)_instance).Logger.LogInfo((object)message);
			}
		}

		public static void LogWarning(string message)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			if (_loggingEnabled.Value && (int)_logLevel.Value <= 4)
			{
				((BaseUnityPlugin)_instance).Logger.LogWarning((object)message);
			}
		}

		public static void LogError(string message)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			if (_loggingEnabled.Value && (int)_logLevel.Value <= 2)
			{
				((BaseUnityPlugin)_instance).Logger.LogError((object)message);
			}
		}

		public static void UpdateStatBars()
		{
			//IL_0091: 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_00fd: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Hud.instance != (Object)null))
			{
				return;
			}
			Transform val = ((Component)Hud.instance).transform.Find("hudroot/HealthBar");
			Transform val2 = ((Component)Hud.instance).transform.Find("hudroot/StaminaBar");
			Transform val3 = ((Component)Hud.instance).transform.Find("hudroot/EitrBar");
			if ((Object)(object)val != (Object)null)
			{
				AugaHealthBar component = ((Component)val).GetComponent<AugaHealthBar>();
				if (component != null)
				{
					component.Hide = !HealthBarShow.Value;
					component.FixedLength = HealthBarFixedSize.Value;
					component.TextDisplay = (TextDisplayMode)HealthBarTextDisplay.Value;
					component.DisplayTextPosition = (TextPosition)HealthBarTextPosition.Value;
					component.ShowTicks = HealthBarShowTicks.Value;
				}
			}
			if ((Object)(object)val2 != (Object)null)
			{
				AugaHealthBar component2 = ((Component)val2).GetComponent<AugaHealthBar>();
				if (component2 != null)
				{
					component2.Hide = !StaminaBarShow.Value;
					component2.FixedLength = StaminaBarFixedSize.Value;
					component2.TextDisplay = (TextDisplayMode)StaminaBarTextDisplay.Value;
					component2.DisplayTextPosition = (TextPosition)StaminaBarTextPosition.Value;
					component2.ShowTicks = StaminaBarShowTicks.Value;
				}
			}
			if ((Object)(object)val3 != (Object)null)
			{
				AugaHealthBar component3 = ((Component)val3).GetComponent<AugaHealthBar>();
				if (component3 != null)
				{
					component3.Hide = !EitrBarShow.Value;
					component3.FixedLength = EitrBarFixedSize.Value;
					component3.TextDisplay = (TextDisplayMode)EitrBarTextDisplay.Value;
					component3.DisplayTextPosition = (TextPosition)EitrBarTextPosition.Value;
					component3.ShowTicks = EitrBarShowTicks.Value;
				}
			}
		}
	}
	public class MovableHudElement : MonoBehaviour
	{
		public ConfigEntry<TextAnchor> Anchor;

		public ConfigEntry<Vector2> Position;

		public ConfigEntry<float> Scale;

		public void Init(TextAnchor defaultAnchor, float defaultPositionX, float defaultPositionY)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Init(((Object)((Component)this).gameObject).name, defaultAnchor, defaultPositionX, defaultPositionY);
		}

		public void Init(string nameOverride, TextAnchor defaultAnchor, float defaultPositionX, float defaultPositionY)
		{
			//IL_0017: 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)
			Anchor = ((BaseUnityPlugin)AugaLite.instance).Config.Bind<TextAnchor>(nameOverride, nameOverride + "Anchor", defaultAnchor, "Anchor for " + nameOverride);
			Position = ((BaseUnityPlugin)AugaLite.instance).Config.Bind<Vector2>(nameOverride, nameOverride + "Position", new Vector2(defaultPositionX, defaultPositionY), "Position for " + nameOverride);
			Scale = ((BaseUnityPlugin)AugaLite.instance).Config.Bind<float>(nameOverride, nameOverride + "Scale", 1f, "Uniform scale for " + nameOverride);
		}

		public void Update()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//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_005b: Expected I4, but got Unknown
			//IL_0074: 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_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_0082: 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_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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00d5: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_0103: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			if (Anchor != null && Position != null && Scale != null)
			{
				RectTransform val = (RectTransform)((Component)this).transform;
				TextAnchor value = Anchor.Value;
				Vector2 val2 = default(Vector2);
				switch ((int)value)
				{
				case 0:
				{
					((Vector2)(ref val2))..ctor(0f, 1f);
					val.anchorMax = val2;
					Vector2 pivot = (val.anchorMin = val2);
					val.pivot = pivot;
					break;
				}
				case 1:
				{
					((Vector2)(ref val2))..ctor(0.5f, 1f);
					val.anchorMax = val2;
					Vector2 pivot = (val.anchorMin = val2);
					val.pivot = pivot;
					break;
				}
				case 2:
				{
					((Vector2)(ref val2))..ctor(1f, 1f);
					val.anchorMax = val2;
					Vector2 pivot = (val.anchorMin = val2);
					val.pivot = pivot;
					break;
				}
				case 3:
				{
					((Vector2)(ref val2))..ctor(0f, 0.5f);
					val.anchorMax = val2;
					Vector2 pivot = (val.anchorMin = val2);
					val.pivot = pivot;
					break;
				}
				case 4:
				{
					((Vector2)(ref val2))..ctor(0.5f, 0.5f);
					val.anchorMax = val2;
					Vector2 pivot = (val.anchorMin = val2);
					val.pivot = pivot;
					break;
				}
				case 5:
				{
					((Vector2)(ref val2))..ctor(1f, 0.5f);
					val.anchorMax = val2;
					Vector2 pivot = (val.anchorMin = val2);
					val.pivot = pivot;
					break;
				}
				case 6:
				{
					((Vector2)(ref val2))..ctor(0f, 0f);
					val.anchorMax = val2;
					Vector2 pivot = (val.anchorMin = val2);
					val.pivot = pivot;
					break;
				}
				case 7:
				{
					((Vector2)(ref val2))..ctor(0.5f, 0f);
					val.anchorMax = val2;
					Vector2 pivot = (val.anchorMin = val2);
					val.pivot = pivot;
					break;
				}
				case 8:
				{
					((Vector2)(ref val2))..ctor(1f, 0f);
					val.anchorMax = val2;
					Vector2 pivot = (val.anchorMin = val2);
					val.pivot = pivot;
					break;
				}
				}
				val.anchoredPosition = Position.Value;
				((Transform)val).localScale = new Vector3(Scale.Value, Scale.Value);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "OnDeath")]
	public static class Player_OnDeath_Patch
	{
		public static void Postfix(Player __instance)
		{
			LastHitTracker lastHitTracker = ((Component)(object)__instance).RequireComponent<LastHitTracker>();
			HitData val = (((Object)(object)lastHitTracker != (Object)null) ? lastHitTracker.LastHit : null);
			AugaMessageLog.instance.AddDeathLog(__instance, val);
		}
	}
	[HarmonyPatch(typeof(TombStone), "UpdateDespawn")]
	public static class TombStone_UpdateDespawn_Patch
	{
		public static bool Prefix(TombStone __instance)
		{
			if (__instance.m_nview.IsValid() && __instance.IsOwner() && !__instance.m_container.IsInUse() && __instance.m_container.GetInventory().NrOfItems() <= 0)
			{
				AugaMessageLog.instance.AddTombstoneLog(Player.m_localPlayer);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "AddKnownItem")]
	public static class Player_AddKnownItem_Patch
	{
		public static bool Prefix(Player __instance, ItemData item)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			if (__instance.m_knownMaterial.Contains(item.m_shared.m_name))
			{
				return true;
			}
			if ((int)item.m_shared.m_itemType == 1)
			{
				AugaMessageLog.instance.AddNewMaterialLog(item);
			}
			else if ((int)item.m_shared.m_itemType == 13)
			{
				AugaMessageLog.instance.AddNewTrophyLog(item);
			}
			else
			{
				AugaMessageLog.instance.AddNewItemLog(item);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateKnownRecipesList")]
	public static class Player_UpdateKnownRecipesList_Patch
	{
		public static bool Prefix(Player __instance)
		{
			List<Recipe> list = new List<Recipe>();
			foreach (Recipe recipe in ObjectDB.instance.m_recipes)
			{
				if (recipe.m_enabled && !__instance.m_knownRecipes.Contains(recipe.m_item.m_itemData.m_shared.m_name) && __instance.HaveRequirements(recipe, true, 0, 1))
				{
					list.Add(recipe);
				}
			}
			if (list.Count > 0)
			{
				AugaMessageLog.instance.AddNewRecipesLog((IReadOnlyList<Recipe>)list);
			}
			List<PieceTable> list2 = new List<PieceTable>();
			List<Piece> list3 = new List<Piece>();
			((Humanoid)__instance).m_inventory.GetAllPieceTables(list2);
			foreach (PieceTable item in list2)
			{
				foreach (GameObject piece in item.m_pieces)
				{
					Piece component = piece.GetComponent<Piece>();
					if (component.m_enabled && !__instance.m_knownRecipes.Contains(component.m_name) && __instance.HaveRequirements(component, (RequirementMode)1))
					{
						list3.Add(component);
					}
				}
			}
			if (list3.Count > 0)
			{
				AugaMessageLog.instance.AddNewPieceLog(list3);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "AddKnownStation")]
	public static class Player_AddKnownStation_Patch
	{
		public static bool Prefix(Player __instance, CraftingStation station)
		{
			if (!__instance.m_knownStations.ContainsKey(station.m_name))
			{
				AugaMessageLog.instance.AddNewStationLog(station);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "AddKnownBiome")]
	public static class Player_AddKnownBiome_Patch
	{
		public static bool Prefix(Player __instance, Biome biome)
		{
			//IL_0006: 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)
			if (!__instance.m_knownBiome.Contains(biome))
			{
				AugaMessageLog.instance.AddNewBiomeLog(biome);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(TeleportWorld), "Teleport")]
	public static class TeleportWorld_Teleport_Patch
	{
		public static void Postfix(TeleportWorld __instance, Player player)
		{
			if (__instance.TargetFound() && ((Humanoid)player).IsTeleportable())
			{
				AugaMessageLog.instance.AddTeleportLog(__instance.GetText(), player);
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
	public static class InventoryGui_DoCrafting_Patch
	{
		public static bool Prefix(InventoryGui __instance, Player player)
		{
			if ((Object)(object)__instance.m_craftRecipe == (Object)null)
			{
				return true;
			}
			ItemData craftUpgradeItem = __instance.m_craftUpgradeItem;
			int num = ((craftUpgradeItem == null) ? 1 : (craftUpgradeItem.m_quality + 1));
			if (num > __instance.m_craftRecipe.m_item.m_itemData.m_shared.m_maxQuality || (!player.HaveRequirements(__instance.m_craftRecipe, false, num, 1) && !player.NoCostCheat()) || (__instance.m_craftUpgradeItem != null && !((Humanoid)player).GetInventory().ContainsItem(__instance.m_craftUpgradeItem)) || (__instance.m_craftUpgradeItem == null && !((Humanoid)player).GetInventory().HaveEmptySlot()))
			{
				return true;
			}
			if (__instance.m_craftRecipe.m_item.m_itemData.m_shared.m_dlc.Length > 0 && !DLCMan.instance.IsDLCInstalled(__instance.m_craftRecipe.m_item.m_itemData.m_shared.m_dlc))
			{
				return true;
			}
			if (__instance.m_craftUpgradeItem != null)
			{
				AugaMessageLog.instance.AddUpgradeItemLog(__instance.m_craftUpgradeItem, num);
			}
			else
			{
				AugaMessageLog.instance.AddCraftItemLog(__instance.m_craftRecipe);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "RaiseSkill")]
	public static class Player_RaiseSkill_Patch
	{
		public static SkillType Skill;

		public static int LevelBefore;

		public static bool Prefix(Player __instance, SkillType skill)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			Skill = skill;
			LevelBefore = Mathf.FloorToInt(__instance.m_skills.GetSkill(skill)?.m_level ?? 0f);
			return true;
		}

		public static void Postfix(Player __instance, SkillType skill)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (Skill == skill)
			{
				int num = Mathf.FloorToInt(__instance.m_skills.GetSkill(skill)?.m_level ?? 0f);
				if (LevelBefore != num)
				{
					AugaMessageLog.instance.AddSkillUpLog(skill, num);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Character), "ShowPickupMessage")]
	public static class Character_ShowPickupMessage_Patch
	{
		public static void Postfix(ItemData item, int amount)
		{
			if (item != null && amount > 0)
			{
				AugaMessageLog.instance.AddItemPickupLog(item, amount);
			}
		}
	}
	[HarmonyPatch]
	public static class DamageText_Setup
	{
		[HarmonyPatch(typeof(DamageText), "Awake")]
		public static class DamageText_Awake_Patch
		{
			public static bool Prefix(TextInput __instance)
			{
				return !SetupHelper.DirectObjectReplace(((Component)__instance).transform, AugaLite.Assets.DamageText, "DamageText");
			}
		}

		[HarmonyPatch(typeof(DamageText), "AddInworldText")]
		[HarmonyPostfix]
		public static void AddInworldText_Postfix(DamageText __instance, TextType type, string text, bool mySelf)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected I4, but got Unknown
			//IL_00ba: 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_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_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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0045: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			WorldTextInstance val = __instance.m_worldTexts.LastOrDefault();
			if (val != null)
			{
				Color color = (Color)(((int)type == 4) ? AugaLite.Colors.Healing : (mySelf ? ((text != "0") ? AugaLite.Colors.PlayerDamage : AugaLite.Colors.PlayerNoDamage) : ((int)type switch
				{
					0 => AugaLite.Colors.NormalDamage, 
					1 => AugaLite.Colors.ResistDamage, 
					2 => AugaLite.Colors.WeakDamage, 
					3 => AugaLite.Colors.ImmuneDamage, 
					5 => AugaLite.Colors.TooHard, 
					_ => Color.white, 
				})));
				((Graphic)val.m_textField).color = color;
			}
		}
	}
	[Flags]
	public enum ReplaceFlags
	{
		None = 0,
		Instantiate = 1,
		DestroyOriginal = 2
	}
	public static class AugaExtensions
	{
		public static RectTransform RectTransform(this Component c)
		{
			Transform transform = c.transform;
			return (RectTransform)(object)((transform is RectTransform) ? transform : null);
		}

		public static RectTransform RectTransform(this GameObject go)
		{
			Transform transform = go.transform;
			return (RectTransform)(object)((transform is RectTransform) ? transform : null);
		}

		public static void HideElement(this Component c)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)c != (Object)null)
			{
				c.gameObject.SetActive(false);
				c.gameObject.transform.localScale = Vector3.zero;
			}
		}

		public static void HideElementByType<T>(this Component parent) where T : Component
		{
			if (!((Object)(object)parent == (Object)null))
			{
				((Component)(object)parent.GetComponentInChildren<T>()).HideElement();
			}
		}

		public static void HideElementByName(this GameObject parent, string name)
		{
			((Component)(object)parent.transform).HideElementByName(name);
		}

		public static void HideElementByName(this Component parent, string name)
		{
			if (!((Object)(object)parent == (Object)null))
			{
				((Component)(object)parent.transform.Find(name)).HideElement();
			}
		}

		public static Transform Replace(this Transform c, string findPath, Transform other, string otherFindPath = null, ReplaceFlags flags = ReplaceFlags.Instantiate | ReplaceFlags.DestroyOriginal)
		{
			Transform val = c.Find(findPath);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			otherFindPath = otherFindPath ?? findPath;
			Transform val2 = other.Find(otherFindPath);
			if ((Object)(object)val2 == (Object)null)
			{
				return null;
			}
			Transform parent = val.parent;
			int siblingIndex = val.GetSiblingIndex();
			val.SetParent((Transform)null);
			if ((flags & ReplaceFlags.DestroyOriginal) != 0)
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			if ((flags & ReplaceFlags.Instantiate) != 0)
			{
				val2 = Object.Instantiate<Transform>(val2, parent);
				((Object)val2).name = ((Object)val2).name.Replace("(Clone)", "").Replace("(clone)", "");
			}
			else
			{
				val2.SetParent(parent);
			}
			val2.SetSiblingIndex(siblingIndex);
			return val2;
		}

		public static Transform Replace(this Component c, string findPath, GameObject other, string otherFindPath = null, ReplaceFlags flags = ReplaceFlags.Instantiate | ReplaceFlags.DestroyOriginal)
		{
			return c.transform.Replace(findPath, other.transform, otherFindPath, flags);
		}

		public static Transform Replace(this Transform c, string findPath, GameObject other, string otherFindPath = null, ReplaceFlags flags = ReplaceFlags.Instantiate | ReplaceFlags.DestroyOriginal)
		{
			return c.Replace(findPath, other.transform, otherFindPath, flags);
		}

		public static Transform Replace(this GameObject go, string findPath, Transform other, string otherFindPath = null, ReplaceFlags flags = ReplaceFlags.Instantiate | ReplaceFlags.DestroyOriginal)
		{
			return go.transform.Replace(findPath, other, otherFindPath, flags);
		}

		public static Transform Replace(this GameObject go, string findPath, GameObject other, string otherFindPath = null, ReplaceFlags flags = ReplaceFlags.Instantiate | ReplaceFlags.DestroyOriginal)
		{
			return go.transform.Replace(findPath, other.transform, otherFindPath, flags);
		}

		public static Transform CopyOver(this GameObject go, string findPath, GameObject other, int siblingIndex)
		{
			Transform val = other.transform.Find(findPath);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			val = Object.Instantiate<Transform>(val, go.transform);
			((Object)val).name = ((Object)val).name.Replace("(Clone)", "").Replace("(clone)", "");
			val.SetSiblingIndex(siblingIndex);
			return val;
		}

		public static T RequireComponent<T>(this Component c) where T : Component
		{
			T val = c.GetComponent<T>();
			if ((Object)(object)val == (Object)null)
			{
				val = c.gameObject.AddComponent<T>();
			}
			return val;
		}

		public static T RequireComponent<T>(this GameObject go) where T : Component
		{
			T val = go.GetComponent<T>();
			if ((Object)(object)val == (Object)null)
			{
				val = go.AddComponent<T>();
			}
			return val;
		}
	}
	[HarmonyPatch(typeof(GuiBar), "SetBar")]
	public static class GuiBar_Patch
	{
		public static bool Prefix(GuiBar __instance, float i)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.m_barImage != (Object)null && (int)__instance.m_barImage.type == 3)
			{
				__instance.m_barImage.fillAmount = i;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Hud))]
	public static class Hud_Setup
	{
		[HarmonyPatch("Awake")]
		[HarmonyPriority(800)]
		[HarmonyPostfix]
		public static void Hud_Awake_Postfix(Hud __instance)
		{
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Expected O, but got Unknown
			__instance.m_saveIcon = ((Component)((Component)(object)__instance).Replace("hudroot/SaveIcon", AugaLite.Assets.Hud)).gameObject;
			__instance.m_saveIconImage = __instance.m_saveIcon.GetComponent<Image>();
			__instance.m_badConnectionIcon = ((Component)((Component)(object)__instance).Replace("hudroot/BadConnectionIcon", AugaLite.Assets.Hud)).gameObject;
			DreamTexts dreamTexts = __instance.m_sleepingProgress.GetComponent<SleepText>().m_dreamTexts;
			Transform val = ((Component)(object)__instance).Replace("LoadingBlack", AugaLite.Assets.Hud);
			__instance.m_loadingScreen = ((Component)val).GetComponent<CanvasGroup>();
			__instance.m_loadingProgress = ((Component)val.Find("Loading")).gameObject;
			__instance.m_sleepingProgress = ((Component)val.Find("Sleeping")).gameObject;
			__instance.m_teleportingProgress = ((Component)val.Find("Teleporting")).gameObject;
			__instance.m_loadingImage = ((Component)val.Find("Loading/Image")).GetComponent<Image>();
			__instance.m_loadingTip = ((Component)val.Find("Loading/Tip")).GetComponent<TMP_Text>();
			__instance.m_sleepingProgress.GetComponent<SleepText>().m_dreamTexts = dreamTexts;
			__instance.m_eventBar = ((Component)((Component)(object)__instance).Replace("hudroot/EventBar", AugaLite.Assets.Hud)).gameObject;
			__instance.m_eventName = __instance.m_eventBar.GetComponentInChildren<TMP_Text>();
			__instance.m_eventBar.gameObject.AddComponent<MovableHudElement>().Init((TextAnchor)1, 0f, -90f);
			__instance.m_damageScreen = ((Component)((Component)(object)__instance).Replace("hudroot/Damaged", AugaLite.Assets.Hud)).GetComponent<Image>();
			TextMeshProUGUI component = ((Component)AugaLite.Assets.Hud.transform.Find("hudroot/crosshair/Dummy/HoverName")).GetComponent<TextMeshProUGUI>();
			((TMP_Text)__instance.m_hoverName).font = ((TMP_Text)component).font;
			Material material = ((Graphic)__instance.m_gpIcon).material;
			__instance.m_gpRoot = (RectTransform)((Component)(object)__instance).Replace("hudroot/GuardianPower", AugaLite.Assets.Hud);
			__instance.m_gpName = ((Component)((Transform)__instance.m_gpRoot).Find("Name")).GetComponent<TMP_Text>();
			__instance.m_gpIcon = ((Component)((Transform)__instance.m_gpRoot).Find("Icon")).GetComponent<Image>();
			((Graphic)__instance.m_gpIcon).material = material;
			__instance.m_gpCooldown = ((Component)((Transform)__instance.m_gpRoot).Find("GPTimeText")).GetComponent<TMP_Text>();
			((Component)(object)((Transform)__instance.m_gpRoot).Find("GPKey")).HideElement();
			((Component)__instance.m_gpRoot).gameObject.AddComponent<MovableHudElement>().Init((TextAnchor)6, 60f, 70f);
			foreach (Transform item in (Transform)__instance.m_healthPanel)
			{
				((Component)item).HideElement();
			}
			((Component)(object)__instance.m_staminaBar2Root).HideElement();
			((Component)(object)__instance.m_eitrBarRoot).HideElement();
			Transform obj = ((Component)__instance).transform.Find("hudroot");
			Transform val2 = ((Component)obj).gameObject.CopyOver("hudroot/FoodPanel0", AugaLite.Assets.Hud, 5);
			Transform val3 = ((Component)obj).gameObject.CopyOver("hudroot/FoodPanel1", AugaLite.Assets.Hud, 6);
			Transform val4 = ((Component)obj).gameObject.CopyOver("hudroot/FoodPanel2", AugaLite.Assets.Hud, 7);
			Transform val5 = ((Component)obj).gameObject.CopyOver("hudroot/HealthBar", AugaLite.Assets.Hud, 8);
			Transform val6 = ((Component)obj).gameObject.CopyOver("hudroot/StaminaBar", AugaLite.Assets.Hud, 9);
			Transform val7 = ((Component)obj).gameObject.CopyOver("hudroot/EitrBar", AugaLite.Assets.Hud, 10);
			((Component)val2).gameObject.AddComponent<MovableHudElement>().Init((TextAnchor)6, 138f, 66f);
			((Component)val3).gameObject.AddComponent<MovableHudElement>().Init((TextAnchor)6, 167f, 95f);
			((Component)val4).gameObject.AddComponent<MovableHudElement>().Init((TextAnchor)6, 138f, 124f);
			((Component)val5).gameObject.AddComponent<MovableHudElement>().Init((TextAnchor)6, 208f, 123.5f);
			((Component)val6).gameObject.AddComponent<MovableHudElement>().Init((TextAnchor)6, 208f, 99.5f);
			((Component)val7).gameObject.AddComponent<MovableHudElement>().Init((TextAnchor)6, 185f, 74.5f);
			__instance.m_healthAnimator = ((Component)val5).GetComponent<Animator>();
			__instance.m_foodBars = Array.Empty<Image>();
			__instance.m_foodIcons = Array.Empty<Image>();
			__instance.m_staminaAnimator = ((Component)val6).GetComponent<Animator>();
			__instance.m_eitrAnimator = ((Component)val7).GetComponent<Animator>();
			__instance.m_actionBarRoot = ((Component)((Component)(object)__instance).Replace("hudroot/action_progress", AugaLite.Assets.Hud)).gameObject;
			__instance.m_actionName = __instance.m_actionBarRoot.GetComponentInChildren<TMP_Text>();
			__instance.m_actionProgress = __instance.m_actionBarRoot.GetComponent<GuiBar>();
			__instance.m_actionBarRoot.gameObject.AddComponent<MovableHudElement>().Init("ActionProgress", (TextAnchor)7, 0f, 226f);
			Transform val8 = ((Component)(object)__instance).Replace("hudroot/staggerpanel", AugaLite.Assets.Hud);
			__instance.m_staggerAnimator = ((Component)val8).GetComponent<Animator>();
			__instance.m_staggerProgress = ((Component)val8.Find("staggerbar/RightBar/Background/FillMask/FillFast")).GetComponent<GuiBar>();
			((Component)val8).gameObject.AddComponent<MovableHudElement>().Init("StaggerPanel", (TextAnchor)7, 0f, 151f);
			AugaLite.UpdateStatBars();
			Localization.instance.Localize(((Component)__instance).transform);
		}

		[HarmonyPatch("UpdateFood")]
		[HarmonyPrefix]
		public static bool Hud_UpdateFood_Prefix()
		{
			return false;
		}

		[HarmonyPatch("SetHealthBarSize")]
		[HarmonyPrefix]
		public static bool Hud_SetHealthBarSize_Prefix()
		{
			return false;
		}

		[HarmonyPatch("SetStaminaBarSize")]
		[HarmonyPrefix]
		public static bool Hud_SetStaminaBarSize_Prefix()
		{
			return false;
		}

		[HarmonyPatch("UpdateHealth")]
		[HarmonyPrefix]
		public static bool Hud_UpdateHealth_Prefix()
		{
			return false;
		}

		[HarmonyPatch("UpdateStamina")]
		[HarmonyPrefix]
		public static bool Hud_UpdateStamina_Prefix()
		{
			return false;
		}

		[HarmonyPatch("UpdateEitr")]
		[HarmonyPrefix]
		public static bool Hud_UpdateEitr_Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(Hud), "StaminaBarEmptyFlash")]
	public static class Hud_StaminaBarEmptyFlash_Patch
	{
		private const float FlashDuration = 0.15f;

		private static Coroutine _staminaFlashCoroutine;

		public static bool Prefix(Hud __instance)
		{
			if (_staminaFlashCoroutine != null)
			{
				((MonoBehaviour)__instance).StopCoroutine(_staminaFlashCoroutine);
			}
			_staminaFlashCoroutine = ((MonoBehaviour)__instance).StartCoroutine(FlashStaminaBar(__instance));
			return false;
		}

		private static IEnumerator FlashStaminaBar(Hud instance)
		{
			Image staminaBarBorder = ((Component)((Component)instance.m_staminaAnimator).transform.Find("Background/Border")).GetComponent<Image>();
			for (int i = 0; i < 3; i++)
			{
				((Graphic)staminaBarBorder).color = Color.white;
				yield return (object)new WaitForSeconds(0.15f);
				((Graphic)staminaBarBorder).color = Color.black;
				yield return (object)new WaitForSeconds(0.15f);
			}
		}
	}
	[RequireComponent(typeof(Player))]
	public class LastHitTracker : MonoBehaviour
	{
		public HitData LastHit;

		protected Player _player;

		public void Awake()
		{
			_player = ((Component)this).GetComponent<Player>();
		}

		public virtual void OnDamaged(HitData hitData)
		{
			LastHit = hitData;
		}
	}
	[HarmonyPatch(typeof(Player), "OnDamaged")]
	public static class Player_OnDamaged_Patch
	{
		public static void Postfix(Player __instance, HitData hit)
		{
			((Component)(object)__instance).RequireComponent<LastHitTracker>().OnDamaged(hit);
		}
	}
	[HarmonyPatch]
	public static class MessageHud_Setup
	{
		[HarmonyPatch(typeof(MessageHud), "Awake")]
		[HarmonyPrefix]
		public static bool MessageHud_Awake_Prefix(MessageHud __instance)
		{
			return !SetupHelper.IndirectTwoObjectReplace(((Component)__instance).transform, AugaLite.Assets.MessageHud, "HudMessage", "TopLeftMessage", "AugaMessageHud");
		}

		[HarmonyPatch(typeof(MessageHud), "Awake")]
		[HarmonyPostfix]
		public static void MessageHud_Awake_Postfix(MessageHud __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				AugaTopLeftMessageController component = ((Component)__instance).GetComponent<AugaTopLeftMessageController>();
				if (Object.op_Implicit((Object)(object)component))
				{
					((Component)((Transform)component.LogContainer).parent).gameObject.AddComponent<MovableHudElement>().Init((TextAnchor)0, 55f, -115f);
				}
				((Component)__instance.m_messageCenterText).gameObject.AddComponent<MovableHudElement>().Init((TextAnchor)4, 0f, 150f);
			}
		}

		[HarmonyPatch(typeof(MessageHud), "ShowMessage")]
		[HarmonyPostfix]
		public static void MessageHud_ShowMessage_Postfix(MessageHud __instance, MessageType type, string text, int amount, Sprite icon)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			if (!Hud.IsUserHidden())
			{
				text = Localization.instance.Localize(text);
				if ((int)type == 1)
				{
					((Component)__instance).GetComponent<AugaTopLeftMessageController>().AddMessage(text, icon, amount);
				}
			}
		}
	}
	public static class SetupHelper
	{
		public static bool DirectObjectReplace(Transform original, GameObject prefab, string originalName)
		{
			GameObject newObject;
			return DirectObjectReplace(original, prefab, originalName, out newObject);
		}

		public static bool DirectObjectReplace(Transform original, GameObject prefab, string originalName, out GameObject newObject)
		{
			if (((Object)original).name != originalName)
			{
				newObject = null;
				return false;
			}
			Transform parent = original.parent;
			int siblingIndex = original.GetSiblingIndex();
			Object.DestroyImmediate((Object)(object)((Component)original).gameObject);
			newObject = Object.Instantiate<GameObject>(prefab, parent, false);
			newObject.transform.SetSiblingIndex(siblingIndex);
			return true;
		}

		public static bool IndirectTwoObjectReplace(Transform primaryOriginal, GameObject prefab, string originalName, string secondaryName, string newPrimaryName)
		{
			if (((Object)primaryOriginal).name.StartsWith("Auga"))
			{
				return false;
			}
			if (((Object)primaryOriginal).name != originalName)
			{
				return false;
			}
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				AugaLite.LogWarning("Prefab for " + originalName + " converting to " + newPrimaryName + " for " + secondaryName + " not found.");
				return false;
			}
			Transform parent = primaryOriginal.parent;
			if ((Object)(object)parent != (Object)null)
			{
				Transform val = parent.Find(secondaryName);
				if ((Object)(object)val != (Object)null)
				{
					int siblingIndex = val.GetSiblingIndex();
					int siblingIndex2 = primaryOriginal.GetSiblingIndex();
					Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
					Object.DestroyImmediate((Object)(object)((Component)primaryOriginal).gameObject);
					GameObject obj = Object.Instantiate<GameObject>(prefab, parent);
					Transform val2 = obj.transform.Find(secondaryName);
					Transform obj2 = obj.transform.Find(newPrimaryName);
					val2.SetParent(parent);
					obj2.SetParent(parent);
					val2.SetSiblingIndex(siblingIndex);
					obj2.SetSiblingIndex(siblingIndex2);
					Object.Destroy((Object)(object)obj);
					return true;
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Text))]
	public static class Text_Patch
	{
		public static TextInfo TextInfo = new CultureInfo("en-US").TextInfo;

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static bool Prefix(Text __instance, ref string value)
		{
			if ((Object)(object)__instance == (Object)null || string.IsNullOrEmpty(value))
			{
				return true;
			}
			if ((Object)(object)((Component)__instance).GetComponent<AlwaysUpper>() != (Object)null)
			{
				if (value.StartsWith("$"))
				{
					value = Localization.instance.Localize(value);
				}
				value = value.ToUpper();
			}
			else if ((Object)(object)((Component)__instance).GetComponent<TitleCase>() != (Object)null)
			{
				if (value.StartsWith("$"))
				{
					value = Localization.instance.Localize(value);
				}
				value = TextInfo.ToTitleCase(value);
			}
			return true;
		}
	}
}
namespace AugaLite.Utilities
{
	public class TranspilerHelpers
	{
		private int _counter;

		private bool _enableLogging;

		public TranspilerHelpers(bool loggingEnabled = false)
		{
			_enableLogging = loggingEnabled;
		}

		public CodeInstruction LogMessage(CodeInstruction instruction)
		{
			if (!_enableLogging)
			{
				return instruction;
			}
			_counter++;
			return instruction;
		}

		public CodeInstruction FindInstructionWithLabel(List<CodeInstruction> codeInstructions, int index, Label label)
		{
			if (index >= codeInstructions.Count)
			{
				return null;
			}
			if (codeInstructions[index].labels.Contains(label))
			{
				return codeInstructions[index];
			}
			return FindInstructionWithLabel(codeInstructions, index + 1, label);
		}
	}
}
namespace AugaLite.Compat
{
	public static class Jewelcrafting
	{
		public static Assembly ModAssembly;

		public static Type Synergy;

		public static Type DisplaySynergyView;

		public static Type AddSynergyIcon;

		public static Type SocketsBackground;

		public static Type FusionBoxSetup;

		public static Type AddSealButton;

		public static Type GemCursor;

		public static Type CacheVanillaCursor;

		public static Type GemStones;

		public static Type OpenFakeSocketsContainer;

		public static Type CloseFakeSocketsContainer;

		[HarmonyBefore(new string[] { "org.bepinex.plugins.jewelcrafting" })]
		public static void Hud_Awake_Prefix(Hud __instance)
		{
			((Component)(object)__instance).Replace("hudroot/HotKeyBar", AugaLite.Assets.Hud, "hudroot/HotKeyBar");
		}

		public static Vector2 ChangeSealPosition(Vector2 anchoredPosition)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(41f, 340f);
		}

		public static Vector2 ChangeTakeAllPosition(Vector2 anchoredPosition)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return anchoredPosition;
		}

		public static IEnumerable<CodeInstruction> FusionBoxSetup_AddSealButton_Postfix_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			TranspilerHelpers th = new TranspilerHelpers();
			List<CodeInstruction> instrs = instructions.ToList();
			bool skipRows = false;
			int i = 0;
			while (i < instrs.Count)
			{
				if (i > 0 && instrs[i].opcode == OpCodes.Ldstr && instrs[i].operand.Equals("Text"))
				{
					yield return th.LogMessage(new CodeInstruction(OpCodes.Ldstr, (object)"Label"));
				}
				else if (instrs[i].opcode == OpCodes.Ldloca_S)
				{
					skipRows = true;
				}
				else if (i > 5 && skipRows && instrs[i].opcode == OpCodes.Ldloc_1 && instrs[i - 1].opcode == OpCodes.Call)
				{
					skipRows = false;
					yield return th.LogMessage(instrs[i]);
					yield return th.LogMessage(new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(Jewelcrafting), "ChangeSealPosition", (Type[])null, (Type[])null)));
				}
				else if (!skipRows)
				{
					yield return th.LogMessage(instrs[i]);
				}
				int num = i + 1;
				i = num;
			}
		}

		public static IEnumerable<CodeInstruction> GemStones_CloseFakeSocketsContainer_Prefix_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			TranspilerHelpers th = new TranspilerHelpers();
			List<CodeInstruction> instrs = instructions.ToList();
			bool skipRows = false;
			int i = 0;
			while (i < instrs.Count)
			{
				if (instrs[i].opcode == OpCodes.Dup && instrs[i + 1].opcode == OpCodes.Callvirt && instrs[i + 2].opcode == OpCodes.Stloc_0 && instrs[i + 3].opcode == OpCodes.Ldloca_S)
				{
					skipRows = true;
				}
				else if (i > 5 && skipRows && instrs[i].opcode == OpCodes.Callvirt && instrs[i - 1].opcode == OpCodes.Ldloc_0 && instrs[i - 2].opcode == OpCodes.Dup)
				{
					skipRows = false;
				}
				else if (!skipRows)
				{
					yield return th.LogMessage(instrs[i]);
				}
				int num = i + 1;
				i = num;
			}
		}

		public static IEnumerable<CodeInstruction> GemStones_OpenFakeSocketsContainer_Open_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			TranspilerHelpers th = new TranspilerHelpers();
			List<CodeInstruction> instrs = instructions.ToList();
			bool skipRows = false;
			int i = 0;
			while (i < instrs.Count)
			{
				if (instrs[i].opcode == OpCodes.Callvirt && instrs[i + 1].opcode == OpCodes.Stloc_S)
				{
					yield return th.LogMessage(instrs[i]);
					yield return th.LogMessage(instrs[i + 1]);
					yield return th.LogMessage(instrs[i + 3]);
					yield return th.LogMessage(new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(Jewelcrafting), "ChangeTakeAllPosition", (Type[])null, (Type[])null)));
					yield return th.LogMessage(instrs[i + 1]);
					skipRows = true;
				}
				else if (i > 5 && skipRows && instrs[i].opcode == OpCodes.Callvirt && instrs[i - 1].opcode == OpCodes.Ldloc_S && instrs[i - 2].opcode == OpCodes.Ldloc_3)
				{
					skipRows = false;
					yield return th.LogMessage(instrs[i - 2]);
					yield return th.LogMessage(instrs[i - 1]);
					yield return th.LogMessage(instrs[i]);
				}
				else if (!skipRows)
				{
					yield return th.LogMessage(instrs[i]);
				}
				int num = i + 1;
				i = num;
			}
		}

		private static Texture2D GetAugaCursor()
		{
			return AugaLite.Assets.Cursor;
		}

		public static IEnumerable<CodeInstruction> GemCursor_CacheVanillaCursor_Postfix_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> instrs = instructions.ToList();
			TranspilerHelpers th = new TranspilerHelpers();
			bool skipRows = false;
			int i = 0;
			while (i < instrs.Count)
			{
				if (instrs[i].opcode == OpCodes.Ldsflda)
				{
					yield return th.LogMessage(instrs[i]);
					skipRows = !skipRows;
					if (skipRows)
					{
						yield return th.LogMessage(new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(Jewelcrafting), "GetAugaCursor", (Type[])null, (Type[])null)));
					}
				}
				else if (instrs[i].opcode == OpCodes.Stfld && skipRows)
				{
					yield return th.LogMessage(instrs[i]);
				}
				else if (!skipRows)
				{
					yield return th.LogMessage(instrs[i]);
				}
				int num = i + 1;
				i = num;
			}
		}

		public static IEnumerable<CodeInstruction> AddSocketAddingTab_InventoryGui_Awake_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> instrs = instructions.ToList();
			TranspilerHelpers th = new TranspilerHelpers();
			int i = 0;
			while (i < instrs.Count)
			{
				yield return th.LogMessage(instrs[i]);
				int num = i + 1;
				i = num;
			}
		}

		private static bool ConfigureForAuga()
		{
			return true;
		}

		[HarmonyAfter(new string[] { "org.bepinex.plugins.jewelcrafting" })]
		public static void IvnentoryGui_Awake_Postfix(InventoryGui __instance)
		{
			//IL_0098: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			Transform obj = ((Component)__instance.m_player).transform.Find("Jewelcrafting Synergy");
			GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
			Transform obj2 = ((Component)__instance.m_player).transform.Find("TrashDivider/DividerLeft/Line");
			GameObject val2 = ((obj2 != null) ? ((Component)obj2).gameObject : null);
			Transform obj3 = ((Component)__instance.m_player).transform.Find("StandardDivider/Center");
			GameObject val3 = ((obj3 != null) ? ((Component)obj3).gameObject : null);
			Transform obj4 = ((Component)__instance.m_player).transform.Find("StandardDivider/Left");
			GameObject val4 = ((obj4 != null) ? ((Component)obj4).gameObject : null);
			if ((Object)(object)val != (Object)null)
			{
				RectTransform obj5 = val.RectTransform();
				obj5.anchoredPosition += new Vector2(80f, 78f);
				Image componentInChildren = val.GetComponentInChildren<Image>();
				RectTransform val5 = ((Component)(object)componentInChildren).RectTransform();
				((Graphic)componentInChildren).color = Color.white;
				val5.sizeDelta = new Vector2(25f, 25f);
			}
			if ((Object)(object)val2 != (Object)null)
			{
				RectTransform obj6 = val2.RectTransform();
				obj6.anchoredPosition = new Vector2(36f, 0f);
				obj6.sizeDelta = new Vector2(-80f, 2f);
			}
			if ((Object)(object)val3 != (Object)null)
			{
				RectTransform obj7 = val3.RectTransform();
				obj7.anchoredPosition = new Vector2(75f, 0f);
				obj7.sizeDelta = new Vector2(-80f, 2f);
			}
			if ((Object)(object)val4 != (Object)null)
			{
				val4.RectTransform().anchoredPosition = new Vector2(72f, 0f);
			}
		}

		public static IEnumerable<CodeInstruction> DisplaySynergyView_Awake_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> instrs = instructions.ToList();
			TranspilerHelpers th = new TranspilerHelpers();
			int i = 0;
			while (i < instrs.Count)
			{
				if (i > 0 && instrs[i].opcode == OpCodes.Ldstr && instrs[i].operand.Equals("ac_text"))
				{
					yield return th.LogMessage(new CodeInstruction(OpCodes.Ldstr, (object)"Text"));
				}
				else
				{
					yield return th.LogMessage(instrs[i]);
				}
				int num = i + 1;
				i = num;
			}
		}
	}
	public static class SearsCatalog
	{
		public static Assembly SearsCatalogType;

		public static Type HudPatch;

		[HarmonyPriority(0)]
		public static void AwakePostfix_Patch(ref Hud __instance)
		{
			//IL_0018: 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_0050: 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)
			((Transform)((Component)(object)__instance.m_pieceListRoot).RectTransform()).localPosition = new Vector3(((Transform)((Component)(object)__instance.m_pieceListRoot).RectTransform()).localPosition.x + 3f, ((Transform)((Component)(object)__instance.m_pieceListRoot).RectTransform()).localPosition.y - 3f, ((Transform)((Component)(object)__instance.m_pieceListRoot).RectTransform()).localPosition.z);
		}
	}
}