Decompiled source of MarsarahTweaks v1.3.2

MarsarahTweaks.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using MarsarahTweaks.Managers;
using MarsarahTweaks.Patches.Features;
using MarsarahTweaks.Patches.Grind;
using MarsarahTweaks.Patches.QOL;
using MarsarahTweaks.Patches.UI;
using Microsoft.CodeAnalysis;
using ServerSync;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MarsarahTweaks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MarsarahTweaks")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("831fc141-e3fa-4e67-9d2f-5e56cf6f3935")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MarsarahTweaks
{
	[BepInPlugin("Marsarah.MarsarahTweaks", "MarsarahTweaks", "1.3.2")]
	public class MarsarahTweaks : BaseUnityPlugin
	{
		internal const string ModName = "MarsarahTweaks";

		internal const string ModVersion = "1.3.2";

		internal const string Author = "Marsarah";

		public const string ModGUID = "Marsarah.MarsarahTweaks";

		private static readonly bool showLogs;

		private readonly Harmony harmony = new Harmony("Marsarah.MarsarahTweaks");

		private void Awake()
		{
			ConfigManager.Init(((BaseUnityPlugin)this).Config);
			UISmartBiome.UpdateBiomeWeights();
			harmony.PatchAll();
		}

		private void Update()
		{
			UIController.UpdateUIDisplay();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		public static void LogInfo(string log, bool header = false, bool footer = false)
		{
			if (showLogs)
			{
				if (header)
				{
					Debug.Log((object)"===================================================");
				}
				Debug.Log((object)("[Marsarah Tweaks] : " + log));
				if (footer)
				{
					Debug.Log((object)"===================================================");
				}
			}
		}

		public static void LogWarn(string log, bool header = false, bool footer = false)
		{
			if (showLogs)
			{
				if (header)
				{
					Debug.Log((object)"===================================================");
				}
				Debug.LogWarning((object)("[Marsarah Tweaks] : " + log));
				if (footer)
				{
					Debug.Log((object)"===================================================");
				}
			}
		}

		public static void LogError(string log, bool header = false, bool footer = false)
		{
			if (showLogs)
			{
				if (header)
				{
					Debug.Log((object)"===================================================");
				}
				Debug.LogError((object)("[Marsarah Tweaks] : " + log));
				if (footer)
				{
					Debug.Log((object)"===================================================");
				}
			}
		}
	}
}
namespace MarsarahTweaks.Patches
{
	public static class GlobalKeyChecker
	{
		[HarmonyPatch(typeof(ZoneSystem), "Update")]
		private class BossStatusUpdate_Patch
		{
			private static void Postfix(ZoneSystem __instance)
			{
				UpdateDefeatedStates(__instance);
				EikthyrDefeated = CheckGlobalKey("defeated_eikthyr");
				ElderDefeated = CheckGlobalKey("defeated_gdking");
				BonemassDefeated = CheckGlobalKey("defeated_bonemass");
				ModerDefeated = CheckGlobalKey("defeated_dragon");
				YagluthDefeated = CheckGlobalKey("defeated_goblinking");
				QueenDefeated = CheckGlobalKey("defeated_queen");
				FaderDefeated = CheckGlobalKey("defeated_fader");
				BrennaDefeated = CheckGlobalKey("hildir1");
				GeirrhafaDefeated = CheckGlobalKey("hildir2");
				ThungrNZilDefeated = CheckGlobalKey("hildir3");
			}
		}

		public static bool EikthyrDefeated = false;

		public static bool ElderDefeated = false;

		public static bool BonemassDefeated = false;

		public static bool ModerDefeated = false;

		public static bool YagluthDefeated = false;

		public static bool QueenDefeated = false;

		public static bool FaderDefeated = false;

		public static bool BrennaDefeated = false;

		public static bool GeirrhafaDefeated = false;

		public static bool ThungrNZilDefeated = false;

		private static readonly Dictionary<string, bool> globalKeyStates = new Dictionary<string, bool>
		{
			{ "defeated_eikthyr", false },
			{ "defeated_gdking", false },
			{ "defeated_bonemass", false },
			{ "defeated_dragon", false },
			{ "defeated_goblinking", false },
			{ "defeated_queen", false },
			{ "defeated_fader", false },
			{ "hildir1", false },
			{ "hildir2", false },
			{ "hildir3", false }
		};

		private static readonly Dictionary<string, string> bossToGlobalKey = new Dictionary<string, string>
		{
			{ "Eikthyr", "defeated_eikthyr" },
			{ "The Elder", "defeated_gdking" },
			{ "Bonemass", "defeated_bonemass" },
			{ "Moder", "defeated_dragon" },
			{ "Yagluth", "defeated_goblinking" },
			{ "The Queen", "defeated_queen" },
			{ "Fader", "defeated_fader" },
			{ "Brenna", "hildir1" },
			{ "Geirrhafa", "hildir2" },
			{ "ThungrNZil", "hildir3" }
		};

		private static void UpdateDefeatedStates(ZoneSystem zoneSystem)
		{
			List<string> globalKeys = zoneSystem.GetGlobalKeys();
			foreach (string item in globalKeyStates.Keys.ToList())
			{
				bool flag = globalKeys.Contains(item);
				if (globalKeyStates[item] != flag)
				{
					globalKeyStates[item] = flag;
				}
			}
		}

		private static bool CheckGlobalKey(string globalKey)
		{
			return globalKeyStates.ContainsKey(globalKey) && globalKeyStates[globalKey];
		}

		public static bool IsBossDefeated(string boss)
		{
			if (bossToGlobalKey.TryGetValue(boss, out var value))
			{
				return CheckGlobalKey(value);
			}
			MarsarahTweaks.LogWarn("[Warning] IsBossDefeated called with unknown boss: " + boss);
			return false;
		}
	}
}
namespace MarsarahTweaks.Patches.UI
{
	internal class UIAshlandsHeatLevel : UIController
	{
		[HarmonyPatch(typeof(Character), "UpdateLava")]
		public class GetHeatLevel_Patch
		{
			private static void Postfix(Character __instance, ref float ___m_lavaHeatLevel)
			{
				if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && ConfigManager.ShowHeatLevelInAshlands.Value && UIController.showUI && __instance is Player)
				{
					heatThreshold = __instance.m_heatLevelFirstDamageThreshold;
					currentHeat = ___m_lavaHeatLevel;
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Update")]
		private static class HeatLevelHUDUpdate_Patch
		{
			private static Image heatBarFill;

			private static Image heatBarBGImage;

			private static GameObject UIHeatBarArea;

			private static Text heatBarText;

			private static TextMeshProUGUI heatBarEmojiTMP;

			private static void Postfix(Hud __instance)
			{
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Invalid comparison between Unknown and I4
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b5: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_019c: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0215: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				if (ConfigManager.ShowHeatLevelInAshlands.Value)
				{
					CreateUI(__instance);
					if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !((Object)(object)heatBarFill != (Object)null) || !(heatThreshold > 0f))
					{
						return;
					}
					if ((int)Player.m_localPlayer.GetCurrentBiome() != 32)
					{
						if ((Object)(object)UIHeatBarArea != (Object)null && UIHeatBarArea.activeSelf)
						{
							UIHeatBarArea.SetActive(false);
						}
						return;
					}
					bool flag = !IsUIHidden() && !IsLoadScreenActive(__instance);
					if (UIHeatBarArea.activeSelf != flag)
					{
						UIHeatBarArea.SetActive(flag);
					}
					heatBarFill.fillAmount = Mathf.Clamp01(currentHeat / heatThreshold);
					if ((Object)(object)heatBarText != (Object)null)
					{
						float num = Mathf.Clamp01(currentHeat / heatThreshold) * 100f;
						heatBarText.text = $"{num:0}%";
					}
					float fillAmount = heatBarFill.fillAmount;
					Color yellow = Color.yellow;
					Color val = default(Color);
					((Color)(ref val))..ctor(1f, 0.549019f, 0f);
					Color red = Color.red;
					Color color = ((fillAmount < 0.5f) ? Color.Lerp(yellow, val, fillAmount * 2f) : Color.Lerp(val, red, (fillAmount - 0.5f) * 2f));
					if (fillAmount > 0.8f)
					{
						float a = 0.6f + 0.4f * Mathf.Sin(Time.time * 4f);
						color.a = a;
					}
					else
					{
						color.a = 0.8f;
					}
					((Graphic)heatBarFill).color = color;
					if (heatBarFill.fillAmount == 0f)
					{
						if ((Object)(object)heatBarFill != (Object)null)
						{
							((Behaviour)heatBarFill).enabled = false;
						}
						if ((Object)(object)heatBarBGImage != (Object)null)
						{
							((Behaviour)heatBarBGImage).enabled = false;
						}
						if ((Object)(object)heatBarText != (Object)null)
						{
							((Behaviour)heatBarText).enabled = false;
						}
						if ((Object)(object)heatBarEmojiTMP != (Object)null)
						{
							((Behaviour)heatBarEmojiTMP).enabled = false;
							((TMP_Text)heatBarEmojiTMP).text = "";
						}
					}
					else
					{
						if ((Object)(object)heatBarFill != (Object)null)
						{
							((Behaviour)heatBarFill).enabled = UIController.showUI;
						}
						if ((Object)(object)heatBarBGImage != (Object)null)
						{
							((Behaviour)heatBarBGImage).enabled = UIController.showUI;
						}
						if ((Object)(object)heatBarText != (Object)null)
						{
							((Behaviour)heatBarText).enabled = UIController.showUI;
						}
						if ((Object)(object)heatBarEmojiTMP != (Object)null)
						{
							((Behaviour)heatBarEmojiTMP).enabled = UIController.showUI;
							((TMP_Text)heatBarEmojiTMP).text = "\ud83d\udd25";
						}
					}
				}
				else
				{
					if ((Object)(object)heatBarFill != (Object)null)
					{
						((Behaviour)heatBarFill).enabled = false;
					}
					if ((Object)(object)heatBarBGImage != (Object)null)
					{
						((Behaviour)heatBarBGImage).enabled = false;
					}
					if ((Object)(object)heatBarText != (Object)null)
					{
						((Behaviour)heatBarText).enabled = false;
					}
					if ((Object)(object)heatBarEmojiTMP != (Object)null)
					{
						((Behaviour)heatBarEmojiTMP).enabled = false;
					}
				}
			}

			private static void CreateUI(Hud hud)
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Expected O, but got Unknown
				//IL_008f: 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_00bd: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Expected O, but got Unknown
				//IL_0138: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0183: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Expected O, but got Unknown
				//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0210: Unknown result type (might be due to invalid IL or missing references)
				//IL_029d: Unknown result type (might be due to invalid IL or missing references)
				//IL_02af: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)UIHeatBarArea != (Object)null))
				{
					Vector2 sizeDelta = default(Vector2);
					((Vector2)(ref sizeDelta))..ctor(200f, 25f);
					int fontSize = 13;
					int fontSize2 = 10;
					string fontName = "AveriaSansLibre-Bold";
					string fontName2 = "NotoEmoji-Regular";
					UIHeatBarArea = new GameObject("HeatBar");
					UIHeatBarArea.layer = 5;
					UIHeatBarArea.transform.SetParent(hud.m_rootObject.transform.parent, false);
					RectTransform val = UIHeatBarArea.AddComponent<RectTransform>();
					val.anchorMin = new Vector2(0.5f, 0.5f);
					val.anchorMax = new Vector2(0.5f, 0.5f);
					val.pivot = new Vector2(0.5f, 0.5f);
					val.anchoredPosition = new Vector2(0f, 350f);
					val.sizeDelta = sizeDelta;
					UIHeatBarArea.transform.localScale = Vector3.one;
					GameObject val2 = new GameObject("HeatBarBackground");
					val2.transform.SetParent(UIHeatBarArea.transform, false);
					heatBarBGImage = val2.AddComponent<Image>();
					RectTransform component = val2.GetComponent<RectTransform>();
					component.anchorMin = Vector2.zero;
					component.anchorMax = Vector2.one;
					component.offsetMin = Vector2.zero;
					component.offsetMax = Vector2.zero;
					((Graphic)heatBarBGImage).color = new Color(0f, 0f, 0f, 0.4f);
					((Behaviour)heatBarBGImage).enabled = false;
					GameObject val3 = new GameObject("HeatBarFill");
					val3.transform.SetParent(UIHeatBarArea.transform, false);
					heatBarFill = val3.AddComponent<Image>();
					RectTransform component2 = val3.GetComponent<RectTransform>();
					component2.anchorMin = Vector2.zero;
					component2.anchorMax = Vector2.one;
					component2.offsetMin = new Vector2(3f, 3f);
					component2.offsetMax = new Vector2(-3f, -3f);
					Sprite sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => ((Object)s).name == "bar_monster_hp_5"));
					heatBarFill.sprite = sprite;
					heatBarFill.type = (Type)3;
					heatBarFill.fillMethod = (FillMethod)0;
					heatBarFill.fillOrigin = 0;
					heatBarFill.fillAmount = 0f;
					((Behaviour)heatBarFill).enabled = false;
					heatBarText = UIController.CreateTextObject("HeatText", UIHeatBarArea, Color.white, fontName, fontSize, (TextAnchor)4, new Vector2(0f, 0f), sizeDelta);
					heatBarEmojiTMP = UIController.CreateTMPTextObject("HeatEmojiTMP", UIHeatBarArea, Color.red, fontName2, fontSize2, (TextAlignmentOptions)4100, new Vector2(-2f, 0f), sizeDelta);
				}
			}

			private static Sprite GenerateWhiteSprite()
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Expected O, but got Unknown
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				Texture2D val = new Texture2D(1, 1);
				val.SetPixel(0, 0, Color.white);
				val.Apply();
				return Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f));
			}

			private static bool IsLoadScreenActive(Hud hud)
			{
				return Object.op_Implicit((Object)(object)Hud.instance) && Object.op_Implicit((Object)(object)hud.m_loadingScreen) && ((Component)hud.m_loadingScreen).gameObject.activeSelf;
			}

			private static bool IsUIHidden()
			{
				return Hud.IsUserHidden();
			}
		}

		private static float heatThreshold;

		private static float currentHeat;
	}
	internal class UIBoatSpeed : UIController
	{
		[HarmonyPatch(typeof(Ship), "GetSpeed")]
		private class ShowBoatSpeed_Patch
		{
			private static void Prefix(Ship __instance, ref Rigidbody ___m_body)
			{
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && ConfigManager.ShowBoatSpeed.Value)
				{
					if (Object.op_Implicit((Object)(object)__instance) && __instance.HasPlayerOnboard())
					{
						boatSpeed = Vector3.Dot(___m_body.velocity, ((Component)__instance).transform.forward);
					}
					if (Traverse.Create((object)__instance).Method("HaveControllingPlayer", Array.Empty<object>()).GetValue<bool>())
					{
						showBoatSpeedUI = true;
					}
					else
					{
						showBoatSpeedUI = false;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Update")]
		private static class BoatSpeedHUDUpdate_Patch
		{
			private static void Postfix(Hud __instance)
			{
				//IL_017a: 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)
				if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				if (ConfigManager.ShowBoatSpeed.Value)
				{
					CreateTextBasedUI(__instance);
					CreateSymbolBasedUI(__instance);
					if (!ConfigManager.UseSymbolsForUI.Value)
					{
						GameObject uIBoatArea = UIBoatArea;
						if (uIBoatArea != null)
						{
							uIBoatArea.SetActive(showBoatSpeedUI && UIController.showUI);
						}
						GameObject uIBoatArea2 = UIBoatArea2;
						if (uIBoatArea2 != null)
						{
							uIBoatArea2.SetActive(false);
						}
						if (showBoatSpeedUI && UIController.showUI)
						{
							((Graphic)UIBoatText).color = GetColorFromSpeed(boatSpeed);
							UIBoatText.text = ((boatSpeed > 0f) ? boatSpeed.ToString("0.00") : ("R " + Math.Abs(boatSpeed).ToString("0.00")));
							UIBoatTextTitle.text = "Boat speed";
						}
					}
					else
					{
						GameObject uIBoatArea3 = UIBoatArea;
						if (uIBoatArea3 != null)
						{
							uIBoatArea3.SetActive(false);
						}
						GameObject uIBoatArea4 = UIBoatArea2;
						if (uIBoatArea4 != null)
						{
							uIBoatArea4.SetActive(showBoatSpeedUI && UIController.showUI);
						}
						if (showBoatSpeedUI && UIController.showUI)
						{
							((Graphic)UIBoatText2).color = GetColorFromSpeed(boatSpeed);
							UIBoatText2.text = ((boatSpeed > 0f) ? boatSpeed.ToString("0.00") : ("R " + Math.Abs(boatSpeed).ToString("0.00")));
							((TMP_Text)UIBoatEmojiTMP).text = "⛵";
						}
					}
				}
				else
				{
					CreateTextBasedUI(__instance);
					CreateSymbolBasedUI(__instance);
					GameObject uIBoatArea5 = UIBoatArea;
					if (uIBoatArea5 != null)
					{
						uIBoatArea5.SetActive(false);
					}
					GameObject uIBoatArea6 = UIBoatArea2;
					if (uIBoatArea6 != null)
					{
						uIBoatArea6.SetActive(false);
					}
				}
			}

			private static void CreateTextBasedUI(Hud hud)
			{
				//IL_0061: 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_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Expected O, but got Unknown
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_020c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0211: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)UIBoatArea != (Object)null) || !((Object)(object)UIBoatText != (Object)null) || !((Object)(object)UIBoatTextTitle != (Object)null))
				{
					int fontSize = 16;
					string fontName = "AveriaSansLibre-Bold";
					Vector2 val = default(Vector2);
					((Vector2)(ref val))..ctor(155f, 30f);
					Vector2 sizeDelta = default(Vector2);
					if (!ConfigManager.UseSymbolsForUI.Value)
					{
						sizeDelta = val;
					}
					else
					{
						((Vector2)(ref sizeDelta))..ctor(155f, 30f);
					}
					UIBoatArea = new GameObject("BoatArea");
					UIBoatArea.layer = 5;
					UIBoatArea.transform.SetParent(((Component)hud.m_healthPanel).transform);
					RectTransform val2 = UIBoatArea.AddComponent<RectTransform>();
					val2.anchorMin = new Vector2(1f, 1f);
					val2.anchorMax = new Vector2(1f, 1f);
					val2.anchoredPosition = new Vector2((ConfigManager.ShowInventoryWeightAndSlots.Value && ConfigManager.ShowEnemyDetector.Value) ? 203f : ((ConfigManager.ShowInventoryWeightAndSlots.Value || ConfigManager.ShowEnemyDetector.Value) ? 100f : (-40f)), -230f);
					val2.sizeDelta = sizeDelta;
					UIBoatArea.transform.localScale = Vector3.one;
					Sprite sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite tempSprite) => ((Object)tempSprite).name == "InputFieldBackground"));
					Image val3 = UIBoatArea.AddComponent<Image>();
					((Graphic)val3).color = new Color(0f, 0f, 0f, 0.4f);
					val3.sprite = sprite;
					val3.type = (Type)1;
					UIBoatTextTitle = UIController.CreateTextObject("BoatTextTitle", UIBoatArea, Color.white, fontName, fontSize, (TextAnchor)4, new Vector2(-25f, 0f), val);
					UIBoatText = UIController.CreateTextObject("BoatText", UIBoatArea, Color.white, fontName, fontSize, (TextAnchor)4, new Vector2(45f, 0f), sizeDelta);
				}
			}

			private static void CreateSymbolBasedUI(Hud hud)
			{
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Expected O, but got Unknown
				//IL_0106: 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)
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: 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_01a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)UIBoatArea2 != (Object)null) || !((Object)(object)UIBoatText2 != (Object)null) || !((Object)(object)UIBoatEmojiTMP != (Object)null))
				{
					int num = 16;
					string fontName = "AveriaSansLibre-Bold";
					string fontName2 = "NotoEmoji-Regular";
					Vector2 sizeDelta = default(Vector2);
					((Vector2)(ref sizeDelta))..ctor(80f, 30f);
					float num2 = (Game.m_noMap ? (-145f) : (-283f));
					float num3 = -225f;
					if (AppDomain.CurrentDomain.GetAssemblies().Any((Assembly a) => a.GetName().Name == "MinimalStatusEffects"))
					{
						num2 = -360f;
						num3 = -25f;
					}
					UIBoatArea2 = new GameObject("BoatArea2");
					UIBoatArea2.layer = 5;
					UIBoatArea2.transform.SetParent(hud.m_rootObject.transform);
					RectTransform val = UIBoatArea2.AddComponent<RectTransform>();
					val.anchorMin = new Vector2(1f, 1f);
					val.anchorMax = new Vector2(1f, 1f);
					val.anchoredPosition = new Vector2(num2, num3);
					val.sizeDelta = sizeDelta;
					UIBoatArea2.transform.localScale = Vector3.one;
					UIBoatText2 = UIController.CreateTextObject("BoatText2", UIBoatArea2, Color.white, fontName, num, (TextAnchor)5, new Vector2(-4f, 0f), sizeDelta);
					UIBoatEmojiTMP = UIController.CreateTMPTextObject("BoatEmojiTMP", UIBoatArea2, Color.white, fontName2, num + 4, (TextAlignmentOptions)4097, new Vector2(4f, 0f), sizeDelta);
				}
			}

			private static Color GetColorFromSpeed(float speed)
			{
				//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_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_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				if (speed < 2.5f)
				{
					return Color.red;
				}
				if (speed < 5f)
				{
					return new Color(1f, 0.549019f, 0f);
				}
				if (speed < 7.5f)
				{
					return Color.yellow;
				}
				return Color.green;
			}
		}

		private static float boatSpeed;

		private static bool showBoatSpeedUI;

		internal static GameObject UIBoatArea;

		private static Text UIBoatText;

		private static Text UIBoatTextTitle;

		internal static GameObject UIBoatArea2;

		private static Text UIBoatText2;

		private static TextMeshProUGUI UIBoatEmojiTMP;
	}
	internal class UIBossPowerExpiration
	{
		[HarmonyPatch(typeof(StatusEffect), "Stop")]
		public class StatusEffectStopPatch
		{
			public static void Postfix(StatusEffect __instance)
			{
				if (!ConfigManager.ShowBossExpirationMessage.Value)
				{
					return;
				}
				Character character = __instance.m_character;
				if (!((Object)(object)character == (Object)null) && character.IsPlayer() && character.IsOwner())
				{
					string name = ((Object)__instance).name;
					if (name.Contains("GP_"))
					{
						string text = Localization.instance.Localize(__instance.m_name);
						character.Message((MessageType)2, text + " Power Expired", 0, (Sprite)null);
					}
				}
			}
		}
	}
	internal class UIController
	{
		public static bool showUI = true;

		public static bool showPlayerList = true;

		public static void UpdateUIDisplay()
		{
			if (Input.GetKeyDown((KeyCode)277))
			{
				showUI = !showUI;
			}
			if (Input.GetKeyDown((KeyCode)278))
			{
				showPlayerList = !showPlayerList;
			}
		}

		public static Text CreateTextObject(string name, GameObject parent, Color textColor, string fontName, int fontSize, TextAnchor alignment, Vector2 position, Vector2 sizeDelta)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.layer = 5;
			val.transform.SetParent(parent.transform);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchoredPosition = position;
			val2.sizeDelta = sizeDelta;
			((Transform)val2).localScale = Vector3.one;
			Text val3 = val.AddComponent<Text>();
			((Graphic)val3).color = textColor;
			val3.font = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name == fontName));
			val3.fontSize = fontSize;
			val3.alignment = alignment;
			Outline val4 = val.AddComponent<Outline>();
			((Shadow)val4).effectColor = Color.black;
			((Shadow)val4).effectDistance = new Vector2(1f, -1f);
			((Shadow)val4).useGraphicAlpha = true;
			((MonoBehaviour)val4).useGUILayout = true;
			return val3;
		}

		public static TextMeshProUGUI CreateTMPTextObject(string name, GameObject parent, Color textColor, string fontName, int fontSize, TextAlignmentOptions alignment, Vector2 position, Vector2 sizeDelta)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.layer = 5;
			val.transform.SetParent(parent.transform, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchoredPosition = position;
			val2.sizeDelta = sizeDelta;
			((Transform)val2).localScale = Vector3.one;
			TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>();
			((Graphic)val3).color = textColor;
			((TMP_Text)val3).font = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == fontName));
			((TMP_Text)val3).fontSize = fontSize;
			((TMP_Text)val3).alignment = alignment;
			((TMP_Text)val3).text = "";
			if ((Object)(object)((TMP_Text)val3).font != (Object)null && (Object)(object)((TMP_Text)val3).fontMaterial != (Object)null)
			{
				((TMP_Text)val3).fontMaterial = new Material(((TMP_Text)val3).fontMaterial);
				if (((TMP_Text)val3).fontMaterial.HasProperty(ShaderUtilities.ID_OutlineWidth) && ((TMP_Text)val3).fontMaterial.HasProperty(ShaderUtilities.ID_OutlineColor))
				{
					((TMP_Text)val3).fontMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.125f);
					((TMP_Text)val3).fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, Color.black);
				}
			}
			return val3;
		}

		public static void UpdateUIPositions()
		{
			//IL_0190: 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_00b3: 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)
			if (!ConfigManager.UseSymbolsForUI.Value)
			{
				float num = -45f;
				float num2 = -230f;
				bool flag = (Object)(object)UIInventoryWeightAndSlots.UIInventoryArea != (Object)null && ConfigManager.ShowInventoryWeightAndSlots.Value;
				bool flag2 = (Object)(object)UIEnemyDetector.UIEnemyArea != (Object)null && ConfigManager.ShowEnemyDetector.Value;
				bool flag3 = (Object)(object)UIBoatSpeed.UIBoatArea != (Object)null && ConfigManager.ShowBoatSpeed.Value;
				if (flag)
				{
					num += 115f;
					if (!flag2 && flag3)
					{
						num += 30f;
					}
				}
				if (flag2)
				{
					UIEnemyDetector.UIEnemyArea.GetComponent<RectTransform>().anchoredPosition = new Vector2(num, num2);
					num += 133f;
				}
				if (flag3)
				{
					UIBoatSpeed.UIBoatArea.GetComponent<RectTransform>().anchoredPosition = new Vector2(num, num2);
				}
			}
			else
			{
				float num3 = -10f;
				float num4 = -230f;
				bool flag4 = (Object)(object)UIInventoryWeightAndSlots.UIWeightBarArea != (Object)null && (Object)(object)UIInventoryWeightAndSlots.UISlotsArea != (Object)null && ConfigManager.ShowInventoryWeightAndSlots.Value;
				bool flag5 = (Object)(object)UIEnemyDetector.UIEnemyArea2 != (Object)null && (Object)(object)UIEnemyDetector.UIFriendlyArea != (Object)null && ConfigManager.ShowEnemyDetector.Value;
				if (flag4)
				{
					num3 += 132f;
				}
				else if (flag5)
				{
					num3 -= 55f;
				}
				if (flag5)
				{
					UIEnemyDetector.UIEnemyArea2.GetComponent<RectTransform>().anchoredPosition = new Vector2(num3, num4);
					UIEnemyDetector.UIFriendlyArea.GetComponent<RectTransform>().anchoredPosition = new Vector2(num3 + 54f, num4);
				}
			}
		}
	}
	internal class UIEnemyDetector : UIController
	{
		[HarmonyPatch(typeof(Player), "Update")]
		private class EnemyDetector_PlayerPatch
		{
			private static void Prefix(ref Player ___m_localPlayer)
			{
				//IL_005a: 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)
				//IL_008e: Invalid comparison between Unknown and I4
				if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)___m_localPlayer == (Object)null || !ConfigManager.ShowEnemyDetector.Value)
				{
					return;
				}
				int num = 0;
				int num2 = 0;
				List<Character> list = new List<Character>();
				Character.GetCharactersInRange(((Component)___m_localPlayer).transform.position, 30f, list);
				foreach (Character item in list)
				{
					if ((int)item.GetFaction() == 10 && (Object)(object)item.GetBaseAI() != (Object)null && !item.GetBaseAI().IsAggravated())
					{
						num2++;
					}
					if (item.m_name.ToString() == "Human" || item.m_name.ToString() == "$enemy_deer" || item.m_name.ToString() == "$enemy_hare" || item.m_name.ToString() == "$enemy_summonedroot" || item.IsTamed())
					{
						num++;
					}
				}
				numEnemies = list.Count - num - num2;
				numEnemiesPassive = num2;
			}
		}

		[HarmonyPatch(typeof(Hud), "Update")]
		private class EnemyDetector_HUDUpdatePatch
		{
			private static bool lastUseSymbolInsteadOfWords = ConfigManager.UseSymbolsForUI.Value;

			private static void Postfix(Hud __instance)
			{
				//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01aa: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0250: Unknown result type (might be due to invalid IL or missing references)
				//IL_0255: Unknown result type (might be due to invalid IL or missing references)
				//IL_025c: Unknown result type (might be due to invalid IL or missing references)
				//IL_027e: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				if (ConfigManager.ShowEnemyDetector.Value)
				{
					CreateTextBasedUI(__instance);
					CreateSymbolBasedUI(__instance);
					if (!ConfigManager.UseSymbolsForUI.Value)
					{
						GameObject uIEnemyArea = UIEnemyArea;
						if (uIEnemyArea != null)
						{
							uIEnemyArea.SetActive(UIController.showUI);
						}
						GameObject uIEnemyArea2 = UIEnemyArea2;
						if (uIEnemyArea2 != null)
						{
							uIEnemyArea2.SetActive(false);
						}
						GameObject uIFriendlyArea = UIFriendlyArea;
						if (uIFriendlyArea != null)
						{
							uIFriendlyArea.SetActive(false);
						}
						if (UIController.showUI)
						{
							((Graphic)UIEnemyText).color = GetColorFromNum(numEnemies);
							if (numEnemiesPassive > 0)
							{
								UIEnemyText.text = "Enemies " + numEnemies + " (" + numEnemiesPassive + ")";
							}
							else
							{
								UIEnemyText.text = "Enemies " + numEnemies;
							}
						}
						return;
					}
					GameObject uIEnemyArea3 = UIEnemyArea;
					if (uIEnemyArea3 != null)
					{
						uIEnemyArea3.SetActive(false);
					}
					GameObject uIEnemyArea4 = UIEnemyArea2;
					if (uIEnemyArea4 != null)
					{
						uIEnemyArea4.SetActive(UIController.showUI);
					}
					GameObject uIFriendlyArea2 = UIFriendlyArea;
					if (uIFriendlyArea2 != null)
					{
						uIFriendlyArea2.SetActive(UIController.showUI && numEnemiesPassive != 0);
					}
					if (UIController.showUI)
					{
						Color colorFromNum = GetColorFromNum(numEnemies);
						((Graphic)UIEnemyText2).color = colorFromNum;
						UIEnemyText2.text = numEnemies.ToString();
						((Graphic)UIEnemyEmojiTMP).color = colorFromNum;
						if (numEnemies == 0)
						{
							((TMP_Text)UIEnemyEmojiTMP).text = "\ud83d\udc41";
						}
						else if (numEnemies < 5)
						{
							((TMP_Text)UIEnemyEmojiTMP).text = "\ud83d\ude08";
						}
						else if (numEnemies < 7)
						{
							((TMP_Text)UIEnemyEmojiTMP).text = "\ud83d\udc7f";
						}
						else
						{
							((TMP_Text)UIEnemyEmojiTMP).text = "☠";
						}
						Color colorFromNum2 = GetColorFromNum(numEnemiesPassive);
						((Graphic)UIFriendlyText).color = colorFromNum2;
						UIFriendlyText.text = numEnemiesPassive.ToString();
						((Graphic)UIFriendlyEmojiTMP).color = colorFromNum2;
						((TMP_Text)UIFriendlyEmojiTMP).text = "\ud83e\uddd4\u200d";
					}
				}
				else
				{
					CreateTextBasedUI(__instance);
					CreateSymbolBasedUI(__instance);
					GameObject uIEnemyArea5 = UIEnemyArea;
					if (uIEnemyArea5 != null)
					{
						uIEnemyArea5.SetActive(false);
					}
					GameObject uIEnemyArea6 = UIEnemyArea2;
					if (uIEnemyArea6 != null)
					{
						uIEnemyArea6.SetActive(false);
					}
					GameObject uIFriendlyArea3 = UIFriendlyArea;
					if (uIFriendlyArea3 != null)
					{
						uIFriendlyArea3.SetActive(false);
					}
				}
			}

			private static void CreateTextBasedUI(Hud hud)
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Expected O, but got Unknown
				//IL_008d: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_017b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)UIEnemyArea != (Object)null) || !((Object)(object)UIEnemyText != (Object)null))
				{
					int fontSize = 16;
					string fontName = "AveriaSansLibre-Bold";
					Vector2 sizeDelta = default(Vector2);
					((Vector2)(ref sizeDelta))..ctor(100f, 30f);
					UIEnemyArea = new GameObject("EnemyArea");
					UIEnemyArea.layer = 5;
					UIEnemyArea.transform.SetParent(((Component)hud.m_healthPanel).transform);
					RectTransform val = UIEnemyArea.AddComponent<RectTransform>();
					val.anchorMin = new Vector2(1f, 1f);
					val.anchorMax = new Vector2(1f, 1f);
					val.anchoredPosition = new Vector2(ConfigManager.ShowInventoryWeightAndSlots.Value ? 70f : (-40f), -230f);
					val.sizeDelta = sizeDelta;
					UIEnemyArea.transform.localScale = Vector3.one;
					Sprite sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite tempSprite) => ((Object)tempSprite).name == "InputFieldBackground"));
					Image val2 = UIEnemyArea.AddComponent<Image>();
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.4f);
					val2.sprite = sprite;
					val2.type = (Type)1;
					UIEnemyText = UIController.CreateTextObject("EnemyText", UIEnemyArea, Color.white, fontName, fontSize, (TextAnchor)4, new Vector2(0f, 0f), sizeDelta);
				}
			}

			private static void CreateSymbolBasedUI(Hud hud)
			{
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Expected O, but got Unknown
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				//IL_0193: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ca: 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_01e4: Expected O, but got Unknown
				//IL_022b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0242: Unknown result type (might be due to invalid IL or missing references)
				//IL_0252: Unknown result type (might be due to invalid IL or missing references)
				//IL_025f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0270: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f0: 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)
				//IL_0307: Unknown result type (might be due to invalid IL or missing references)
				//IL_031c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0334: Unknown result type (might be due to invalid IL or missing references)
				//IL_0339: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)UIEnemyArea2 != (Object)null) || !((Object)(object)UIEnemyText2 != (Object)null) || !((Object)(object)UIEnemyEmojiTMP != (Object)null))
				{
					int num = 16;
					string fontName = "AveriaSansLibre-Bold";
					Vector2 sizeDelta = default(Vector2);
					((Vector2)(ref sizeDelta))..ctor(50f, 30f);
					float num2 = (ConfigManager.ShowInventoryWeightAndSlots.Value ? 122f : (-65f));
					float num3 = -230f;
					UIEnemyArea2 = new GameObject("EnemyArea2");
					UIEnemyArea2.layer = 5;
					UIEnemyArea2.transform.SetParent(((Component)hud.m_healthPanel).transform);
					RectTransform val = UIEnemyArea2.AddComponent<RectTransform>();
					val.anchorMin = new Vector2(1f, 1f);
					val.anchorMax = new Vector2(1f, 1f);
					val.anchoredPosition = new Vector2(num2, num3);
					val.sizeDelta = sizeDelta;
					UIEnemyArea2.transform.localScale = Vector3.one;
					Sprite sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite tempSprite) => ((Object)tempSprite).name == "InputFieldBackground"));
					Image val2 = UIEnemyArea2.AddComponent<Image>();
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.4f);
					val2.sprite = sprite;
					val2.type = (Type)1;
					UIEnemyText2 = UIController.CreateTextObject("EnemyText2", UIEnemyArea2, Color.white, fontName, num, (TextAnchor)5, new Vector2(-4f, 0f), sizeDelta);
					UIEnemyEmojiTMP = UIController.CreateTMPTextObject("EnemyEmojiTMP", UIEnemyArea2, Color.green, fontName, num + 4, (TextAlignmentOptions)4097, new Vector2(4f, 0f), sizeDelta);
					UIFriendlyArea = new GameObject("FriendlyArea");
					UIFriendlyArea.layer = 5;
					UIFriendlyArea.transform.SetParent(((Component)hud.m_healthPanel).transform);
					num2 += 54f;
					RectTransform val3 = UIFriendlyArea.AddComponent<RectTransform>();
					val3.anchorMin = new Vector2(1f, 1f);
					val3.anchorMax = new Vector2(1f, 1f);
					val3.anchoredPosition = new Vector2(num2, num3);
					val3.sizeDelta = sizeDelta;
					UIFriendlyArea.transform.localScale = Vector3.one;
					Sprite val4 = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite tempSprite) => ((Object)tempSprite).name == "InputFieldBackground"));
					Image val5 = UIFriendlyArea.AddComponent<Image>();
					((Graphic)val5).color = new Color(0f, 0f, 0f, 0.4f);
					val5.sprite = sprite;
					val5.type = (Type)1;
					UIFriendlyText = UIController.CreateTextObject("FriendlyText", UIFriendlyArea, Color.white, fontName, num, (TextAnchor)5, new Vector2(-4f, 0f), sizeDelta);
					UIFriendlyEmojiTMP = UIController.CreateTMPTextObject("FriendlyEmojiTMP", UIFriendlyArea, Color.green, fontName, num + 4, (TextAlignmentOptions)4097, new Vector2(4f, 0f), sizeDelta);
				}
			}

			private static Color GetColorFromNum(int num)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				if (num < 3)
				{
					return Color.green;
				}
				if (num < 5)
				{
					return Color.yellow;
				}
				if (num < 7)
				{
					return new Color(1f, 0.549019f, 0f);
				}
				return Color.red;
			}
		}

		public static int numEnemies;

		public static int numEnemiesPassive;

		internal static GameObject UIEnemyArea;

		private static Text UIEnemyText;

		internal static GameObject UIEnemyArea2;

		private static Text UIEnemyText2;

		private static TextMeshProUGUI UIEnemyEmojiTMP;

		internal static GameObject UIFriendlyArea;

		private static Text UIFriendlyText;

		private static TextMeshProUGUI UIFriendlyEmojiTMP;
	}
	internal class UIInventoryWeightAndSlots : UIController
	{
		[HarmonyPatch(typeof(Player), "Update")]
		private class InventoryWeightAndSlots_PlayerPatch
		{
			private static void Prefix(ref Player ___m_localPlayer)
			{
				if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && !((Object)(object)___m_localPlayer == (Object)null) && ConfigManager.ShowInventoryWeightAndSlots.Value)
				{
					currentWeight = ((Humanoid)___m_localPlayer).GetInventory().GetTotalWeight();
					maxWeight = ___m_localPlayer.GetMaxCarryWeight();
					freeSlots = ((Humanoid)___m_localPlayer).GetInventory().GetEmptySlots();
					freeSlotsPercent = ((Humanoid)___m_localPlayer).GetInventory().SlotsUsedPercentage();
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Update")]
		private class InventoryWeightAndSlots_HUDUpdatePatch
		{
			private static void Postfix(Hud __instance)
			{
				//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0282: Unknown result type (might be due to invalid IL or missing references)
				//IL_0287: Unknown result type (might be due to invalid IL or missing references)
				//IL_0274: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				if (ConfigManager.ShowInventoryWeightAndSlots.Value)
				{
					CreateTextBasedUI(__instance);
					CreateSymbolBasedUI(__instance);
					if (!ConfigManager.UseSymbolsForUI.Value)
					{
						GameObject uIInventoryArea = UIInventoryArea;
						if (uIInventoryArea != null)
						{
							uIInventoryArea.SetActive(UIController.showUI);
						}
						GameObject uIWeightBarArea = UIWeightBarArea;
						if (uIWeightBarArea != null)
						{
							uIWeightBarArea.SetActive(false);
						}
						GameObject uIWeightBarEmojiArea = UIWeightBarEmojiArea;
						if (uIWeightBarEmojiArea != null)
						{
							uIWeightBarEmojiArea.SetActive(false);
						}
						GameObject uISlotsArea = UISlotsArea;
						if (uISlotsArea != null)
						{
							uISlotsArea.SetActive(false);
						}
						if (UIController.showUI)
						{
							float percent = currentWeight * 100f / maxWeight;
							((Graphic)UIWeightText).color = GetColorFromPercent(percent);
							UIWeightText.text = currentWeight.ToString("0.0") + "/" + maxWeight.ToString("0");
						}
						if (UIController.showUI)
						{
							((Graphic)UISlotText).color = GetColorFromPercent(freeSlotsPercent);
							UISlotText.text = "(" + freeSlots + ")";
						}
						return;
					}
					GameObject uIInventoryArea2 = UIInventoryArea;
					if (uIInventoryArea2 != null)
					{
						uIInventoryArea2.SetActive(false);
					}
					GameObject uIWeightBarArea2 = UIWeightBarArea;
					if (uIWeightBarArea2 != null)
					{
						uIWeightBarArea2.SetActive(UIController.showUI);
					}
					GameObject uIWeightBarEmojiArea2 = UIWeightBarEmojiArea;
					if (uIWeightBarEmojiArea2 != null)
					{
						uIWeightBarEmojiArea2.SetActive(UIController.showUI);
					}
					GameObject uISlotsArea2 = UISlotsArea;
					if (uISlotsArea2 != null)
					{
						uISlotsArea2.SetActive(UIController.showUI);
					}
					if (UIController.showUI)
					{
						weightBarFill.fillAmount = Mathf.Clamp01(currentWeight / maxWeight);
						float fillAmount = weightBarFill.fillAmount;
						Color colorBlendFromPercent = GetColorBlendFromPercent(fillAmount);
						((Graphic)weightBarFill).color = colorBlendFromPercent;
						if ((Object)(object)UIWeightBarText != (Object)null)
						{
							UIWeightBarText.text = currentWeight.ToString("0.0") + "/" + maxWeight.ToString("0");
						}
						if ((Object)(object)UIWeightBarEmojiTMP != (Object)null)
						{
							((TMP_Text)UIWeightBarEmojiTMP).text = "\ud83c\udfcb\ufe0f";
							((Graphic)UIWeightBarEmojiTMP).color = colorBlendFromPercent;
						}
						Color colorFromPercent = GetColorFromPercent(freeSlotsPercent);
						if ((Object)(object)UISlotsText2 != (Object)null)
						{
							((Graphic)UISlotsText2).color = colorFromPercent;
							UISlotsText2.text = freeSlots.ToString();
						}
						if ((Object)(object)UISlotsEmojiTMP != (Object)null)
						{
							((Graphic)UISlotsEmojiTMP).color = colorFromPercent;
							((TMP_Text)UISlotsEmojiTMP).text = "\ud83c\udf92";
						}
					}
				}
				else
				{
					CreateTextBasedUI(__instance);
					CreateSymbolBasedUI(__instance);
					GameObject uIInventoryArea3 = UIInventoryArea;
					if (uIInventoryArea3 != null)
					{
						uIInventoryArea3.SetActive(false);
					}
					GameObject uIWeightBarArea3 = UIWeightBarArea;
					if (uIWeightBarArea3 != null)
					{
						uIWeightBarArea3.SetActive(false);
					}
					GameObject uIWeightBarEmojiArea3 = UIWeightBarEmojiArea;
					if (uIWeightBarEmojiArea3 != null)
					{
						uIWeightBarEmojiArea3.SetActive(false);
					}
					GameObject uISlotsArea3 = UISlotsArea;
					if (uISlotsArea3 != null)
					{
						uISlotsArea3.SetActive(false);
					}
				}
			}

			private static void CreateTextBasedUI(Hud hud)
			{
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Expected O, but got Unknown
				//IL_009a: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: 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_0175: Unknown result type (might be due to invalid IL or missing references)
				//IL_017a: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)UIInventoryArea != (Object)null) || !((Object)(object)UIWeightText != (Object)null) || !((Object)(object)UISlotText != (Object)null))
				{
					int fontSize = 16;
					string fontName = "AveriaSansLibre-Bold";
					Vector2 sizeDelta = default(Vector2);
					((Vector2)(ref sizeDelta))..ctor(115f, 30f);
					UIInventoryArea = new GameObject("InventoryArea");
					UIInventoryArea.layer = 5;
					UIInventoryArea.transform.SetParent(((Component)hud.m_healthPanel).transform);
					RectTransform val = UIInventoryArea.AddComponent<RectTransform>();
					val.anchorMin = new Vector2(1f, 1f);
					val.anchorMax = new Vector2(1f, 1f);
					val.anchoredPosition = new Vector2(-45f, -230f);
					val.sizeDelta = sizeDelta;
					UIInventoryArea.transform.localScale = Vector3.one;
					Sprite sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite tempSprite) => ((Object)tempSprite).name == "InputFieldBackground"));
					Image val2 = UIInventoryArea.AddComponent<Image>();
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.4f);
					val2.sprite = sprite;
					val2.type = (Type)1;
					UIWeightText = UIController.CreateTextObject("WeightText", UIInventoryArea, Color.green, fontName, fontSize, (TextAnchor)3, new Vector2(5f, 0f), sizeDelta);
					UISlotText = UIController.CreateTextObject("SlotText", UIInventoryArea, Color.green, fontName, fontSize, (TextAnchor)5, new Vector2(-5f, 0f), sizeDelta);
				}
			}

			private static void CreateSymbolBasedUI(Hud hud)
			{
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Expected O, but got Unknown
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Expected O, but got Unknown
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: 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_0186: Expected O, but got Unknown
				//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_026c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0276: Expected O, but got Unknown
				//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0305: Unknown result type (might be due to invalid IL or missing references)
				//IL_0315: Unknown result type (might be due to invalid IL or missing references)
				//IL_031c: Expected O, but got Unknown
				//IL_0348: Unknown result type (might be due to invalid IL or missing references)
				//IL_0355: Unknown result type (might be due to invalid IL or missing references)
				//IL_0362: Unknown result type (might be due to invalid IL or missing references)
				//IL_036f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0390: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_0416: Unknown result type (might be due to invalid IL or missing references)
				//IL_0420: Expected O, but got Unknown
				//IL_045f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0476: Unknown result type (might be due to invalid IL or missing references)
				//IL_0487: Unknown result type (might be due to invalid IL or missing references)
				//IL_0494: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0526: Unknown result type (might be due to invalid IL or missing references)
				//IL_0538: Unknown result type (might be due to invalid IL or missing references)
				//IL_053d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0553: Unknown result type (might be due to invalid IL or missing references)
				//IL_056b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0570: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)UIWeightBarArea != (Object)null))
				{
					int num = 16;
					string fontName = "AveriaSansLibre-Bold";
					Vector2 sizeDelta = default(Vector2);
					((Vector2)(ref sizeDelta))..ctor(100f, 30f);
					Vector2 sizeDelta2 = default(Vector2);
					((Vector2)(ref sizeDelta2))..ctor(30f, 30f);
					float num2 = -10f;
					float num3 = -230f;
					UIWeightBarArea = new GameObject("WeightAreaBar");
					UIWeightBarArea.layer = 5;
					UIWeightBarArea.transform.SetParent(((Component)hud.m_healthPanel).transform);
					RectTransform val = UIWeightBarArea.AddComponent<RectTransform>();
					val.anchorMin = new Vector2(1f, 1f);
					val.anchorMax = new Vector2(1f, 1f);
					val.anchoredPosition = new Vector2(num2, num3);
					val.sizeDelta = sizeDelta;
					UIWeightBarArea.transform.localScale = Vector3.one;
					GameObject val2 = new GameObject("WeightBarBackground");
					val2.transform.SetParent(UIWeightBarArea.transform, false);
					Image val3 = val2.AddComponent<Image>();
					RectTransform component = val2.GetComponent<RectTransform>();
					component.anchorMin = Vector2.zero;
					component.anchorMax = Vector2.one;
					component.offsetMin = Vector2.zero;
					component.offsetMax = Vector2.zero;
					((Graphic)val3).color = new Color(0f, 0f, 0f, 0.4f);
					GameObject val4 = new GameObject("WeightBarFill");
					val4.transform.SetParent(UIWeightBarArea.transform, false);
					weightBarFill = val4.AddComponent<Image>();
					RectTransform component2 = val4.GetComponent<RectTransform>();
					component2.anchorMin = Vector2.zero;
					component2.anchorMax = Vector2.one;
					component2.offsetMin = new Vector2(3f, 3f);
					component2.offsetMax = new Vector2(-3f, -3f);
					Sprite sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => ((Object)s).name == "bar_monster_hp_5"));
					weightBarFill.sprite = sprite;
					weightBarFill.type = (Type)3;
					weightBarFill.fillMethod = (FillMethod)0;
					weightBarFill.fillOrigin = 0;
					weightBarFill.fillAmount = 0f;
					UIWeightBarEmojiArea = new GameObject("WeightAreaEmoji");
					UIWeightBarEmojiArea.layer = 5;
					UIWeightBarEmojiArea.transform.SetParent(((Component)hud.m_healthPanel).transform);
					num2 -= 65f;
					RectTransform val5 = UIWeightBarEmojiArea.AddComponent<RectTransform>();
					val5.anchorMin = new Vector2(1f, 1f);
					val5.anchorMax = new Vector2(1f, 1f);
					val5.anchoredPosition = new Vector2(num2, num3);
					val5.sizeDelta = sizeDelta2;
					UIWeightBarEmojiArea.transform.localScale = Vector3.one;
					GameObject val6 = new GameObject("WeightEmojiBackground");
					val6.transform.SetParent(UIWeightBarEmojiArea.transform, false);
					Image val7 = val6.AddComponent<Image>();
					RectTransform component3 = val6.GetComponent<RectTransform>();
					component3.anchorMin = Vector2.zero;
					component3.anchorMax = Vector2.one;
					component3.offsetMin = Vector2.zero;
					component3.offsetMax = Vector2.zero;
					((Graphic)val7).color = new Color(0f, 0f, 0f, 0.4f);
					UIWeightBarText = UIController.CreateTextObject("WeightText", UIWeightBarArea, Color.white, fontName, num, (TextAnchor)4, new Vector2(0f, 0f), sizeDelta);
					UIWeightBarEmojiTMP = UIController.CreateTMPTextObject("WeightEmojiTMP", UIWeightBarEmojiArea, Color.green, fontName, num + 4, (TextAlignmentOptions)4098, new Vector2(0f, 0f), sizeDelta);
					Vector2 sizeDelta3 = default(Vector2);
					((Vector2)(ref sizeDelta3))..ctor(50f, 30f);
					num2 = 68f;
					UISlotsArea = new GameObject("SlotsArea");
					UISlotsArea.layer = 5;
					UISlotsArea.transform.SetParent(((Component)hud.m_healthPanel).transform);
					RectTransform val8 = UISlotsArea.AddComponent<RectTransform>();
					val8.anchorMin = new Vector2(1f, 1f);
					val8.anchorMax = new Vector2(1f, 1f);
					val8.anchoredPosition = new Vector2(num2, num3);
					val8.sizeDelta = sizeDelta3;
					UISlotsArea.transform.localScale = Vector3.one;
					Sprite sprite2 = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite tempSprite) => ((Object)tempSprite).name == "InputFieldBackground"));
					Image val9 = UISlotsArea.AddComponent<Image>();
					((Graphic)val9).color = new Color(0f, 0f, 0f, 0.4f);
					val9.sprite = sprite2;
					val9.type = (Type)1;
					UISlotsText2 = UIController.CreateTextObject("slotsText", UISlotsArea, Color.white, fontName, num, (TextAnchor)5, new Vector2(-4f, 0f), sizeDelta3);
					UISlotsEmojiTMP = UIController.CreateTMPTextObject("SlotsEmojiTMP", UISlotsArea, Color.green, fontName, num + 4, (TextAlignmentOptions)4097, new Vector2(4f, 0f), sizeDelta3);
				}
			}

			private static Color GetColorFromPercent(float percent)
			{
				//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_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_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				if (percent < 33f)
				{
					return Color.green;
				}
				if (percent < 66f)
				{
					return Color.yellow;
				}
				if (percent < 100f)
				{
					return new Color(1f, 0.549019f, 0f);
				}
				return Color.red;
			}

			private static Color GetColorBlendFromPercent(float percent)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: 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_00a9: 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_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				Color green = Color.green;
				Color green2 = Color.green;
				Color yellow = Color.yellow;
				Color val = default(Color);
				((Color)(ref val))..ctor(1f, 0.549019f, 0f);
				Color red = Color.red;
				if (percent <= 0.33f)
				{
					return Color.Lerp(green, green2, percent / 0.33f);
				}
				if (percent <= 0.66f)
				{
					return Color.Lerp(green2, yellow, (percent - 0.33f) / 0.33f);
				}
				if (percent < 1f)
				{
					return Color.Lerp(yellow, val, (percent - 0.66f) / 0.34f);
				}
				return red;
			}
		}

		private static float currentWeight;

		private static float maxWeight;

		private static float freeSlots;

		private static float freeSlotsPercent;

		internal static GameObject UIInventoryArea;

		private static Text UIWeightText;

		private static Text UISlotText;

		internal static GameObject UIWeightBarArea;

		private static GameObject UIWeightBarEmojiArea;

		private static Image weightBarFill;

		private static Text UIWeightBarText;

		private static TextMeshProUGUI UIWeightBarEmojiTMP;

		internal static GameObject UISlotsArea;

		private static Text UISlotsText2;

		private static TextMeshProUGUI UISlotsEmojiTMP;
	}
	internal class UILoadscreenTips
	{
		[HarmonyPatch(typeof(Localization), "SetupLanguage")]
		private class LoadingTips_Patch
		{
			private static void Postfix(Localization __instance, string language)
			{
				if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && __instance != null && ConfigManager.MoreLoadingTipsEnabled.Value)
				{
					localizationLanguage = language;
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Awake")]
		private class Loadscreens_HUDAwakePatch
		{
			private static void Postfix(Hud __instance)
			{
				if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && !((Object)(object)__instance == (Object)null) && ConfigManager.MoreLoadingTipsEnabled.Value)
				{
					loadingTipString = loadingTipStrings[Random.Range(0, loadingTipStrings.Count)];
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "UpdateBlackScreen")]
		private class ExtraLoadingTipsUpdate_Patch
		{
			private static void Postfix(Hud __instance)
			{
				if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && !((Object)(object)__instance == (Object)null) && ConfigManager.MoreLoadingTipsEnabled.Value && localizationLanguage == "English")
				{
					__instance.m_loadingTip.text = loadingTipString;
				}
			}
		}

		private static string loadingTipString;

		private static string localizationLanguage;

		private static readonly List<string> loadingTipStrings = new List<string>
		{
			"Weapons and armor can be crafted and upgraded using Workbenches or Forges.", "Eating food increases your health and stamina pools. Try to balance your three food slots accordingly.", "Crafting stations can be upgraded by building extenstions in their proximity.", "There are four principal crafting types: woodworking, masonry, smithing, and cooking.", "Enemies won't spawn near player built structures, such as crafting tables and camp fires.", "Sitting is the safest way to travel while on a boat.", "Upon your arrival in Valheim, try to find stones and branches on the ground to build your first weapon.", "Venturing outside at night is more dangerous. Be prepared if you plan to go out during that time.", "Hunting deer with a ranged weapon provides a good source of meat and skin.", "Build a rudimentary shelter as soon as possible, to refuge during your first nights. It can be used as a temporary home until you find a good spot for a better one.",
			"Different enemies are resistant to different damage types. If you see grey damage indicators when attacking, try changing the weapon.", "Claiming a bed after building it will set your spawn point to its location when dying.", "Attacking with knives and bows while sneaking confers a large damage bonus.", "Birds are a good source of feathers. They will stay close to the ground while the weather is bad.", "Weapons, armor, and tools can be repaired for free at a Workbench or Forge by interacting with the hammer icon while crafting.", "Some resources require better tools to harvest them.", "Being rested helps to regenerate stamina and health faster.", "Yellow damage numbers indicate a weakness, grey numbers indicate a resistance", "Use the hoe in combination with the pickaxe to flatten the ground. This will make it much easier to construct buildings.", "Build a cart to haul heavy goods over longer distances. Carts cannot go through portals.",
			"Boats are controlled by interacting with the steering oar.", "Defeating a Forsaken will drop items that will give you a general idea of what to do next.", "Cooking meat over a fire or eating fruit is a good way to get fed. Later on, they can be cooked using a cauldron.", "You can filter map pins by type by right clicking on them. (DPad Right)", "If no arrow has been manually selected when using a bow, arrows are automatically selected in ascending order beginning from the leftmost column and going right.", "Build a Fermenter to craft different potions from base meads. The right potion used at the right time and place can be the difference between life and death.", "Killing bee nests can provide the means to make your own honey.", "The more comfort items are installed in your home (e.g., fire, rugs, furniture, etc), the longer the rested bonus will be.", "When fighting a Forsaken, make sure you bring your best gear, food, and potions.", "All build pieces require a certain crafting station nearby (e.g., Workbench, Forge, Stonecutter). If you want to build outside their range, either move them closer or build new ones.",
			"Building paths and roads can make carying material with a cart a lot easier.", "Item stacks can be split using SHIFT + Left Click in chests or inventory.", "Item stacks can be fully transferred to/from containers by dragging or pressing CTRL + Left Click.", "If you run out of stamina while swimming, you will drown.", "The HUD can be toggled with the CTRL + F3 keys.", "Parying with a shield or weapon means blocking at the very last moment of an enemy attack before hitting you. If done right, the enemy will be staggered.", "Don't be afraid to retreat from a fight. It is better to come back to it prepared than naked.", "Sheathing or unsheathing equipped weapons and shields can be done by pressing R. Walking and runnng with unsheathed weapons will slow you down.", "Old buildings can be found throughout Valheim. They can be either renovated for shelter, or torn down for resources.", "Some animals can be tamed.",
			"Sitting next to a lit fire in any open space provides a level 1 rested bonus."
		};
	}
	internal static class PlayerLogoutAnnounce
	{
		[HarmonyPatch(typeof(ZNet), "Update")]
		public static class ZNet_Update_Patch
		{
			public static void Postfix()
			{
				if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer() || !ConfigManager.AnnouncePlayerLogout.Value)
				{
					return;
				}
				List<ZNetPeer> connectedPeers = ZNet.instance.GetConnectedPeers();
				HashSet<string> hashSet = new HashSet<string>();
				foreach (ZNetPeer item in connectedPeers)
				{
					if (!string.IsNullOrEmpty(item.m_playerName))
					{
						hashSet.Add(item.m_playerName);
					}
				}
				foreach (string previousPeer in _previousPeers)
				{
					if (!hashSet.Contains(previousPeer))
					{
						ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "MarsarahTweaks_LogoutAnnounce", new object[1] { previousPeer });
					}
				}
				_previousPeers = hashSet;
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		public static class ZNet_Awake_LogoutAnnounce_Patch
		{
			public static void Postfix()
			{
				TryRegisterRPC();
			}
		}

		private static HashSet<string> _previousPeers = new HashSet<string>();

		private const string LogoutRPC = "MarsarahTweaks_LogoutAnnounce";

		private static bool _registered = false;

		public static void TryRegisterRPC()
		{
			if (!_registered && ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.Register<string>("MarsarahTweaks_LogoutAnnounce", (Action<long, string>)OnPlayerLogoutRPC);
				_registered = true;
			}
		}

		private static void OnPlayerLogoutRPC(long sender, string playerName)
		{
			if (ConfigManager.AnnouncePlayerLogout.Value)
			{
				MessageHud instance = MessageHud.instance;
				if (instance != null)
				{
					instance.ShowMessage((MessageType)1, playerName + " logged out.", 0, (Sprite)null, false);
				}
				Chat instance2 = Chat.instance;
				if (instance2 != null)
				{
					((Terminal)instance2).AddString("[Server]", playerName + " logged out.", (Type)2, false);
				}
			}
		}
	}
	internal class UIOnlinePlayers : UIController
	{
		[HarmonyPatch(typeof(ZNet), "Update")]
		private class OnlinePartyIndicator_Patch
		{
			private static void Prefix(ref List<PlayerInfo> ___m_players)
			{
				if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && ConfigManager.ShowOnlinePlayers.Value && UIController.showUI)
				{
					playerInfoList = ___m_players;
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Awake")]
		private class DisableMinimapUnderNoMapPatch
		{
			private static void Postfix()
			{
				if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && Game.m_noMap && ConfigManager.OnlinePlayersUnderMinimap.Value)
				{
					MarsarahTweaks.LogInfo("Disabling OnlinePlayersUnderMinimap: no map is enabled.");
					ConfigManager.OnlinePlayersUnderMinimap.Value = false;
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Update")]
		private class OnlinePlayers_HUDUpdatePatch
		{
			private static bool lastOnlinePlayersUnderMinimap = ConfigManager.OnlinePlayersUnderMinimap.Value;

			private static readonly float UIPartyPlayerTextDistanceV = -25f;

			private static readonly bool minimalStatusEffectsLoaded = AppDomain.CurrentDomain.GetAssemblies().Any((Assembly a) => a.GetName().Name == "MinimalStatusEffects");

			private static void Postfix(Hud __instance)
			{
				//IL_0555: Unknown result type (might be due to invalid IL or missing references)
				//IL_044e: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0502: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0363: Unknown result type (might be due to invalid IL or missing references)
				//IL_0383: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				if (Game.m_noMap && ConfigManager.OnlinePlayersUnderMinimap.Value)
				{
					MarsarahTweaks.LogInfo("Cannot enable 'Online Players Under Minimap' on a no map world.");
					ConfigManager.OnlinePlayersUnderMinimap.Value = false;
				}
				if (minimalStatusEffectsLoaded && ConfigManager.OnlinePlayersUnderMinimap.Value)
				{
					MarsarahTweaks.LogInfo("Cannot enable 'Online Players Under Minimap' with 'Minimal Status Effects' enabled.");
					ConfigManager.OnlinePlayersUnderMinimap.Value = false;
				}
				if (ConfigManager.ShowOnlinePlayers.Value)
				{
					CreateUI(__instance);
					if (ConfigManager.OnlinePlayersUnderMinimap.Value != lastOnlinePlayersUnderMinimap)
					{
						lastOnlinePlayersUnderMinimap = ConfigManager.OnlinePlayersUnderMinimap.Value;
						UpdatePartyUIPosition(__instance);
					}
					if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && (Object)(object)UIPartyArea != (Object)null)
					{
						bool flag = IsUIHidden();
						bool flag2 = IsLoadScreenActive(__instance);
						if (flag && UIPartyArea.activeSelf)
						{
							UIPartyArea.SetActive(false);
						}
						else if (!flag)
						{
							if (flag2 && UIPartyArea.activeSelf)
							{
								UIPartyArea.SetActive(false);
							}
							else if (!flag2)
							{
								if (ConfigManager.OnlinePlayersUnderMinimap.Value)
								{
									bool activeInHierarchy = Minimap.instance.m_mapSmall.activeInHierarchy;
									if (activeInHierarchy && !UIPartyArea.activeSelf)
									{
										UIPartyArea.SetActive(true);
									}
									else if (!activeInHierarchy && UIPartyArea.activeSelf)
									{
										UIPartyArea.SetActive(false);
									}
								}
								else if (!UIPartyArea.activeSelf)
								{
									UIPartyArea.SetActive(true);
								}
							}
						}
					}
					int count = playerInfoList.Count;
					int num = ((playerInfoList.Count <= numOnlinePlayerSlots - 1) ? playerInfoList.Count : (numOnlinePlayerSlots - 1));
					if (playerInfoList.Count != 1)
					{
						if (!ConfigManager.OnlinePlayersUnderMinimap.Value)
						{
							bool enabled = UIController.showUI && !Chat.instance.IsChatDialogWindowVisible();
							bool enabled2 = UIController.showUI && UIController.showPlayerList && !Chat.instance.IsChatDialogWindowVisible();
							((Behaviour)UIPlayerTexts[0]).enabled = enabled;
							if (UIController.showUI)
							{
								((Graphic)UIPlayerTexts[0]).color = Color.green;
								UIPlayerTexts[0].text = $"Online: {count}";
							}
							for (int i = 1; i < numOnlinePlayerSlots; i++)
							{
								if (i <= num)
								{
									((Behaviour)UIPlayerTexts[i]).enabled = enabled2;
									if (UIController.showUI)
									{
										((Graphic)UIPlayerTexts[i]).color = Color.white;
										UIPlayerTexts[i].text = playerInfoList[i - 1].m_name;
									}
								}
								else
								{
									((Graphic)UIPlayerTexts[i]).color = Color.white;
									UIPlayerTexts[i].text = "";
								}
							}
							return;
						}
						bool enabled3 = UIController.showUI && Minimap.instance.m_mapSmall.activeInHierarchy;
						bool enabled4 = UIController.showUI && UIController.showPlayerList && Minimap.instance.m_mapSmall.activeInHierarchy;
						((Behaviour)UIPlayerTexts[0]).enabled = enabled3;
						if (UIController.showUI)
						{
							((Graphic)UIPlayerTexts[0]).color = Color.green;
							UIPlayerTexts[0].text = $"Online: {count}";
						}
						for (int j = 1; j < numOnlinePlayerSlots; j++)
						{
							if (j <= num)
							{
								((Behaviour)UIPlayerTexts[j]).enabled = enabled4;
								if (UIController.showUI)
								{
									((Graphic)UIPlayerTexts[j]).color = Color.white;
									UIPlayerTexts[j].text = playerInfoList[j - 1].m_name;
								}
							}
							else
							{
								((Graphic)UIPlayerTexts[j]).color = Color.white;
								UIPlayerTexts[j].text = "";
							}
						}
					}
					else
					{
						for (int k = 0; k < numOnlinePlayerSlots; k++)
						{
							((Graphic)UIPlayerTexts[k]).color = Color.white;
							UIPlayerTexts[k].text = "";
						}
					}
					return;
				}
				foreach (Text uIPlayerText in UIPlayerTexts)
				{
					if ((Object)(object)uIPlayerText != (Object)null)
					{
						((Behaviour)uIPlayerText).enabled = false;
					}
				}
			}

			private static void CreateUI(Hud hud)
			{
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Expected O, but got Unknown
				//IL_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: 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_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0143: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_022d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0218: Unknown result type (might be due to invalid IL or missing references)
				//IL_0232: Unknown result type (might be due to invalid IL or missing references)
				//IL_024a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0251: Unknown result type (might be due to invalid IL or missing references)
				//IL_0253: Unknown result type (might be due to invalid IL or missing references)
				//IL_0255: Unknown result type (might be due to invalid IL or missing references)
				if (UIPlayerTexts.Count <= 0 || !UIPlayerTexts.All((Text t) => (Object)(object)t != (Object)null))
				{
					int fontSize = 16;
					string fontName = "AveriaSansLibre-Bold";
					Vector2 sizeDelta = default(Vector2);
					((Vector2)(ref sizeDelta))..ctor(120f, 30f);
					UIPartyArea = new GameObject("PartyArea");
					UIPartyArea.SetActive(false);
					UIPartyArea.layer = 5;
					if (!ConfigManager.OnlinePlayersUnderMinimap.Value)
					{
						UIPartyArea.transform.SetParent(hud.m_rootObject.transform.parent);
					}
					else
					{
						UIPartyArea.transform.SetParent(hud.m_rootObject.transform);
					}
					RectTransform val = UIPartyArea.AddComponent<RectTransform>();
					if (!ConfigManager.OnlinePlayersUnderMinimap.Value)
					{
						val.anchorMin = new Vector2(1f, 0f);
						val.anchorMax = new Vector2(1f, 0f);
						val.pivot = new Vector2(1f, 0f);
						val.anchoredPosition = new Vector2(-20f, 70f);
					}
					else
					{
						val.anchorMin = new Vector2(1f, 1f);
						val.anchorMax = new Vector2(1f, 1f);
						val.pivot = new Vector2(0.5f, 0.5f);
						val.anchoredPosition = new Vector2(-170f, -255f);
					}
					val.sizeDelta = sizeDelta;
					UIPartyArea.transform.localScale = Vector3.one;
					List<GameObject> list = new List<GameObject>();
					UIPlayerTexts.Clear();
					list.Clear();
					for (int i = 0; i < numOnlinePlayerSlots; i++)
					{
						TextAnchor alignment = (TextAnchor)(ConfigManager.OnlinePlayersUnderMinimap.Value ? 3 : 5);
						Vector2 position = (ConfigManager.OnlinePlayersUnderMinimap.Value ? new Vector2(0f, UIPartyPlayerTextDistanceV * (float)i) : new Vector2(0f, (0f - UIPartyPlayerTextDistanceV) * (float)i));
						Text val2 = UIController.CreateTextObject($"PartyText_{i}", UIPartyArea, Color.white, fontName, fontSize, alignment, position, sizeDelta);
						UIPlayerTexts.Add(val2);
						list.Add(((Component)val2).gameObject);
					}
				}
			}

			private static void UpdatePartyUIPosition(Hud hud)
			{
				//IL_00ed: 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_0119: 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_0091: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)UIPartyArea == (Object)null)
				{
					return;
				}
				if (!ConfigManager.OnlinePlayersUnderMinimap.Value)
				{
					UIPartyArea.transform.SetParent(hud.m_rootObject.transform.parent, false);
				}
				else
				{
					UIPartyArea.transform.SetParent(hud.m_rootObject.transform, false);
				}
				RectTransform component = UIPartyArea.GetComponent<RectTransform>();
				if (!ConfigManager.OnlinePlayersUnderMinimap.Value)
				{
					component.anchorMin = new Vector2(1f, 0f);
					component.anchorMax = new Vector2(1f, 0f);
					component.pivot = new Vector2(1f, 0f);
					component.anchoredPosition = new Vector2(-20f, 70f);
				}
				else
				{
					component.anchorMin = new Vector2(1f, 1f);
					component.anchorMax = new Vector2(1f, 1f);
					component.pivot = new Vector2(0.5f, 0.5f);
					component.anchoredPosition = new Vector2(-170f, -255f);
				}
				for (int i = 0; i < UIPlayerTexts.Count; i++)
				{
					Text val = UIPlayerTexts[i];
					if ((Object)(object)val != (Object)null)
					{
						RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
						val.alignment = (TextAnchor)(ConfigManager.OnlinePlayersUnderMinimap.Value ? 3 : 5);
						component2.anchoredPosition = (ConfigManager.OnlinePlayersUnderMinimap.Value ? new Vector2(0f, UIPartyPlayerTextDistanceV * (float)i) : new Vector2(0f, (0f - UIPartyPlayerTextDistanceV) * (float)i));
					}
				}
			}

			private static bool IsLoadScreenActive(Hud hud)
			{
				return Object.op_Implicit((Object)(object)Hud.instance) && Object.op_Implicit((Object)(object)hud.m_loadingScreen) && ((Component)hud.m_loadingScreen).gameObject.activeSelf;
			}

			private static bool IsUIHidden()
			{
				return Hud.IsUserHidden();
			}
		}

		private static List<PlayerInfo> playerInfoList = new List<PlayerInfo>();

		private static int numOnlinePlayerSlots = 21;

		private static GameObject UIPartyArea;

		private static List<Text> UIPlayerTexts = new List<Text>();
	}
	internal class UIShowOwnedResources
	{
		[HarmonyPatch(typeof(InventoryGui), "SetupRequirement")]
		private class ShowOwnedResources_Patch
		{
			private static void Postfix(Transform elementRoot, Requirement req, Player player, bool craft, int quality, int craftMultiplier)
			{
				//IL_012f: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				if (!ConfigManager.ShowOwnedResources.Value || (Object)(object)req?.m_resItem == (Object)null || (Object)(object)player == (Object)null)
				{
					return;
				}
				int num = req.GetAmount(quality) * craftMultiplier;
				int num2 = ((Humanoid)player).GetInventory().CountItems(req.m_resItem.m_itemData.m_shared.m_name, -1, true);
				Transform val = elementRoot.Find("res_amount");
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				TMP_Text component = ((Component)val).GetComponent<TMP_Text>();
				if (!((Object)(object)component == (Object)null))
				{
					component.text = $"{num}/{num2}";
					bool flag = (!craft && ZoneSystem.instance.GetGlobalKey((GlobalKeys)18)) || (craft && ZoneSystem.instance.GetGlobalKey((GlobalKeys)19));
					if (num2 < num && !flag)
					{
						((Graphic)component).color = ((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : Color.white);
					}
					else
					{
						((Graphic)component).color = Color.white;
					}
				}
			}
		}
	}
	internal class UISmartBiome : UIController
	{
		private struct BiomeWeights
		{
			public int _min;

			public int _max;

			public BiomeWeights(int min, int max)
			{
				_min = min;
				_max = max;
			}
		}

		[HarmonyPatch(typeof(Player), "Update")]
		private class SmartBiome_PlayerPatch
		{
			private static void Prefix(ref Player ___m_localPlayer)
			{
				if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)___m_localPlayer == (Object)null || !ConfigManager.ShowSmartBiome.Value || !UIController.showUI)
				{
					return;
				}
				playerArmor = ((Character)___m_localPlayer).GetBodyArmor();
				Inventory inventory = ((Humanoid)___m_localPlayer).GetInventory();
				List<ItemData> equippedItems = inventory.GetEquippedItems();
				foreach (ItemData item in equippedItems)
				{
					if (armorWeightsDict.ContainsKey(item.m_shared.m_name))
					{
						if (!equippedArmorWeightsDict.ContainsKey(item.m_shared.m_name))
						{
							equippedArmorWeightsDict.Add(item.m_shared.m_name, armorWeightsDict[item.m_shared.m_name] + item.m_quality - 1);
						}
						else
						{
							equippedArmorWeightsDict[item.m_shared.m_name] = armorWeightsDict[item.m_shared.m_name] + item.m_quality - 1;
						}
					}
				}
				List<string> list = new List<string>();
				foreach (KeyValuePair<string, int> item2 in equippedArmorWeightsDict)
				{
					bool flag = false;
					foreach (ItemData item3 in equippedItems)
					{
						if (item3.m_shared.m_name == item2.Key)
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						list.Add(item2.Key);
					}
				}
				foreach (string item4 in list)
				{
					equippedArmorWeightsDict.Remove(item4);
				}
			}
		}

		[HarmonyPatch(typeof(Minimap), "UpdateBiome")]
		private class MoveBiomeMinimapText_Patch
		{
			private static void Prefix(ref Text ___m_biomeNameSmall, ref Player player)
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated())
				{
					if (ConfigManager.ShowSmartBiome.Value && UIController.showUI)
					{
						((Behaviour)___m_biomeNameSmall).enabled = false;
						Biome currentBiome = player.GetCurrentBiome();
						UISmartBiome.currentBiome = ((object)(Biome)(ref currentBiome)).ToString();
					}
					else
					{
						((Behaviour)___m_biomeNameSmall).enabled = true;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Update")]
		private class SmartBiome_HUDUpdatePatch
		{
			private static void Postfix(Hud __instance)
			{
				//IL_0169: 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)
				if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				if (ConfigManager.ShowSmartBiome.Value)
				{
					CreateUI(__instance);
					((Behaviour)UIBiomeText).enabled = UIController.showUI && Minimap.instance.m_mapSmall.activeInHierarchy;
					if (!UIController.showUI || !Minimap.instance.m_mapSmall.activeInHierarchy)
					{
						return;
					}
					if (currentBiome != null && biomeWeightsDict.ContainsKey(currentBiome))
					{
						playerArmorWeight = 0;
						foreach (KeyValuePair<string, int> item in equippedArmorWeightsDict)
						{
							playerArmorWeight += item.Value;
						}
						float num = biomeWeightsDict[currentBiome]._min;
						float num2 = biomeWeightsDict[currentBiome]._max;
						float num3 = num2 - num;
						float num4 = (float)playerArmorWeight - num;
						float percent = num4 * 100f / num3;
						((Graphic)UIBiomeText).color = GetColorFromPercent(percent);
					}
					else
					{
						((Graphic)UIBiomeText).color = Color.white;
					}
					UIBiomeText.text = ((currentBiome == "BlackForest") ? "Black forest" : ((currentBiome == "AshLands") ? "Ashlands" : currentBiome));
				}
				else if ((Object)(object)UIBiomeText != (Object)null)
				{
					((Behaviour)UIBiomeText).enabled = false;
				}
			}

			private static void CreateUI(Hud hud)
			{
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: 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)
				if (!((Object)(object)UIBiomeText != (Object)null))
				{
					int fontSize = 16;
					string fontName = "AveriaSansLibre-Bold";
					Vector2 sizeDelta = default(Vector2);
					((Vector2)(ref sizeDelta))..ctor(150f, 30f);
					GameObject val = new GameObject("BiomeArea");
					val.layer = 5;
					val.transform.SetParent(hud.m_rootObject.transform);
					RectTransform val2 = val.AddComponent<RectTransform>();
					val2.anchorMin = new Vector2(1f, 1f);
					val2.anchorMax = new Vector2(1f, 1f);
					val2.anchoredPosition = new Vector2(-125f, -55f);
					val2.sizeDelta = sizeDelta;
					val.transform.localScale = Vector3.one;
					UIBiomeText = UIController.CreateTextObject("BiomeText", val, Color.white, fontName, fontSize, (TextAnchor)5, new Vector2(0f, 0f), sizeDelta);
				}
			}

			private static Color GetColorFromPercent(float percent)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				if (percent < 0f)
				{
					return new Color(0.298039f, 0f, 0.6f);
				}
				if (percent < 25f)
				{
					return Color.red;
				}
				if (percent < 75f)
				{
					return new Color(1f, 0.549019f, 0f);
				}
				if (percent < 100f)
				{
					return Color.yellow;
				}
				return Color.green;
			}
		}

		private static float playerArmor;

		private static int playerArmorWeight;

		private static string currentBiome = null;

		private static Text UIBiomeText;

		private static readonly Dictionary<string, BiomeWeights> defaultBiomeWeights = new Dictionary<string, BiomeWeights>
		{
			{
				"Meadows",
				new BiomeWeights(1, 11)
			},
			{
				"BlackForest",
				new BiomeWeights(11, 24)
			},
			{
				"Swamp",
				new BiomeWeights(24, 37)
			},
			{
				"Mountain",
				new BiomeWeights(33, 46)
			},
			{
				"Plains",
				new BiomeWeights(42, 55)
			},
			{
				"Mistlands",
				new BiomeWeights(51, 60)
			},
			{
				"AshLands",
				new BiomeWeights(60, 69)
			}
		};

		private static readonly Dictionary<string, BiomeWeights> unlockedBiomeWeights = new Dictionary<string, BiomeWeights>
		{
			{
				"Meadows",
				new BiomeWeights(1, 15)
			},
			{
				"BlackForest",
				new BiomeWeights(11, 28)
			},
			{
				"Swamp",
				new BiomeWeights(24, 37)
			},
			{
				"Mountain",
				new BiomeWeights(33, 46)
			},
			{
				"Plains",
				new BiomeWeights(42, 55)
			},
			{
				"Mistlands",
				new BiomeWeights(51, 64)
			},
			{
				"AshLands",
				new BiomeWeights(60, 73)
			}
		};

		private static Dictionary<string, BiomeWeights> biomeWeightsDict = defaultBiomeWeights;

		private static Dictionary<string, int> armorWeightsDict = new Dictionary<string, int>
		{
			{ "$item_cape_deerhide", 1 },
			{ "$item_cape_trollhide", 1 },
			{ "$item_cape_linen", 1 },
			{ "$item_cape_wolf", 1 },
			{ "$item_cape_lox", 1 },
			{ "$item_cape_feather", 1 },
			{ "$item_cape_ash", 1 },
			{ "$item_cape_asksvin", 1 },
			{ "$item_chest_rags", 1 },
			{ "$item_legs_rags", 1 },
			{ "$item_helmet_l