Decompiled source of MarsarahUI v1.5.0

MarsarahUI.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using MarsarahUI.Managers;
using MarsarahUI.Patches.Logic;
using MarsarahUI.Patches.UI;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
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("MarsarahUI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MarsarahUI")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7138bb38-6a11-44f4-8009-836df083e4de")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MarsarahUI
{
	[BepInPlugin("Marsarah.MarsarahUI", "MarsarahUI", "1.5.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MarsarahUI : BaseUnityPlugin
	{
		internal const string ModName = "MarsarahUI";

		internal const string ModVersion = "1.5.0";

		internal const string Author = "Marsarah";

		public const string ModGUID = "Marsarah.MarsarahUI";

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

		private static readonly LogManager log = new LogManager("Main", LogManager.LogLevel.Warning);

		private void Awake()
		{
			LogManager.SetGlobalLogLevel(LogManager.LogLevel.Warning);
			ConfigManager.Init(((BaseUnityPlugin)this).Config);
			harmony.PatchAll();
			log.Info("MarsarahUI v1.5.0 loaded.");
		}

		private void Start()
		{
			CompatibilityManager.Initialize();
		}

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

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}
	}
}
namespace MarsarahUI.Managers
{
	internal static class CompatibilityManager
	{
		private static readonly LogManager log = new LogManager("Compatibility Manager", LogManager.LogLevel.Warning);

		private const string MarsarahTweaksGUID = "Marsarah.MarsarahTweaks";

		private const string CraftFromContainersGUID = "aedenthorn.CraftFromContainers";

		private static ConfigEntry<bool> tweaksGearUpgradeUnlock;

		private static ConfigEntry<bool> tweaksEarlyLinenCape;

		private static MethodInfo tweaksIsContainerSealedMethod;

		internal static bool MarsarahTweaksLoaded { get; private set; }

		internal static bool CraftFromContainersLoaded { get; private set; }

		internal static bool TweaksGearUpgradeUnlockEnabled => MarsarahTweaksLoaded && (tweaksGearUpgradeUnlock?.Value ?? false);

		internal static bool TweaksEarlyLinenCapeEnabled => MarsarahTweaksLoaded && (tweaksEarlyLinenCape?.Value ?? false);

		internal static void Initialize()
		{
			if (Chainloader.PluginInfos.TryGetValue("Marsarah.MarsarahTweaks", out var value) && (Object)(object)value.Instance != (Object)null)
			{
				MarsarahTweaksLoaded = true;
				ConfigFile config = value.Instance.Config;
				tweaksGearUpgradeUnlock = GetBoolConfig(config, "3 - Balance (Synced with Server)", "Gear Upgrade Unlock");
				tweaksEarlyLinenCape = GetBoolConfig(config, "3 - Balance (Synced with Server)", "Early Linen Cape");
				tweaksIsContainerSealedMethod = ((object)value.Instance).GetType().Assembly.GetType("MarsarahTweaks.Patches.Features.ProgressionHalt")?.GetMethod("IsContainerSealed", BindingFlags.Static | BindingFlags.NonPublic);
				if (tweaksIsContainerSealedMethod == null)
				{
					log.Warn("Could not find MarsarahTweaks Progression Halt container compatibility method.");
				}
				log.Info("MarsarahTweaks detected. Compatibility features initialized.");
			}
			CraftFromContainersLoaded = Chainloader.PluginInfos.ContainsKey("aedenthorn.CraftFromContainers");
			if (CraftFromContainersLoaded)
			{
				log.Info("Craft From Containers detected. Show Owned Resources will be handled by Craft From Containers.");
			}
		}

		private static ConfigEntry<bool> GetBoolConfig(ConfigFile config, string section, string key)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			ConfigDefinition val = new ConfigDefinition(section, key);
			ConfigEntry<bool> result = default(ConfigEntry<bool>);
			if (config.TryGetEntry<bool>(val, ref result))
			{
				return result;
			}
			log.Warn("Could not find MarsarahTweaks config '" + section + " / " + key + "'.");
			return null;
		}

		internal static bool TweaksIsContainerSealed(Container container)
		{
			if (!MarsarahTweaksLoaded || tweaksIsContainerSealedMethod == null || (Object)(object)container == (Object)null)
			{
				return false;
			}
			try
			{
				return (bool)tweaksIsContainerSealedMethod.Invoke(null, new object[1] { container });
			}
			catch (Exception ex)
			{
				log.Warn("Failed to check MarsarahTweaks Progression Halt container state: " + ex.Message);
				return false;
			}
		}
	}
	public static class ConfigManager
	{
		public static class ConfigSections
		{
			public const string GeneralHUD = "01 - General & HUD (Local)";

			public const string InformationRail = "02 - Information Rail (Local)";

			public const string ItemsInteraction = "03 - Items & Interaction (Local)";

			public const string DetailedHovers = "04 - Detailed Hovers (Local)";

			public const string Notifications = "05 - Notifications (Local)";

			public const string ServerOverrides = "06 - Server Overrides (Synced)";
		}

		public struct ConfigMetadata
		{
			public string Name;

			public string Description;

			public string Section;

			public int Order;

			public ConfigMetadata(string name, string description, string section, int order)
			{
				Name = name;
				Description = description;
				Section = section;
				Order = order;
			}
		}

		private sealed class ConfigurationManagerAttributes
		{
			public int? Order;
		}

		public enum UIStyle
		{
			Style1,
			Style2,
			Style3
		}

		public enum TimeMode
		{
			DigitalClock,
			DigitalClock12Hour,
			DayPhases,
			Off
		}

		public enum PortalTransitionMode
		{
			Images,
			ImagesAndText,
			Off
		}

		public enum AlternateBiomeDisplayMode
		{
			Off,
			OneRow,
			TwoRows
		}

		public enum InfoRailDisplayMode
		{
			Icons,
			Text
		}

		public enum InventoryDisplayMode
		{
			WeightAndFreeSlots,
			WeightOnly,
			FreeSlotsOnly,
			Off
		}

		public enum EnemyDetectorMode
		{
			Consolidated,
			Split,
			Off
		}

		public enum EnemyDetectorPosition
		{
			TopCenter,
			InformationRail
		}

		public enum SkillProgressBarColor
		{
			Gold,
			White,
			Green,
			Blue,
			Cyan,
			Red,
			Purple
		}

		public enum SkillProgressPercentageLocation
		{
			NotificationArea,
			InformationRail
		}

		public enum BiomeCraftingTabsMode
		{
			Scrolling,
			MultipleRows,
			Off
		}

		public enum EnemyNameplateMode
		{
			BarsOnly,
			BarsWithHealth,
			BarsWithPercent,
			BarsWithBoth,
			Off
		}

		public enum ItemQualityMode
		{
			Horizontal,
			Vertical,
			Off
		}

		public enum ItemQualitySymbol
		{
			Star,
			Circle,
			Diamond,
			EmptyDiamond
		}

		public enum ItemQualityColor
		{
			White,
			Yellow,
			Green,
			Red,
			Blue,
			Cyan
		}

		public enum HoverInfoMode
		{
			ColoredText,
			WhiteText,
			Off
		}

		public enum ContainerContentsMode
		{
			IconsHorizontal,
			IconsVertical,
			Text,
			Off
		}

		public enum ContainerHoverMode
		{
			CurrentPerMax,
			AmountOfFreeSlots,
			Percent,
			Off
		}

		public enum BeeHoverMode
		{
			RemainingTime,
			Percent,
			PercentAndTime,
			Off
		}

		public enum PlantHoverMode
		{
			RemainingTime,
			Percent,
			PercentAndTime,
			Off
		}

		public enum FermenterHoverMode
		{
			RemainingTime,
			Percent,
			PercentAndTime,
			Off
		}

		public enum CookingStationHoverMode
		{
			RemainingTime,
			Percent,
			PercentAndTime,
			Off
		}

		public enum SmelterHoverMode
		{
			RemainingTime,
			Off
		}

		public enum EggHoverMode
		{
			RemainingTime,
			Percent,
			PercentAndTime,
			Off
		}

		public enum NotificationMode
		{
			Enhanced,
			Vanilla
		}

		public enum BoolOverride
		{
			UserChoice,
			ForceOn,
			ForceOff
		}

		public enum TimeModeOverride
		{
			UserChoice,
			DigitalClock,
			DigitalClock12Hour,
			DayPhases,
			Off
		}

		public enum AlternateBiomeDisplayModeOverride
		{
			UserChoice,
			Off,
			OneRow,
			TwoRows
		}

		public enum EnemyNameplateModeOverride
		{
			UserChoice,
			BarsOnly,
			BarsWithHealth,
			BarsWithPercent,
			BarsWithBoth,
			Off
		}

		public enum InfoRailDisplayModeOverride
		{
			UserChoice,
			Icons,
			Text
		}

		public enum BiomeCraftingTabsModeOverride
		{
			UserChoice,
			Scrolling,
			MultipleRows,
			Off
		}

		public enum NotificationModeOverride
		{
			UserChoice,
			Enhanced,
			Vanilla
		}

		public static class Configs
		{
			public static readonly ConfigMetadata UIStyle = new ConfigMetadata("UI Style", "Choose the shared visual style used by supported MarsarahUI elements, including the information rail, summon counter, enhanced notifications, and other HUD elements that use the shared style.", "01 - General & HUD (Local)", 140);

			public static readonly ConfigMetadata UIInfoRailDisplayMode = new ConfigMetadata("UI Display Mode", "Choose whether supported UI elements, including the information rail, summon counter, and sailing HUD, display icons or text labels.", "01 - General & HUD (Local)", 130);

			public static readonly ConfigMetadata UIAnimations = new ConfigMetadata("UI Animations", "Animate supported MarsarahUI elements such as the information rail, summon counter, and enhanced notifications. Disable this if you experience UI-related performance issues.", "01 - General & HUD (Local)", 125);

			public static readonly ConfigMetadata UIBetterLoadingTips = new ConfigMetadata("Better Loading Tips", "Replaces the vanilla loading tips with a larger selection of more useful gameplay tips.", "01 - General & HUD (Local)", 120);

			public static readonly ConfigMetadata UIPortalTransition = new ConfigMetadata("Portal Transition Images", "Choose between displaying custom portal images, custom portal images with destination biome text, or Valheim's vanilla teleport screen.", "01 - General & HUD (Local)", 115);

			public static readonly ConfigMetadata UICurrentDay = new ConfigMetadata("Show Current Day", "Shows the current day above the minimap.", "01 - General & HUD (Local)", 100);

			public static readonly ConfigMetadata UITimeMode = new ConfigMetadata("Show Current Time", "Shows the current time above the minimap. Choose between 24-hour digital clock, 12-hour digital clock, day phases, or off.", "01 - General & HUD (Local)", 90);

			public static readonly ConfigMetadata UIColorDayPhases = new ConfigMetadata("Color Day Phases", "Colors the Day Phases time display based on the current phase of the day. Only applies when Show Current Time is set to DayPhases.", "01 - General & HUD (Local)", 85);

			public static readonly ConfigMetadata UIWeatherForecast = new ConfigMetadata("Show Weather Forecast Indicator", "Shows the next scheduled weather as an icon at the bottom-right of the minimap and the remaining time to that weather.", "01 - General & HUD (Local)", 80);

			public static readonly ConfigMetadata UISmartBiome = new ConfigMetadata("Smart Biome Indicator", "Shows smart biome text on the minimap (colored according to worn armor relative to current biome).", "01 - General & HUD (Local)", 75);

			public static readonly ConfigMetadata UIAlternateBiomeNames = new ConfigMetadata("Alternate Biome Names", "Choose how alternate biome names are displayed on the minimap. OneRow shows a compact single-line label, TwoRows shows up to two lines, and Off uses the normal biome name. Lower-priority alternates are summarized with +N when space is limited.", "01 - General & HUD (Local)", 70);

			public static readonly ConfigMetadata UIBoatSpeed = new ConfigMetadata("Show Boat Speed", "Shows the controlled boat's speed near the sailing controls.", "01 - General & HUD (Local)", 69);

			public static readonly ConfigMetadata UIBoatHealth = new ConfigMetadata("Show Boat Health", "Shows the controlled boat's health as a bar near the sailing controls.", "01 - General & HUD (Local)", 68);

			public static readonly ConfigMetadata UIOnlinePlayers = new ConfigMetadata("Show Online Players", "Displays the number of online players in the bottom-right corner. Player names can be toggled with the Home key. Not displayed if only one player is online.", "01 - General & HUD (Local)", 60);

			public static readonly ConfigMetadata UIShowPowerExpiration = new ConfigMetadata("Show Boss Power Expiration Message", "Displays a message in the center of the screen when any Forsaken Power expires.", "01 - General & HUD (Local)", 50);

			public static readonly ConfigMetadata UIAshlandsHeatLevel = new ConfigMetadata("Show Heat Meter in Ashlands", "Shows a heat meter at the top-center of the screen when in Ashlands water or lava.", "01 - General & HUD (Local)", 40);

			public static readonly ConfigMetadata UIRaidTimer = new ConfigMetadata("Show Raid Timer", "Shows the remaining duration beneath the vanilla raid title while the raid banner is visible.", "01 - General & HUD (Local)", 35);

			public static readonly ConfigMetadata UIStatusEffectsUnderMinimap = new ConfigMetadata("Status Effects Under Minimap", "Moves status effects below the minimap and displays them in a more compact layout.", "01 - General & HUD (Local)", 30);

			public static readonly ConfigMetadata UIGlobalChatByDefault = new ConfigMetadata("Global Chat By Default", "Makes regular chat messages visible to all players regardless of distance.", "01 - General & HUD (Local)", 20);

			public static readonly ConfigMetadata UICharacterStatistics = new ConfigMetadata("Logon Screen Character Statistics", "Displays statistics and notable facts for the selected character on the character selection screen.", "01 - General & HUD (Local)", 10);

			public static readonly ConfigMetadata UIInfoRailPosition = new ConfigMetadata("Information Rail X/Y Position", "Sets the exact X and Y position of the information rail.", "02 - Information Rail (Local)", 54);

			public static readonly ConfigMetadata UIInfoRailScale = new ConfigMetadata("Information Rail Scale", "Sets the scale of the information rail as a percentage. 100 is the default size.", "02 - Information Rail (Local)", 53);

			public static readonly ConfigMetadata UIInventoryWeightAndSlots = new ConfigMetadata("Inventory Weight and Free Slots", "Choose whether the bottom-left information rail displays inventory weight, free slots, both, or neither.", "02 - Information Rail (Local)", 50);

			public static readonly ConfigMetadata UIEnemyDetector = new ConfigMetadata("Enemy Detector", "Choose whether nearby hostile enemies are shown in one consolidated counter, split into normal, tough, and boss counters, or enemy detection is disabled.", "02 - Information Rail (Local)", 40);

			public static readonly ConfigMetadata UIEnemyDetectorPosition = new ConfigMetadata("Enemy Detector Position", "Choose whether the enemy detector is displayed in the bottom-left information rail or separately at the top-center of the screen.", "02 - Information Rail (Local)", 30);

			public static readonly ConfigMetadata UIEnemyRailPosition = new ConfigMetadata("Enemy Rail X/Y Position", "Sets the exact X and Y position of the top-center enemy rail.", "02 - Information Rail (Local)", 29);

			public static readonly ConfigMetadata UIEnemyRailScale = new ConfigMetadata("Enemy Rail Scale", "Sets the scale of the top-center enemy rail as a percentage. 100 is the default size.", "02 - Information Rail (Local)", 28);

			public static readonly ConfigMetadata UISummonCounter = new ConfigMetadata("Show Summon Counter", "Shows number of summoned skeletons from the Dead Raiser.", "02 - Information Rail (Local)", 20);

			public static readonly ConfigMetadata UISummonCounterPosition = new ConfigMetadata("Summon Counter X/Y Position", "Sets the exact X and Y position of the summon counter.", "02 - Information Rail (Local)", 19);

			public static readonly ConfigMetadata UISummonCounterScale = new ConfigMetadata("Summon Counter Scale", "Sets the scale of the summon counter as a percentage. 100 is the default size.", "02 - Information Rail (Local)", 18);

			public static readonly ConfigMetadata UIShowSkillProgress = new ConfigMetadata("Show Skill Progress", "Shows skill progress while advancing toward the next skill level.", "02 - Information Rail (Local)", 12);

			public static readonly ConfigMetadata UISkillProgressBarColor = new ConfigMetadata("Skill Progress Bar Color", "Choose the color of the skill progress bar shown at the bottom while advancing toward the next skill level.", "02 - Information Rail (Local)", 11);

			public static readonly ConfigMetadata UISkillProgressPercentageLocation = new ConfigMetadata("Skill Progress Percentage Location", "Choose whether the skill progress percentage is shown in the enhanced notification area or in the information rail. When Notification Mode is Vanilla, the percentage is always shown in the information rail.", "02 - Information Rail (Local)", 10);

			public static readonly ConfigMetadata UIBiomeSortedCraftingTabs = new ConfigMetadata("Biome-Sorted Crafting Tabs", "Organizes crafting recipes into contextual tabs (separated by biome and type). Choose Scrolling, MultipleRows, or Off.", "03 - Items & Interaction (Local)", 80);

			public static readonly ConfigMetadata UIShowOwnedResources = new ConfigMetadata("Show Owned Resources In Build Menu", "Displays the total amount of resources in the player's inventory in addition to the required resource amount for the selected piece or recipe in the build or crafting menu.", "03 - Items & Interaction (Local)", 70);

			public static readonly ConfigMetadata UIEnemyNameplateMode = new ConfigMetadata("Enemy Nameplate Mode", "Changes the way enemy nameplates are displayed by changing bar style and colors and alerted/aggravated status. Has different ways of showing HP.", "03 - Items & Interaction (Local)", 60);

			public static readonly ConfigMetadata UITamingProgress = new ConfigMetadata("Show Taming Progress", "Displays current taming percentage of animals that are acclimatizing under the HP bar. This is independent of Enemy Nameplate Mode.", "03 - Items & Interaction (Local)", 50);

			public static readonly ConfigMetadata UIItemQualityIndicatorMode = new ConfigMetadata("Item Quality Indicator Mode", "Changes the way item quality is displayed by converting the vanilla number to symbols.", "03 - Items & Interaction (Local)", 40);

			public static readonly ConfigMetadata UIItemQualitySymbol = new ConfigMetadata("Symbol For Item Quality", "Choose the symbol used for the item quality indicator. Requires Item Quality Indicator Mode to be enabled.", "03 - Items & Interaction (Local)", 30);

			public static readonly ConfigMetadata UIItemQualityColor = new ConfigMetadata("Color For Item Quality", "Choose the color used for the item quality indicator. Requires Item Quality Indicator Mode to be enabled.", "03 - Items & Interaction (Local)", 20);

			public static readonly ConfigMetadata UIItemDurabilityColor = new ConfigMetadata("Better Item Durability Bar", "Colors the item durability bar according to current durability and modifies the sprite texture.", "03 - Items & Interaction (Local)", 10);

			public static readonly ConfigMetadata UIHoverInfoMode = new ConfigMetadata("Detailed Hover Information", "Controls the style of detailed hover information, or disables all detailed hovers.", "04 - Detailed Hovers (Local)", 90);

			public static readonly ConfigMetadata UIContainerContents = new ConfigMetadata("Container Contents Mode", "Choose how container contents are displayed when hovering: horizontal icons, vertical icons, text, or off.", "04 - Detailed Hovers (Local)", 80);

			public static readonly ConfigMetadata UIContainerContentsOffset = new ConfigMetadata("Container Contents Icon X/Y Offset", "Adjusts the X and Y position of container content icons relative to their default hover position.", "04 - Detailed Hovers (Local)", 79);

			public static readonly ConfigMetadata UIContainerContentsScale = new ConfigMetadata("Container Contents Icon Scale", "Sets the scale of the container contents icons and item counts as a percentage. 100 is the default size.", "04 - Detailed Hovers (Local)", 78);

			public static readonly ConfigMetadata UIContainerHoverMode = new ConfigMetadata("Container Hover Mode", "Choose the method of displaying Container hover info, or Off to disable it.", "04 - Detailed Hovers (Local)", 70);

			public static readonly ConfigMetadata UIBeeHoverMode = new ConfigMetadata("Beehive Hover Mode", "Choose the method of displaying Beehive hover info, or Off to disable it.", "04 - Detailed Hovers (Local)", 60);

			public static readonly ConfigMetadata UIPlantHoverMode = new ConfigMetadata("Plant Hover Mode", "Choose the method of displaying Plant hover info, or Off to disable it.", "04 - Detailed Hovers (Local)", 50);

			public static readonly ConfigMetadata UIFermenterHoverMode = new ConfigMetadata("Fermenter Hover Mode", "Choose the method of displaying Fermenter hover info, or Off to disable it.", "04 - Detailed Hovers (Local)", 40);

			public static readonly ConfigMetadata UICookingStationHoverMode = new ConfigMetadata("Cooking Station Hover Mode", "Choose the method of displaying Cooking Station hover info, or Off to disable it.", "04 - Detailed Hovers (Local)", 30);

			public static readonly ConfigMetadata UISmelterHoverMode = new ConfigMetadata("Smelter Hover Mode", "Choose the method of displaying Smelter hover info, or Off to disable it.", "04 - Detailed Hovers (Local)", 20);

			public static readonly ConfigMetadata UIEggHoverMode = new ConfigMetadata("Egg Hover Mode", "Choose the method of displaying Egg hatching hover info, or Off to disable it.", "04 - Detailed Hovers (Local)", 10);

			public static readonly ConfigMetadata UINotificationMode = new ConfigMetadata("Notification Mode", "Choose whether transient notifications use the enhanced MarsarahUI notification stack, or the vanilla Valheim notification system.", "05 - Notifications (Local)", 50);

			public static readonly ConfigMetadata UINotificationPosition = new ConfigMetadata("Notification X/Y Position", "Sets the exact X and Y position of the enhanced notification stack.", "05 - Notifications (Local)", 40);

			public static readonly ConfigMetadata UINotificationScale = new ConfigMetadata("Notification Scale", "Sets the scale of the enhanced notification stack as a percentage. 100 is the default size.", "05 - Notifications (Local)", 30);

			public static readonly ConfigMetadata UINotificationDuration = new ConfigMetadata("Notification Duration", "Sets how many seconds enhanced notifications remain visible before disappearing.", "05 - Notifications (Local)", 20);

			public static readonly ConfigMetadata UINotificationMaxVisible = new ConfigMetadata("Maximum Visible Notifications", "Sets the maximum number of enhanced notifications that can be visible at the same time.", "05 - Notifications (Local)", 10);

			public static readonly ConfigMetadata LockServerOverrides = new ConfigMetadata("Lock Server Overrides", "If on, only server admins can change Server Override settings. Local UI settings are never affected.", "06 - Server Overrides (Synced)", 130);

			public static readonly ConfigMetadata EnableServerOverrides = new ConfigMetadata("Enable Server Overrides", "If on, the server can override selected UI settings for connected players. Settings left as UserChoice continue to use each player's local UI preference.", "06 - Server Overrides (Synced)", 120);

			public static readonly ConfigMetadata OverrideInfoRailDisplayMode = new ConfigMetadata("Information Rail Display Mode Override", "Overrides the player's local Information Rail Display Mode setting.", "06 - Server Overrides (Synced)", 115);

			public static readonly ConfigMetadata OverrideEnemyDetector = new ConfigMetadata("Enemy Detector Override", "Overrides the player's local Enemy Detector setting.", "06 - Server Overrides (Synced)", 110);

			public static readonly ConfigMetadata OverrideBiomeCraftingTabs = new ConfigMetadata("Biome-Sorted Crafting Tabs Override", "Overrides the player's local Biome-Sorted Crafting Tabs setting.", "06 - Server Overrides (Synced)", 105);

			public static readonly ConfigMetadata OverrideCurrentDay = new ConfigMetadata("Current Day Override", "Overrides the player's local Current Day setting.", "06 - Server Overrides (Synced)", 100);

			public static readonly ConfigMetadata OverrideCurrentTime = new ConfigMetadata("Current Time Override", "Overrides the player's local Current Time setting.", "06 - Server Overrides (Synced)", 90);

			public static readonly ConfigMetadata OverrideWeatherForecast = new ConfigMetadata("Weather Forecast Override", "Overrides the player's local Weather Forecast setting.", "06 - Server Overrides (Synced)", 80);

			public static readonly ConfigMetadata OverrideSmartBiome = new ConfigMetadata("Smart Biome Override", "Overrides the player's local Smart Biome setting.", "06 - Server Overrides (Synced)", 70);

			public static readonly ConfigMetadata OverrideAlternateBiomeNames = new ConfigMetadata("Alternate Biome Names Mode Override", "Overrides the player's local Alternate Biome Names display mode.", "06 - Server Overrides (Synced)", 65);

			public static readonly ConfigMetadata OverrideAshlandsHeat = new ConfigMetadata("Ashlands Heat Meter Override", "Overrides the player's local Ashlands Heat Meter setting.", "06 - Server Overrides (Synced)", 60);

			public static readonly ConfigMetadata OverrideEnemyNameplates = new ConfigMetadata("Enemy Nameplate Mode Override", "Overrides the player's local Enemy Nameplate Mode setting.", "06 - Server Overrides (Synced)", 50);

			public static readonly ConfigMetadata OverrideTamingProgress = new ConfigMetadata("Taming Progress Override", "Overrides the player's local Taming Progress setting.", "06 - Server Overrides (Synced)", 40);

			public static readonly ConfigMetadata OverrideDetailedHovers = new ConfigMetadata("Detailed Hover Information Override", "Choose whether Detailed Hover Information uses the player's local setting, is forced on, or is forced off.", "06 - Server Overrides (Synced)", 30);

			public static readonly ConfigMetadata OverrideContainerContents = new ConfigMetadata("Container Contents Override", "Overrides the player's local Container Contents setting.", "06 - Server Overrides (Synced)", 20);

			public static readonly ConfigMetadata OverrideGlobalChatByDefault = new ConfigMetadata("Global Chat By Default Override", "Overrides the player's local Global Chat By Default setting.", "06 - Server Overrides (Synced)", 10);

			public static readonly ConfigMetadata OverrideNotificationMode = new ConfigMetadata("Notification Mode Override", "Overrides the player's local Notification Mode setting.", "06 - Server Overrides (Synced)", 5);
		}

		private static readonly LogManager log = new LogManager("Config Manager", LogManager.LogLevel.Warning);

		private static ConfigFile Config;

		private static readonly ConfigSync configSync = new ConfigSync("Marsarah.MarsarahUI")
		{
			DisplayName = "MarsarahUI",
			CurrentVersion = "1.5.0",
			MinimumRequiredVersion = "1.5.0"
		};

		private static FileSystemWatcher watcher;

		public static ConfigEntry<UIStyle> UIStyleChoice;

		public static ConfigEntry<InfoRailDisplayMode> InfoRailDisplayModeChoice;

		public static ConfigEntry<bool> UIAnimationsEnabled;

		public static ConfigEntry<bool> BetterLoadingTipsEnabled;

		public static ConfigEntry<PortalTransitionMode> PortalTransitionChoice;

		public static ConfigEntry<bool> ShowCurrentDay;

		public static ConfigEntry<TimeMode> TimeChoice;

		public static ConfigEntry<bool> ColorDayPhases;

		public static ConfigEntry<bool> ShowWeatherForecast;

		public static ConfigEntry<bool> ShowSmartBiome;

		public static ConfigEntry<AlternateBiomeDisplayMode> AlternateBiomeDisplayModeChoice;

		public static ConfigEntry<bool> ShowOnlinePlayers;

		public static ConfigEntry<bool> ShowBoatSpeed;

		public static ConfigEntry<bool> ShowBoatHealth;

		public static ConfigEntry<bool> ShowBossExpirationMessage;

		public static ConfigEntry<bool> ShowHeatLevelInAshlands;

		public static ConfigEntry<bool> ShowRaidTimer;

		public static ConfigEntry<bool> StatusEffectsUnderMinimap;

		public static ConfigEntry<bool> GlobalChatByDefault;

		public static ConfigEntry<bool> ShowCharacterStatistics;

		public static ConfigEntry<Vector2> InfoRailPosition;

		public static ConfigEntry<int> InfoRailScale;

		public static ConfigEntry<InventoryDisplayMode> InventoryDisplayChoice;

		public static ConfigEntry<EnemyDetectorMode> EnemyDetectorChoice;

		public static ConfigEntry<EnemyDetectorPosition> EnemyDetectorPositionChoice;

		public static ConfigEntry<Vector2> EnemyRailPosition;

		public static ConfigEntry<int> EnemyRailScale;

		public static ConfigEntry<bool> ShowSummonCounter;

		public static ConfigEntry<Vector2> SummonCounterPosition;

		public static ConfigEntry<int> SummonCounterScale;

		public static ConfigEntry<bool> ShowSkillProgress;

		public static ConfigEntry<SkillProgressBarColor> SkillProgressBarColorChoice;

		public static ConfigEntry<SkillProgressPercentageLocation> SkillProgressPercentageLocationChoice;

		public static ConfigEntry<BiomeCraftingTabsMode> BiomeCraftingTabsChoice;

		public static ConfigEntry<bool> ShowOwnedResources;

		public static ConfigEntry<EnemyNameplateMode> EnemyNameplateChoice;

		public static ConfigEntry<bool> ShowTamingProgress;

		public static ConfigEntry<ItemQualityMode> ItemQualityIndicatorChoice;

		public static ConfigEntry<ItemQualitySymbol> ItemQualitySymbolChoice;

		public static ConfigEntry<ItemQualityColor> ItemQualityColorChoice;

		public static ConfigEntry<bool> ColoredItemDurabilityBar;

		public static ConfigEntry<HoverInfoMode> DetailedHoverInfoChoice;

		public static ConfigEntry<ContainerContentsMode> ContainerContentsChoice;

		public static ConfigEntry<Vector2> ContainerContentsOffset;

		public static ConfigEntry<int> ContainerContentsScale;

		public static ConfigEntry<ContainerHoverMode> ContainerHoverModeChoice;

		public static ConfigEntry<BeeHoverMode> BeehiveHoverModeChoice;

		public static ConfigEntry<PlantHoverMode> PlantHoverModeChoice;

		public static ConfigEntry<FermenterHoverMode> FermenterHoverModeChoice;

		public static ConfigEntry<CookingStationHoverMode> CookingStationHoverModeChoice;

		public static ConfigEntry<SmelterHoverMode> SmelterHoverModeChoice;

		public static ConfigEntry<EggHoverMode> EggHoverModeChoice;

		public static ConfigEntry<NotificationMode> NotificationModeChoice;

		public static ConfigEntry<Vector2> NotificationPosition;

		public static ConfigEntry<int> NotificationScale;

		public static ConfigEntry<float> NotificationDuration;

		public static ConfigEntry<int> NotificationMaxVisible;

		public static ConfigEntry<bool> ServerOverridesLocked;

		public static ConfigEntry<bool> ServerOverridesEnabled;

		public static ConfigEntry<InfoRailDisplayModeOverride> InfoRailDisplayModeOverrideChoice;

		public static ConfigEntry<BoolOverride> EnemyDetectorOverride;

		public static ConfigEntry<BiomeCraftingTabsModeOverride> BiomeCraftingTabsOverrideChoice;

		public static ConfigEntry<BoolOverride> CurrentDayOverride;

		public static ConfigEntry<TimeModeOverride> CurrentTimeOverride;

		public static ConfigEntry<BoolOverride> WeatherForecastOverride;

		public static ConfigEntry<BoolOverride> SmartBiomeOverride;

		public static ConfigEntry<AlternateBiomeDisplayModeOverride> AlternateBiomeDisplayModeOverrideChoice;

		public static ConfigEntry<BoolOverride> AshlandsHeatOverride;

		public static ConfigEntry<EnemyNameplateModeOverride> EnemyNameplatesOverride;

		public static ConfigEntry<BoolOverride> TamingProgressOverride;

		public static ConfigEntry<BoolOverride> DetailedHoversOverride;

		public static ConfigEntry<BoolOverride> ContainerContentsOverride;

		public static ConfigEntry<BoolOverride> GlobalChatByDefaultOverride;

		public static ConfigEntry<NotificationModeOverride> NotificationModeOverrideChoice;

		private static string ConfigFileName => "Marsarah.MarsarahUI.cfg";

		private static string ConfigFileFullPath
		{
			get
			{
				string configPath = Paths.ConfigPath;
				char directorySeparatorChar = Path.DirectorySeparatorChar;
				return configPath + directorySeparatorChar + ConfigFileName;
			}
		}

		public static InfoRailDisplayMode EffectiveInfoRailDisplayModeChoice => ResolveEnum<InfoRailDisplayMode, InfoRailDisplayModeOverride>(InfoRailDisplayModeChoice, InfoRailDisplayModeOverrideChoice, InfoRailDisplayModeOverride.UserChoice);

		public static bool EffectiveUIAnimations => UIAnimationsEnabled.Value;

		public static bool EffectiveBetterLoadingTipsEnabled => BetterLoadingTipsEnabled.Value;

		public static bool EffectivePortalTransitionEnabled => PortalTransitionChoice.Value != PortalTransitionMode.Off;

		public static bool EffectiveShowPortalDestinationText => PortalTransitionChoice.Value == PortalTransitionMode.ImagesAndText;

		public static bool EffectiveShowCurrentDay => ResolveBool(ShowCurrentDay, CurrentDayOverride);

		public static TimeMode EffectiveTimeChoice => ResolveEnum<TimeMode, TimeModeOverride>(TimeChoice, CurrentTimeOverride, TimeModeOverride.UserChoice);

		public static bool EffectiveColorDayPhases => ColorDayPhases.Value;

		public static bool EffectiveShowWeatherForecast => ResolveBool(ShowWeatherForecast, WeatherForecastOverride);

		public static bool EffectiveShowSmartBiome => ResolveBool(ShowSmartBiome, SmartBiomeOverride);

		public static AlternateBiomeDisplayMode EffectiveAlternateBiomeDisplayMode => ResolveEnum<AlternateBiomeDisplayMode, AlternateBiomeDisplayModeOverride>(AlternateBiomeDisplayModeChoice, AlternateBiomeDisplayModeOverrideChoice, AlternateBiomeDisplayModeOverride.UserChoice);

		public static bool EffectiveShowBoatSpeed => ShowBoatSpeed.Value;

		public static bool EffectiveShowBoatHealth => ShowBoatHealth.Value;

		public static bool EffectiveShowOnlinePlayers => ShowOnlinePlayers.Value;

		public static bool EffectiveShowBossExpirationMessage => ShowBossExpirationMessage.Value;

		public static bool EffectiveShowHeatLevelInAshlands => ResolveBool(ShowHeatLevelInAshlands, AshlandsHeatOverride);

		public static bool EffectiveShowRaidTimer => ShowRaidTimer.Value;

		public static bool EffectiveStatusEffectsUnderMinimap => StatusEffectsUnderMinimap.Value;

		public static bool EffectiveGlobalChatByDefault => ResolveBool(GlobalChatByDefault, GlobalChatByDefaultOverride);

		public static bool EffectiveShowCharacterStatistics => ShowCharacterStatistics.Value;

		public static InventoryDisplayMode EffectiveInventoryDisplayChoice => InventoryDisplayChoice.Value;

		public static bool EffectiveShowInventoryWeightAndSlots => EffectiveInventoryDisplayChoice != InventoryDisplayMode.Off;

		public static EnemyDetectorMode EffectiveEnemyDetectorChoice
		{
			get
			{
				if (!ServerOverridesEnabled.Value || EnemyDetectorOverride.Value == BoolOverride.UserChoice)
				{
					return EnemyDetectorChoice.Value;
				}
				return EnemyDetectorOverride.Value switch
				{
					BoolOverride.ForceOn => (EnemyDetectorChoice.Value != EnemyDetectorMode.Off) ? EnemyDetectorChoice.Value : EnemyDetectorMode.Consolidated, 
					BoolOverride.ForceOff => EnemyDetectorMode.Off, 
					_ => EnemyDetectorChoice.Value, 
				};
			}
		}

		public static bool EffectiveShowEnemyDetector => EffectiveEnemyDetectorChoice != EnemyDetectorMode.Off;

		public static EnemyDetectorPosition EffectiveEnemyDetectorPositionChoice => EnemyDetectorPositionChoice.Value;

		public static bool EffectiveShowSummonCounter => ShowSummonCounter.Value;

		public static bool EffectiveShowSkillProgress => ShowSkillProgress.Value;

		public static SkillProgressBarColor EffectiveSkillProgressBarColor => SkillProgressBarColorChoice.Value;

		public static SkillProgressPercentageLocation EffectiveSkillProgressPercentageLocation
		{
			get
			{
				if (EffectiveNotificationModeChoice == NotificationMode.Vanilla)
				{
					return SkillProgressPercentageLocation.InformationRail;
				}
				return SkillProgressPercentageLocationChoice.Value;
			}
		}

		public static BiomeCraftingTabsMode EffectiveBiomeCraftingTabsChoice => ResolveEnum<BiomeCraftingTabsMode, BiomeCraftingTabsModeOverride>(BiomeCraftingTabsChoice, BiomeCraftingTabsOverrideChoice, BiomeCraftingTabsModeOverride.UserChoice);

		public static bool EffectiveBiomeSortedCraftingTabs => EffectiveBiomeCraftingTabsChoice != BiomeCraftingTabsMode.Off;

		public static bool EffectiveShowOwnedResources => ShowOwnedResources.Value;

		public static EnemyNameplateMode EffectiveEnemyNameplateChoice => ResolveEnum<EnemyNameplateMode, EnemyNameplateModeOverride>(EnemyNameplateChoice, EnemyNameplatesOverride, EnemyNameplateModeOverride.UserChoice);

		public static bool EffectiveShowTamingProgress => ResolveBool(ShowTamingProgress, TamingProgressOverride);

		public static ItemQualityMode EffectiveItemQualityIndicatorChoice => ItemQualityIndicatorChoice.Value;

		public static ItemQualitySymbol EffectiveItemQualitySymbolChoice => ItemQualitySymbolChoice.Value;

		public static ItemQualityColor EffectiveItemQualityColorChoice => ItemQualityColorChoice.Value;

		public static bool EffectiveColoredItemDurabilityBar => ColoredItemDurabilityBar.Value;

		public static HoverInfoMode EffectiveDetailedHoverInfoChoice
		{
			get
			{
				if (!ServerOverridesEnabled.Value || DetailedHoversOverride.Value == BoolOverride.UserChoice)
				{
					return DetailedHoverInfoChoice.Value;
				}
				return DetailedHoversOverride.Value switch
				{
					BoolOverride.ForceOn => (DetailedHoverInfoChoice.Value != HoverInfoMode.Off) ? DetailedHoverInfoChoice.Value : HoverInfoMode.ColoredText, 
					BoolOverride.ForceOff => HoverInfoMode.Off, 
					_ => DetailedHoverInfoChoice.Value, 
				};
			}
		}

		public static ContainerContentsMode EffectiveContainerContentsChoice
		{
			get
			{
				if (!ServerOverridesEnabled.Value || ContainerContentsOverride.Value == BoolOverride.UserChoice)
				{
					return ContainerContentsChoice.Value;
				}
				return ContainerContentsOverride.Value switch
				{
					BoolOverride.ForceOn => (ContainerContentsChoice.Value != ContainerContentsMode.Off) ? ContainerContentsChoice.Value : ContainerContentsMode.IconsHorizontal, 
					BoolOverride.ForceOff => ContainerContentsMode.Off, 
					_ => ContainerContentsChoice.Value, 
				};
			}
		}

		public static ContainerHoverMode EffectiveContainerHoverModeChoice => ContainerHoverModeChoice.Value;

		public static BeeHoverMode EffectiveBeehiveHoverModeChoice => BeehiveHoverModeChoice.Value;

		public static PlantHoverMode EffectivePlantHoverModeChoice => PlantHoverModeChoice.Value;

		public static FermenterHoverMode EffectiveFermenterHoverModeChoice => FermenterHoverModeChoice.Value;

		public static CookingStationHoverMode EffectiveCookingStationHoverModeChoice => CookingStationHoverModeChoice.Value;

		public static SmelterHoverMode EffectiveSmelterHoverModeChoice => SmelterHoverModeChoice.Value;

		public static EggHoverMode EffectiveEggHoverModeChoice => EggHoverModeChoice.Value;

		public static NotificationMode EffectiveNotificationModeChoice => ResolveEnum<NotificationMode, NotificationModeOverride>(NotificationModeChoice, NotificationModeOverrideChoice, NotificationModeOverride.UserChoice);

		public static Vector2 EffectiveNotificationPosition => NotificationPosition.Value;

		public static int EffectiveNotificationScale => NotificationScale.Value;

		public static float EffectiveNotificationDuration => NotificationDuration.Value;

		public static int EffectiveNotificationMaxVisible => NotificationMaxVisible.Value;

		public static void Init(ConfigFile configFile)
		{
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: 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_03d4: Unknown result type (might be due to invalid IL or missing references)
			Config = configFile;
			UIStyleChoice = CreateConfig(Configs.UIStyle, UIStyle.Style1);
			UIStyleManager.Initialize(UIStyleChoice);
			InfoRailDisplayModeChoice = CreateConfig(Configs.UIInfoRailDisplayMode, InfoRailDisplayMode.Icons);
			UIAnimationsEnabled = CreateConfig(Configs.UIAnimations, defaultValue: true);
			BetterLoadingTipsEnabled = CreateConfig(Configs.UIBetterLoadingTips, defaultValue: true);
			PortalTransitionChoice = CreateConfig(Configs.UIPortalTransition, PortalTransitionMode.Images);
			ShowCurrentDay = CreateConfig(Configs.UICurrentDay, defaultValue: true);
			TimeChoice = CreateConfig(Configs.UITimeMode, TimeMode.DigitalClock);
			ColorDayPhases = CreateConfig(Configs.UIColorDayPhases, defaultValue: true);
			ShowWeatherForecast = CreateConfig(Configs.UIWeatherForecast, defaultValue: true);
			ShowSmartBiome = CreateConfig(Configs.UISmartBiome, defaultValue: true);
			AlternateBiomeDisplayModeChoice = CreateConfig(Configs.UIAlternateBiomeNames, AlternateBiomeDisplayMode.OneRow);
			ShowBoatSpeed = CreateConfig(Configs.UIBoatSpeed, defaultValue: true);
			ShowBoatHealth = CreateConfig(Configs.UIBoatHealth, defaultValue: true);
			ShowOnlinePlayers = CreateConfig(Configs.UIOnlinePlayers, defaultValue: true);
			ShowBossExpirationMessage = CreateConfig(Configs.UIShowPowerExpiration, defaultValue: true);
			ShowHeatLevelInAshlands = CreateConfig(Configs.UIAshlandsHeatLevel, defaultValue: true);
			ShowRaidTimer = CreateConfig(Configs.UIRaidTimer, defaultValue: true);
			StatusEffectsUnderMinimap = CreateConfig(Configs.UIStatusEffectsUnderMinimap, defaultValue: true);
			GlobalChatByDefault = CreateConfig(Configs.UIGlobalChatByDefault, defaultValue: true);
			ShowCharacterStatistics = CreateConfig(Configs.UICharacterStatistics, defaultValue: true);
			InfoRailPosition = CreateConfig<Vector2>(Configs.UIInfoRailPosition, new Vector2(-88f, -230f));
			InfoRailScale = CreateScaleConfig(Configs.UIInfoRailScale, 100);
			InventoryDisplayChoice = CreateConfig(Configs.UIInventoryWeightAndSlots, InventoryDisplayMode.WeightAndFreeSlots);
			EnemyDetectorChoice = CreateConfig(Configs.UIEnemyDetector, EnemyDetectorMode.Consolidated);
			EnemyDetectorPositionChoice = CreateConfig(Configs.UIEnemyDetectorPosition, EnemyDetectorPosition.TopCenter);
			EnemyRailPosition = CreateConfig<Vector2>(Configs.UIEnemyRailPosition, new Vector2(0f, -44f));
			EnemyRailScale = CreateScaleConfig(Configs.UIEnemyRailScale, 100);
			ShowSummonCounter = CreateConfig(Configs.UISummonCounter, defaultValue: true);
			SummonCounterPosition = CreateConfig<Vector2>(Configs.UISummonCounterPosition, new Vector2(38f, -85f));
			SummonCounterScale = CreateScaleConfig(Configs.UISummonCounterScale, 100);
			ShowSkillProgress = CreateConfig(Configs.UIShowSkillProgress, defaultValue: true);
			SkillProgressBarColorChoice = CreateConfig(Configs.UISkillProgressBarColor, SkillProgressBarColor.Gold);
			SkillProgressPercentageLocationChoice = CreateConfig(Configs.UISkillProgressPercentageLocation, SkillProgressPercentageLocation.NotificationArea);
			BiomeCraftingTabsChoice = CreateConfig(Configs.UIBiomeSortedCraftingTabs, BiomeCraftingTabsMode.Scrolling);
			ShowOwnedResources = CreateConfig(Configs.UIShowOwnedResources, defaultValue: true);
			EnemyNameplateChoice = CreateConfig(Configs.UIEnemyNameplateMode, EnemyNameplateMode.BarsWithHealth);
			ShowTamingProgress = CreateConfig(Configs.UITamingProgress, defaultValue: true);
			ItemQualityIndicatorChoice = CreateConfig(Configs.UIItemQualityIndicatorMode, ItemQualityMode.Horizontal);
			ItemQualitySymbolChoice = CreateConfig(Configs.UIItemQualitySymbol, ItemQualitySymbol.Star);
			ItemQualityColorChoice = CreateConfig(Configs.UIItemQualityColor, ItemQualityColor.Yellow);
			ColoredItemDurabilityBar = CreateConfig(Configs.UIItemDurabilityColor, defaultValue: true);
			DetailedHoverInfoChoice = CreateConfig(Configs.UIHoverInfoMode, HoverInfoMode.ColoredText);
			ContainerContentsChoice = CreateConfig(Configs.UIContainerContents, ContainerContentsMode.IconsHorizontal);
			ContainerContentsOffset = CreateConfig<Vector2>(Configs.UIContainerContentsOffset, Vector2.zero);
			ContainerContentsScale = CreateScaleConfig(Configs.UIContainerContentsScale, 100);
			ContainerHoverModeChoice = CreateConfig(Configs.UIContainerHoverMode, ContainerHoverMode.CurrentPerMax);
			BeehiveHoverModeChoice = CreateConfig(Configs.UIBeeHoverMode, BeeHoverMode.RemainingTime);
			PlantHoverModeChoice = CreateConfig(Configs.UIPlantHoverMode, PlantHoverMode.RemainingTime);
			FermenterHoverModeChoice = CreateConfig(Configs.UIFermenterHoverMode, FermenterHoverMode.RemainingTime);
			CookingStationHoverModeChoice = CreateConfig(Configs.UICookingStationHoverMode, CookingStationHoverMode.RemainingTime);
			SmelterHoverModeChoice = CreateConfig(Configs.UISmelterHoverMode, SmelterHoverMode.RemainingTime);
			EggHoverModeChoice = CreateConfig(Configs.UIEggHoverMode, EggHoverMode.RemainingTime);
			NotificationModeChoice = CreateConfig(Configs.UINotificationMode, NotificationMode.Enhanced);
			NotificationPosition = CreateConfig<Vector2>(Configs.UINotificationPosition, new Vector2(47f, -120f));
			NotificationScale = CreateScaleConfig(Configs.UINotificationScale, 100);
			NotificationDuration = CreateConfig(Configs.UINotificationDuration, 6f);
			NotificationMaxVisible = CreateConfig(Configs.UINotificationMaxVisible, 5);
			ServerOverridesLocked = CreateServerOverride(Configs.LockServerOverrides, defaultValue: true);
			configSync.AddLockingConfigEntry<bool>(ServerOverridesLocked);
			ServerOverridesEnabled = CreateServerOverride(Configs.EnableServerOverrides, defaultValue: true);
			InfoRailDisplayModeOverrideChoice = CreateServerOverride(Configs.OverrideInfoRailDisplayMode, InfoRailDisplayModeOverride.UserChoice);
			EnemyDetectorOverride = CreateServerOverride(Configs.OverrideEnemyDetector, BoolOverride.UserChoice);
			BiomeCraftingTabsOverrideChoice = CreateServerOverride(Configs.OverrideBiomeCraftingTabs, BiomeCraftingTabsModeOverride.UserChoice);
			CurrentDayOverride = CreateServerOverride(Configs.OverrideCurrentDay, BoolOverride.UserChoice);
			CurrentTimeOverride = CreateServerOverride(Configs.OverrideCurrentTime, TimeModeOverride.UserChoice);
			WeatherForecastOverride = CreateServerOverride(Configs.OverrideWeatherForecast, BoolOverride.UserChoice);
			SmartBiomeOverride = CreateServerOverride(Configs.OverrideSmartBiome, BoolOverride.UserChoice);
			AlternateBiomeDisplayModeOverrideChoice = CreateServerOverride(Configs.OverrideAlternateBiomeNames, AlternateBiomeDisplayModeOverride.UserChoice);
			AshlandsHeatOverride = CreateServerOverride(Configs.OverrideAshlandsHeat, BoolOverride.UserChoice);
			EnemyNameplatesOverride = CreateServerOverride(Configs.OverrideEnemyNameplates, EnemyNameplateModeOverride.UserChoice);
			TamingProgressOverride = CreateServerOverride(Configs.OverrideTamingProgress, BoolOverride.UserChoice);
			DetailedHoversOverride = CreateServerOverride(Configs.OverrideDetailedHovers, BoolOverride.UserChoice);
			ContainerContentsOverride = CreateServerOverride(Configs.OverrideContainerContents, BoolOverride.UserChoice);
			GlobalChatByDefaultOverride = CreateServerOverride(Configs.OverrideGlobalChatByDefault, BoolOverride.UserChoice);
			NotificationModeOverrideChoice = CreateServerOverride(Configs.OverrideNotificationMode, NotificationModeOverride.UserChoice);
			SetupWatcher();
		}

		private static ConfigEntry<T> CreateConfig<T>(ConfigMetadata metadata, T defaultValue, AcceptableValueBase acceptableValues = null)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
			{
				Order = metadata.Order
			};
			ConfigEntry<T> val = Config.Bind<T>(metadata.Section, metadata.Name, defaultValue, new ConfigDescription(metadata.Description, acceptableValues, new object[1] { configurationManagerAttributes }));
			val.SettingChanged += delegate
			{
				OnConfigChanged(metadata.Name);
			};
			return val;
		}

		private static ConfigEntry<int> CreateScaleConfig(ConfigMetadata metadata, int defaultValue)
		{
			return CreateConfig(metadata, defaultValue, (AcceptableValueBase)(object)new AcceptableValueRange<int>(50, 150));
		}

		private static ConfigEntry<T> CreateServerOverride<T>(ConfigMetadata metadata, T defaultValue)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
			{
				Order = metadata.Order
			};
			ConfigEntry<T> val = Config.Bind<T>(metadata.Section, metadata.Name, defaultValue, new ConfigDescription(metadata.Description, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
			SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val);
			syncedConfigEntry.SynchronizedConfig = true;
			val.SettingChanged += delegate
			{
				OnConfigChanged(metadata.Name);
			};
			return val;
		}

		private static bool ResolveBool(ConfigEntry<bool> localEntry, ConfigEntry<BoolOverride> overrideEntry)
		{
			if (!ServerOverridesEnabled.Value || overrideEntry.Value == BoolOverride.UserChoice)
			{
				return localEntry.Value;
			}
			return overrideEntry.Value switch
			{
				BoolOverride.ForceOn => true, 
				BoolOverride.ForceOff => false, 
				_ => localEntry.Value, 
			};
		}

		private static TLocal ResolveEnum<TLocal, TOverride>(ConfigEntry<TLocal> localEntry, ConfigEntry<TOverride> overrideEntry, TOverride userChoice) where TLocal : struct where TOverride : struct
		{
			if (!ServerOverridesEnabled.Value || overrideEntry.Value.Equals(userChoice))
			{
				return localEntry.Value;
			}
			if (Enum.TryParse<TLocal>(overrideEntry.Value.ToString(), out var result))
			{
				return result;
			}
			log.Warn($"Could not resolve server override '{((ConfigEntryBase)overrideEntry).Definition.Key}' value '{overrideEntry.Value}'. Falling back to local value.");
			return localEntry.Value;
		}

		private static void SetupWatcher()
		{
			watcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName)
			{
				IncludeSubdirectories = true,
				SynchronizingObject = ThreadingHelper.SynchronizingObject,
				EnableRaisingEvents = true
			};
			watcher.Changed += ReadConfigValues;
			watcher.Created += ReadConfigValues;
			watcher.Renamed += ReadConfigValues;
		}

		private static void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(ConfigFileFullPath))
			{
				return;
			}
			try
			{
				Config.Reload();
			}
			catch
			{
				log.Error("There was an issue loading " + ConfigFileName);
			}
		}

		private static void OnConfigChanged(string configName)
		{
			log.Info("Config setting '" + configName + "' changed!");
			Config.Save();
			if (configName == Configs.UICurrentDay.Name || configName == Configs.UITimeMode.Name || configName == Configs.OverrideCurrentDay.Name || configName == Configs.OverrideCurrentTime.Name || configName == Configs.EnableServerOverrides.Name)
			{
				UITimeAndDay.UpdatePositions();
			}
			if (configName == Configs.UIAnimations.Name)
			{
				UIInfoRail.ApplyAnimationSetting();
				UISummonDisplay.ApplyAnimationSetting();
				UINotifications.ApplyAnimationSetting();
			}
			if (configName == Configs.UIAlternateBiomeNames.Name || configName == Configs.OverrideAlternateBiomeNames.Name || configName == Configs.EnableServerOverrides.Name)
			{
				UIAlternateBiomeNames.RefreshFromConfig();
			}
			if (configName == Configs.UIInfoRailPosition.Name || configName == Configs.UIInfoRailScale.Name)
			{
				UIInfoRail.ApplyInfoRailTransform();
			}
			if (configName == Configs.UIEnemyRailPosition.Name || configName == Configs.UIEnemyRailScale.Name)
			{
				UIInfoRail.ApplyEnemyRailTransform();
			}
			if (configName == Configs.UISummonCounterPosition.Name || configName == Configs.UISummonCounterScale.Name)
			{
				UISummonDisplay.ApplySummonCounterTransform();
			}
			if (configName == Configs.UIBiomeSortedCraftingTabs.Name || configName == Configs.OverrideBiomeCraftingTabs.Name || configName == Configs.EnableServerOverrides.Name)
			{
				UICraftingTabs.RefreshFromConfig();
			}
			if (configName == Configs.UIItemQualityIndicatorMode.Name || configName == Configs.UIItemQualitySymbol.Name || configName == Configs.UIItemQualityColor.Name)
			{
				UIItemQuality.UpdateSymbols();
			}
			if (configName == Configs.UIHoverInfoMode.Name || configName == Configs.UIContainerContents.Name || configName == Configs.UIContainerContentsOffset.Name || configName == Configs.UIContainerContentsScale.Name || configName == Configs.OverrideDetailedHovers.Name || configName == Configs.OverrideContainerContents.Name || configName == Configs.EnableServerOverrides.Name)
			{
				UIContainerContents.HideContainerContents();
			}
			if (configName == Configs.UINotificationMode.Name || configName == Configs.OverrideNotificationMode.Name || configName == Configs.EnableServerOverrides.Name || configName == Configs.UINotificationDuration.Name || configName == Configs.UINotificationMaxVisible.Name)
			{
				UINotifications.RefreshFromConfig();
			}
			if (configName == Configs.UINotificationMode.Name || configName == Configs.OverrideNotificationMode.Name || configName == Configs.EnableServerOverrides.Name || configName == Configs.UIShowSkillProgress.Name || configName == Configs.UISkillProgressPercentageLocation.Name)
			{
				UIInfoRail.RefreshSkillProgressPercentageLocation();
			}
			if (configName == Configs.UINotificationPosition.Name || configName == Configs.UINotificationScale.Name)
			{
				UINotifications.ApplyNotificationTransform();
			}
		}
	}
	internal static class IconManager
	{
		private static readonly LogManager log = new LogManager("Icon Manager", LogManager.LogLevel.Warning);

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

		private const string HudIconResourcePrefix = "MarsarahUI.Assets.Icons.HUD.";

		private static readonly MethodInfo loadImageMethod = GetLoadImageMethod();

		public static Sprite LoadHudIcon(string iconName)
		{
			if (string.IsNullOrEmpty(iconName))
			{
				return null;
			}
			return LoadEmbeddedIcon("MarsarahUI.Assets.Icons.HUD." + iconName + ".png");
		}

		internal static Sprite LoadEmbeddedIcon(string resourceName)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_010a: 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)
			if (string.IsNullOrEmpty(resourceName))
			{
				return null;
			}
			if (icons.TryGetValue(resourceName, out var value))
			{
				return value;
			}
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			using Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
			if (stream == null)
			{
				log.Warn("Icon resource '" + resourceName + "' not found in assembly.");
				return null;
			}
			byte[] data;
			using (MemoryStream memoryStream = new MemoryStream())
			{
				stream.CopyTo(memoryStream);
				data = memoryStream.ToArray();
			}
			Texture2D val = new Texture2D(2, 2);
			if (!TryLoadImageBytes(val, data))
			{
				log.Error("Failed to decode image bytes for '" + resourceName + "'.");
				Object.Destroy((Object)(object)val);
				return null;
			}
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			icons[resourceName] = val2;
			return val2;
		}

		private static bool TryLoadImageBytes(Texture2D texture, byte[] data)
		{
			if ((Object)(object)texture == (Object)null || data == null)
			{
				return false;
			}
			if (loadImageMethod == null)
			{
				return false;
			}
			try
			{
				object obj = loadImageMethod.Invoke(null, new object[3] { texture, data, false });
				bool flag = default(bool);
				int num;
				if (obj is bool)
				{
					flag = (bool)obj;
					num = 1;
				}
				else
				{
					num = 0;
				}
				return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
			}
			catch (Exception arg)
			{
				log.Error($"Failed to load image bytes: {arg}");
				return false;
			}
		}

		private static MethodInfo GetLoadImageMethod()
		{
			try
			{
				Assembly assembly = Assembly.Load("UnityEngine.ImageConversionModule");
				Type type = assembly.GetType("UnityEngine.ImageConversion");
				if (type == null)
				{
					log.Error("Could not find UnityEngine.ImageConversion type.");
					return null;
				}
				return type.GetMethod("LoadImage", BindingFlags.Static | BindingFlags.Public, null, new Type[3]
				{
					typeof(Texture2D),
					typeof(byte[]),
					typeof(bool)
				}, null);
			}
			catch (Exception arg)
			{
				log.Error($"Failed to locate ImageConversion.LoadImage: {arg}");
				return null;
			}
		}
	}
	internal class LogManager
	{
		public enum LogLevel
		{
			None,
			Error,
			Warning,
			Info
		}

		private readonly string classLogTitle;

		private LogLevel classLogLevel;

		private static LogLevel globalLogLevel;

		public LogManager(string logTitle, LogLevel level)
		{
			classLogTitle = logTitle;
			classLogLevel = level;
		}

		public static void SetGlobalLogLevel(LogLevel level)
		{
			globalLogLevel = level;
		}

		public void SetClassLogLevel(LogLevel level)
		{
			classLogLevel = level;
		}

		private bool ShouldLog(LogLevel messageLevel)
		{
			return messageLevel <= classLogLevel && messageLevel <= globalLogLevel;
		}

		public void Info(string message, bool header = false, bool footer = false)
		{
			if (ShouldLog(LogLevel.Info))
			{
				if (header)
				{
					Debug.Log((object)"===================================================");
				}
				Debug.Log((object)("[Marsarah UI] [" + classLogTitle + "] : " + message));
				if (footer)
				{
					Debug.Log((object)"===================================================");
				}
			}
		}

		public void Warn(string message, bool header = false, bool footer = false)
		{
			if (ShouldLog(LogLevel.Warning))
			{
				if (header)
				{
					Debug.Log((object)"===================================================");
				}
				Debug.LogWarning((object)("[Marsarah UI] [" + classLogTitle + "] : " + message));
				if (footer)
				{
					Debug.Log((object)"===================================================");
				}
			}
		}

		public void Error(string message, bool header = false, bool footer = false)
		{
			if (ShouldLog(LogLevel.Error))
			{
				if (header)
				{
					Debug.Log((object)"===================================================");
				}
				Debug.LogError((object)("[Marsarah UI] [" + classLogTitle + "] : " + message));
				if (footer)
				{
					Debug.Log((object)"===================================================");
				}
			}
		}
	}
	internal enum UIBackgroundType
	{
		None,
		UnityImage,
		VanillaSlicedSprite
	}
	internal enum UIBorderType
	{
		None,
		UnityBorder,
		SideCapsSprite
	}
	internal enum UIColorMode
	{
		Fixed,
		WeightGradient,
		SlotsGradient,
		EnemyCountGradient,
		SummonCountGradient
	}
	internal sealed class UIStyleDefinition
	{
		internal UIBackgroundType BackgroundType;

		internal string VanillaBackgroundSprite;

		internal Color BackgroundColor;

		internal UIBorderType BorderType;

		internal UIBorderType SummonBorderType;

		internal string BorderCapAsset;

		internal Color BorderColor;

		internal Vector2 BorderCapSize;

		internal Color BorderOuterColor;

		internal Color BorderInnerColor;

		internal float BorderOuterWidth;

		internal float BorderInnerWidth;

		internal string WeightIcon;

		internal string SlotsIcon;

		internal string EnemyIcon;

		internal string ToughEnemyIcon;

		internal string BossIcon;

		internal string NeutralIcon;

		internal string SummonIcon;

		internal string BoatIcon;

		internal string BoatSpeedIcon;

		internal float RailHeight;

		internal RectOffset RailPadding;

		internal float SeparatorWidth;

		internal float SeparatorLineWidth;

		internal float SeparatorHeight;

		internal Color SeparatorColor;

		internal bool UseSeparatorEdge;

		internal Color SeparatorEdgeColor;

		internal Color SeparatorHighlightColor;

		internal float SeparatorEdgeWidth;

		internal float SeparatorHighlightWidth;

		internal Vector2 SummonSize;

		internal Color ValueTextColor;

		internal Color WeightFillColor;

		internal Color LabelTextColor;

		internal Color SlotsTextColor;

		internal Color EnemyTextColor;

		internal Color ToughEnemyTextColor;

		internal Color BossTextColor;

		internal Color NeutralTextColor;

		internal Color SkillTextColor;

		internal Color SummonTextColor;

		internal UIColorMode WeightFillColorMode;

		internal UIColorMode SlotsTextColorMode;

		internal UIColorMode EnemyTextColorMode;

		internal UIColorMode SummonTextColorMode;
	}
	internal static class UIStyleManager
	{
		private static readonly LogManager log = new LogManager("UI Style Manager", LogManager.LogLevel.Warning);

		private static readonly UIStyleDefinition style1 = new UIStyleDefinition
		{
			BackgroundType = UIBackgroundType.VanillaSlicedSprite,
			VanillaBackgroundSprite = "InputFieldBackground",
			BackgroundColor = new Color(0f, 0f, 0f, 0.4f),
			BorderType = UIBorderType.None,
			SummonBorderType = UIBorderType.None,
			BorderColor = Color.white,
			WeightIcon = "Style1.Weight",
			SlotsIcon = "Style1.Slots",
			EnemyIcon = "Style1.Enemy",
			ToughEnemyIcon = "Style1.ToughEnemy",
			BossIcon = "Style1.Boss",
			NeutralIcon = "Style1.Neutral",
			SummonIcon = "Style1.Summon",
			BoatIcon = "Style1.Boat",
			BoatSpeedIcon = "Style1.BoatSpeed",
			RailHeight = 30f,
			RailPadding = new RectOffset(7, 7, 3, 3),
			SeparatorWidth = 7f,
			SeparatorLineWidth = 1f,
			SeparatorHeight = 18f,
			SeparatorColor = new Color(1f, 1f, 1f, 0.2f),
			UseSeparatorEdge = false,
			SummonSize = new Vector2(49f, 30f),
			ValueTextColor = new Color(0.95f, 0.95f, 0.92f),
			WeightFillColor = new Color(1f, 61f / 85f, 0.3568628f),
			LabelTextColor = new Color(1f, 61f / 85f, 0.3568628f),
			SlotsTextColor = new Color(0.95f, 0.95f, 0.92f),
			EnemyTextColor = new Color(0.95f, 0.95f, 0.92f),
			ToughEnemyTextColor = new Color(0.95f, 0.95f, 0.92f),
			BossTextColor = new Color(0.95f, 0.95f, 0.92f),
			NeutralTextColor = new Color(0.95f, 0.95f, 0.92f),
			SkillTextColor = new Color(0.95f, 0.95f, 0.92f),
			SummonTextColor = new Color(0.95f, 0.95f, 0.92f),
			WeightFillColorMode = UIColorMode.Fixed,
			SlotsTextColorMode = UIColorMode.Fixed,
			EnemyTextColorMode = UIColorMode.Fixed,
			SummonTextColorMode = UIColorMode.Fixed
		};

		private static readonly UIStyleDefinition style2 = new UIStyleDefinition
		{
			BackgroundType = UIBackgroundType.VanillaSlicedSprite,
			VanillaBackgroundSprite = "InputFieldBackground",
			BackgroundColor = new Color(0f, 0f, 0f, 0.45f),
			BorderType = UIBorderType.SideCapsSprite,
			SummonBorderType = UIBorderType.SideCapsSprite,
			BorderCapAsset = "Style2.BorderCap",
			BorderColor = Color.white,
			BorderCapSize = new Vector2(18f, 36f),
			WeightIcon = "Style2.Weight",
			SlotsIcon = "Style2.Slots",
			EnemyIcon = "Style2.Enemy",
			ToughEnemyIcon = "Style2.ToughEnemy",
			BossIcon = "Style2.Boss",
			NeutralIcon = "Style2.Neutral",
			SummonIcon = "Style2.Summon",
			BoatIcon = "Style2.Boat",
			BoatSpeedIcon = "Style2.BoatSpeed",
			RailHeight = 30f,
			RailPadding = new RectOffset(7, 7, 3, 3),
			SeparatorWidth = 7f,
			SeparatorLineWidth = 2f,
			SeparatorHeight = 22f,
			SeparatorColor = new Color(0.62f, 0.52f, 0.34f, 1f),
			UseSeparatorEdge = true,
			SeparatorEdgeColor = new Color(0.18f, 0.1f, 0.05f, 0.8f),
			SeparatorHighlightColor = new Color(0.95f, 0.72f, 0.35f, 0.85f),
			SeparatorEdgeWidth = 3f,
			SeparatorHighlightWidth = 1f,
			SummonSize = new Vector2(49f, 30f),
			ValueTextColor = Color.white,
			WeightFillColor = Color.green,
			LabelTextColor = new Color(0.95f, 0.95f, 0.92f),
			SlotsTextColor = Color.yellow,
			EnemyTextColor = Color.red,
			ToughEnemyTextColor = new Color(1f, 0.549019f, 0f),
			BossTextColor = new Color(0.75f, 0.4f, 1f),
			NeutralTextColor = new Color(1f, 0.75f, 0.2f),
			SkillTextColor = new Color(1f, 0.75f, 0.2f),
			SummonTextColor = Color.white,
			WeightFillColorMode = UIColorMode.WeightGradient,
			SlotsTextColorMode = UIColorMode.SlotsGradient,
			EnemyTextColorMode = UIColorMode.EnemyCountGradient,
			SummonTextColorMode = UIColorMode.SummonCountGradient
		};

		private static readonly UIStyleDefinition style3 = new UIStyleDefinition
		{
			BackgroundType = UIBackgroundType.VanillaSlicedSprite,
			VanillaBackgroundSprite = "InputFieldBackground",
			BackgroundColor = new Color(0f, 0f, 0f, 0.45f),
			BorderType = UIBorderType.UnityBorder,
			SummonBorderType = UIBorderType.None,
			BorderColor = new Color(0.58f, 0.58f, 0.55f, 1f),
			BorderOuterColor = new Color(0.12f, 0.12f, 0.12f, 1f),
			BorderInnerColor = new Color(0.28f, 0.28f, 0.27f, 1f),
			BorderOuterWidth = 2f,
			BorderInnerWidth = 1f,
			WeightIcon = "Style3.Weight",
			SlotsIcon = "Style3.Slots",
			EnemyIcon = "Style3.Enemy",
			ToughEnemyIcon = "Style3.ToughEnemy",
			BossIcon = "Style3.Boss",
			NeutralIcon = "Style3.Neutral",
			SummonIcon = "Style3.Summon",
			BoatIcon = "Style3.Boat",
			BoatSpeedIcon = "Style3.BoatSpeed",
			RailHeight = 34f,
			RailPadding = new RectOffset(7, 7, 3, 3),
			SeparatorWidth = 7f,
			SeparatorLineWidth = 1f,
			SeparatorHeight = 18f,
			SeparatorColor = new Color(1f, 1f, 1f, 0.4f),
			UseSeparatorEdge = false,
			SummonSize = new Vector2(49f, 34f),
			ValueTextColor = new Color(0.88f, 0.87f, 0.82f),
			WeightFillColor = new Color(0.333f, 0.357f, 0.369f),
			LabelTextColor = new Color(0.88f, 0.87f, 0.82f),
			SlotsTextColor = new Color(0.88f, 0.87f, 0.82f),
			EnemyTextColor = new Color(0.88f, 0.87f, 0.82f),
			ToughEnemyTextColor = new Color(0.88f, 0.87f, 0.82f),
			BossTextColor = new Color(0.88f, 0.87f, 0.82f),
			NeutralTextColor = new Color(0.88f, 0.87f, 0.82f),
			SkillTextColor = new Color(0.88f, 0.87f, 0.82f),
			SummonTextColor = new Color(0.88f, 0.87f, 0.82f),
			WeightFillColorMode = UIColorMode.Fixed,
			SlotsTextColorMode = UIColorMode.Fixed,
			EnemyTextColorMode = UIColorMode.Fixed,
			SummonTextColorMode = UIColorMode.Fixed
		};

		private static readonly Dictionary<ConfigManager.UIStyle, UIStyleDefinition> styles = new Dictionary<ConfigManager.UIStyle, UIStyleDefinition>
		{
			{
				ConfigManager.UIStyle.Style1,
				style1
			},
			{
				ConfigManager.UIStyle.Style2,
				style2
			},
			{
				ConfigManager.UIStyle.Style3,
				style3
			}
		};

		private static ConfigEntry<ConfigManager.UIStyle> styleConfig;

		internal static UIStyleDefinition Current { get; private set; } = style1;

		internal static event Action StyleChanged;

		internal static void Initialize(ConfigEntry<ConfigManager.UIStyle> config)
		{
			if (styleConfig != null)
			{
				styleConfig.SettingChanged -= OnStyleSettingChanged;
			}
			styleConfig = config;
			if (styleConfig != null)
			{
				styleConfig.SettingChanged += OnStyleSettingChanged;
			}
			RefreshStyle(notify: false);
		}

		private static void OnStyleSettingChanged(object sender, EventArgs e)
		{
			RefreshStyle(notify: true);
		}

		private static void RefreshStyle(bool notify)
		{
			ConfigManager.UIStyle key = styleConfig?.Value ?? ConfigManager.UIStyle.Style1;
			Current = styles[key];
			if (notify)
			{
				UIStyleManager.StyleChanged?.Invoke();
			}
		}

		internal static Color GetWeightFillColor(float weightPercent)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			UIColorMode weightFillColorMode = Current.WeightFillColorMode;
			UIColorMode uIColorMode = weightFillColorMode;
			if (uIColorMode == UIColorMode.WeightGradient)
			{
				return GetUsageGradientColor(weightPercent);
			}
			return Current.WeightFillColor;
		}

		internal static Color GetSlotsTextColor(float slotsUsedPercent)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			UIColorMode slotsTextColorMode = Current.SlotsTextColorMode;
			UIColorMode uIColorMode = slotsTextColorMode;
			if (uIColorMode == UIColorMode.SlotsGradient)
			{
				return GetUsageGradientColor(Mathf.Clamp01(slotsUsedPercent / 100f));
			}
			return Current.SlotsTextColor;
		}

		internal static Color GetEnemyTextColor(int enemyCount)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			UIColorMode enemyTextColorMode = Current.EnemyTextColorMode;
			UIColorMode uIColorMode = enemyTextColorMode;
			if (uIColorMode == UIColorMode.EnemyCountGradient)
			{
				return GetCountGradientColor(enemyCount);
			}
			return Current.EnemyTextColor;
		}

		private static Color GetUsageGradientColor(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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			Color green = Color.green;
			Color yellow = Color.yellow;
			Color val = default(Color);
			((Color)(ref val))..ctor(1f, 0.549019f, 0f);
			percent = Mathf.Clamp01(percent);
			if (percent <= 0.33f)
			{
				return green;
			}
			if (percent <= 0.66f)
			{
				return Color.Lerp(green, yellow, (percent - 0.33f) / 0.33f);
			}
			if (percent < 1f)
			{
				return Color.Lerp(yellow, val, (percent - 0.66f) / 0.34f);
			}
			return Color.red;
		}

		private static Color GetCountGradientColor(int count)
		{
			//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 (count < 3)
			{
				return Color.green;
			}
			if (count < 5)
			{
				return Color.yellow;
			}
			if (count < 7)
			{
				return new Color(1f, 0.549019f, 0f);
			}
			return Color.red;
		}

		internal static Color GetSummonTextColor(int summonCount)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			UIColorMode summonTextColorMode = Current.SummonTextColorMode;
			UIColorMode uIColorMode = summonTextColorMode;
			if (uIColorMode == UIColorMode.SummonCountGradient)
			{
				return GetSummonCountColor(summonCount);
			}
			return Current.SummonTextColor;
		}

		private static Color GetSummonCountColor(int count)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (count < 2)
			{
				return new Color(1f, 0.549019f, 0f);
			}
			if (count == 2 || count == 3)
			{
				return Color.yellow;
			}
			if (count >= 4)
			{
				return Color.green;
			}
			return Current.SummonTextColor;
		}
	}
}
namespace MarsarahUI.Patches.UI
{
	internal class UIAlternateBiomeNames
	{
		[HarmonyPatch(typeof(Minimap), "UpdateBiome")]
		private static class AlternateBiome_MinimapPatch
		{
			private static void Postfix(Minimap __instance, Player player)
			{
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_021e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0223: Unknown result type (might be due to invalid IL or missing references)
				//IL_0261: 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 || (Object)(object)player == (Object)null || WorldGenerator.instance == null)
				{
					return;
				}
				TMP_Text biomeText = default(TMP_Text);
				ref TMP_Text reference = ref biomeText;
				object? obj = biomeNameField?.GetValue(__instance);
				reference = (TMP_Text)((obj is TMP_Text) ? obj : null);
				if ((Object)(object)biomeText == (Object)null)
				{
					return;
				}
				string biome = ((object)player.GetCurrentBiome()/*cast due to .constrained prefix*/).ToString();
				if (lastBiome != biome)
				{
					vanillaBiomeName = biomeText.text;
					lastBiome = biome;
				}
				if (ConfigManager.EffectiveAlternateBiomeDisplayMode == ConfigManager.AlternateBiomeDisplayMode.Off)
				{
					currentAlternateNames.Clear();
					CurrentAlternateSignature = string.Empty;
					return;
				}
				string biomeDisplayName = GetBiomeDisplayName(biome);
				List<string> list = new List<string>();
				BiomeSector biomeSector = WorldGenerator.instance.GetBiomeSector(((Component)player).transform.position, true);
				if (biomeSector != null && biomeSector.AltBiomes != null)
				{
					foreach (AltBiome altBiome in biomeSector.AltBiomes)
					{
						if (altBiome != null && !string.IsNullOrWhiteSpace(altBiome.m_name))
						{
							string shortAlternateName = GetShortAlternateName(altBiome.m_name.Trim(), biomeDisplayName);
							if (!list.Contains(shortAlternateName))
							{
								list.Add(shortAlternateName);
							}
						}
					}
				}
				list = list.OrderBy((string name) => BiomePriority.GetAlternatePriority(biome, name)).ToList();
				currentAlternateNames.Clear();
				currentAlternateNames.AddRange(list);
				currentBaseBiome = biomeDisplayName;
				CurrentAlternateSignature = biomeDisplayName + "|" + string.Join("|", list);
				Rect rect = biomeText.rectTransform.rect;
				float width = ((Rect)(ref rect)).width;
				string text = ((ConfigManager.EffectiveAlternateBiomeDisplayMode == ConfigManager.AlternateBiomeDisplayMode.OneRow) ? "Mg" : "Mg\nMg");
				float maximumHeight = biomeText.GetPreferredValues(text, width, 10000f).y;
				string limitedDisplayName = GetLimitedDisplayName(biomeDisplayName, list, (string candidate) => biomeText.GetPreferredValues(candidate, width, 10000f).y <= maximumHeight + 0.5f);
				biomeText.text = limitedDisplayName;
				if (lastDisplayName != limitedDisplayName)
				{
					log.Info("Minimap biome text updated: " + limitedDisplayName);
					lastDisplayName = limitedDisplayName;
				}
			}
		}

		private static readonly LogManager log = new LogManager("UI Alternate Biome Names", LogManager.LogLevel.Warning);

		private static readonly FieldInfo biomeNameField = AccessTools.Field(typeof(Minimap), "m_biomeNameSmall");

		private static readonly MethodInfo updateBiomeMethod = AccessTools.Method(typeof(Minimap), "UpdateBiome", new Type[1] { typeof(Player) }, (Type[])null);

		private static string lastDisplayName = string.Empty;

		private static string vanillaBiomeName = string.Empty;

		private static string lastBiome = string.Empty;

		private static readonly List<string> currentAlternateNames = new List<string>();

		private static string currentBaseBiome = string.Empty;

		internal static string CurrentAlternateSignature { get; private set; } = string.Empty;

		internal static bool HasAlternateBiomes => currentAlternateNames.Count > 0;

		private static string GetBiomeDisplayName(string biome)
		{
			return biome switch
			{
				"BlackForest" => "Black Forest", 
				"AshLands" => "Ashlands", 
				"DeepNorth" => "Deep North", 
				_ => biome ?? string.Empty, 
			};
		}

		private static string GetShortAlternateName(string name, string biome)
		{
			string text = " " + biome;
			if (name.EndsWith(text, StringComparison.OrdinalIgnoreCase))
			{
				return name.Substring(0, name.Length - text.Length).Trim();
			}
			return name;
		}

		private static string GetLimitedDisplayName(string biome, List<string> alternates, Func<string, bool> fits)
		{
			if (alternates.Count == 0)
			{
				return biome;
			}
			if (alternates.Count == 1)
			{
				string text = alternates[0] + " " + biome;
				if (fits(text))
				{
					return text;
				}
				return TruncateToFit(alternates[0], fits);
			}
			for (int num = alternates.Count; num >= 1; num--)
			{
				string text2 = biome + ": " + string.Join(", ", alternates.GetRange(0, num));
				int num2 = alternates.Count - num;
				if (num2 > 0)
				{
					text2 = text2 + " +" + num2;
				}
				if (fits(text2))
				{
					return text2;
				}
			}
			string text3 = alternates[0] + " +" + (alternates.Count - 1);
			if (fits(text3))
			{
				return text3;
			}
			return TruncateToFit(biome + " +" + alternates.Count, fits);
		}

		private static string TruncateToFit(string value, Func<string, bool> fits)
		{
			if (fits(value))
			{
				return value;
			}
			for (int num = value.Length - 1; num > 0; num--)
			{
				string text = value.Substring(0, num).TrimEnd(Array.Empty<char>()) + "…";
				if (fits(text))
				{
					return text;
				}
			}
			return fits("…") ? "…" : string.Empty;
		}

		internal static string GetSmartBiomeDisplayName(Func<string, bool> fits)
		{
			if (currentAlternateNames.Count == 0)
			{
				return string.Empty;
			}
			return GetLimitedDisplayName(currentBaseBiome, currentAlternateNames, fits);
		}

		internal static void RefreshFromConfig()
		{
			if ((Object)(object)Minimap.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			if (ConfigManager.EffectiveAlternateBiomeDisplayMode == ConfigManager.AlternateBiomeDisplayMode.Off)
			{
				object? obj = biomeNameField?.GetValue(Minimap.instance);
				TMP_Text val = (TMP_Text)((obj is TMP_Text) ? obj : null);
				if (!((Object)(object)val == (Object)null))
				{
					val.text = vanillaBiomeName;
					lastDisplayName = string.Empty;
					currentAlternateNames.Clear();
					CurrentAlternateSignature = string.Empty;
					log.Info("Alternate biome names disabled. Restored original vanilla biome text.");
				}
			}
			else if (updateBiomeMethod == null)
			{
				log.Warn("Could not find Minimap.UpdateBiome method.");
			}
			else
			{
				updateBiomeMethod.Invoke(Minimap.instance, new object[1] { Player.m_localPlayer });
				log.Info("Alternate biome names enabled. Refreshed minimap.");
			}
		}
	}
	internal class UIAshlandsHeatLevel : UIController
	{
		[HarmonyPatch(typeof(Hud), "Awake")]
		private static class HeatLevel_HUDAwakePatch
		{
			private static void Postfix(Hud __instance)
			{
				if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && !((Object)(object)__instance == (Object)null) && ConfigManager.EffectiveShowHeatLevelInAshlands)
				{
					CreateUI(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Update")]
		private static class HeatLevel_HUDUpdatePatch
		{
			private static void Postfix(Hud __instance)
			{
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01da: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_024d: 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.EffectiveShowHeatLevelInAshlands)
				{
					if ((Object)(object)UIHeatBarArea != (Object)null && UIHeatBarArea.activeSelf)
					{
						UIHeatBarArea.SetActive(false);
					}
					return;
				}
				CreateUI(__instance);
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null || (Object)(object)heatBarFill == (Object)null)
				{
					return;
				}
				float heatLevelFirstDamageThreshold = ((Character)localPlayer).m_heatLevelFirstDamageThreshold;
				if (heatLevelFirstDamageThreshold <= 0f)
				{
					return;
				}
				float num = lavaHeatLevelRef.Invoke(localPlayer);
				float num2 = ashlandsOceanHeatLevelRef.Invoke(localPlayer);
				float num3 = ((((Character)localPlayer).InWater() && WorldGenerator.GetAshlandsOceanGradient(((Component)localPlayer).transform.position) >= 0f) ? Mathf.Max(num, num2) : num);
				bool flag = UIController.ShowUI && !IsUIHidden() && !IsLoadScreenActive(__instance);
				if (UIHeatBarArea.activeSelf != flag)
				{
					UIHeatBarArea.SetActive(flag);
				}
				if (flag)
				{
					heatBarFill.fillAmount = Mathf.Clamp01(num3 / heatLevelFirstDamageThreshold);
					float fillAmount = heatBarFill.fillAmount;
					heatBarText.text = $"{fillAmount * 100f:0}%";
					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)
					{
						color.a = 0.6f + 0.4f * Mathf.Sin(Time.time * 4f);
					}
					else
					{
						color.a = 0.8f;
					}
					((Graphic)heatBarFill).color = color;
					bool flag2 = heatBarFill.fillAmount > 0f;
					((Behaviour)heatBarFill).enabled = flag2;
					((Behaviour)heatBarBackground).enabled = flag2;
					((Behaviour)heatBarText).enabled = flag2;
					((Behaviour)heatBarEmojiTMP).enabled = flag2;
					((TMP_Text)heatBarEmojiTMP).text = (flag2 ? "\ud83d\udd25" : "");
				}
			}

			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 readonly LogManager log = new LogManager("UI Ashlands Heat", LogManager.LogLevel.Warning);

		private static Image heatBarFill;

		private static Image heatBarBackground;

		private static GameObject UIHeatBarArea;

		private static Text heatBarText;

		private static TextMeshProUGUI heatBarEmojiTMP;

		private static readonly FieldRef<Player, float> lavaHeatLevelRef = AccessTools.FieldRefAccess<Player, float>("m_lavaHeatLevel");

		private static readonly FieldRef<Player, float> ashlandsOceanHeatLevelRef = AccessTools.FieldRefAccess<Player, float>("m_ashlandsOceanHeatLevel");

		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_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//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_02db: 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 SDF";
				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);
				heatBarBackground = 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)heatBarBackground).color = new Color(0f, 0f, 0f, 0.4f);
				((Behaviour)heatBarBackground).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 tempSprite) => ((Object)tempSprite).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, Vector2.zero, sizeDelta);
				heatBarEmojiTMP = UIController.CreateTMPTextObject("HeatEmojiTMP", UIHeatBarArea, Color.red, fontName2, fontSize2, (TextAlignmentOptions)4100, new Vector2(-2f, 0f), sizeDelta, log);
			}
		}
	}
	internal class UIBoatHealth : UIController
	{
		private static readonly LogManager log = new LogManager("UI Boat Health", LogManager.LogLevel.Warning);

		private const float HealthAreaWidth = 80f;

		private const float HealthAreaHeight = 20f;

		private const float HealthBarWidth = 46f;

		private const float HealthBarHeight = 11f;

		private const float HealthBarRightInset = 4f;

		private const float HealthOffsetBelowSpeed = -27f;

		private const float CriticalHealthThreshold = 0.3f;

		private const float BoatIconX = -23f;

		private const float BoatIconSize = 24f;

		private static GameObject UIHealthArea;

		private static RectTransform healthAreaTransform;

		private static RectTransform healthFillTransform;

		private static Image boatIcon;

		private static Text boatHealthLabel;

		private static Image healthFillImage;

		private static bool warnedMissingHealth;

		private static Ship cachedShip;

		private static WearNTear cachedWear;

		internal static void UpdateUI(GameObject parent, Ship ship, bool enabled, bool showSpeed)
		{
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//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_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Invalid comparison between Unknown and I4
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			if (!enabled || (Object)(object)parent == (Object)null || (Object)(object)ship == (Object)null)
			{
				if ((Object)(object)UIHealthArea != (Object)null)
				{
					UIHealthArea.SetActive(false);
				}
				return;
			}
			CreateUI(parent);
			if ((Object)(object)UIHealthArea == (Object)null)
			{
				return;
			}
			if ((Object)(object)cachedShip != (Object)(object)ship || (Object)(object)cachedWear == (Object)null)
			{
				cachedShip = ship;
				cachedWear = ((Component)ship).GetComponent<WearNTear>();
				if ((Object)(object)cachedWear == (Object)null)
				{
					cachedWear = ((Component)ship).GetComponentInChildren<WearNTear>();
				}
			}
			if ((Object)(object)cachedWear == (Object)null)
			{
				UIHealthArea.SetActive(false);
				if (!warnedMissingHealth)
				{
					log.Warn("The controlled ship '" + ((Object)((Component)ship).gameObject).name + "' has no WearNTear component; boat health cannot be displayed.");
					warnedMissingHealth = true;
				}
				return;
			}
			warnedMissingHealth = false;
			bool flag = ConfigManager.EffectiveInfoRailDisplayModeChoice == ConfigManager.InfoRailDisplayMode.Text;
			if ((Object)(object)boatIcon != (Object)null)
			{
				((Component)boatIcon).gameObject.SetActive(!flag);
			}
			if ((Object)(object)boatHealthLabel != (Object)null)
			{
				((Component)boatHealthLabel).gameObject.SetActive(flag);
				((Graphic)boatHealthLabel).color = UIStyleManager.Current.LabelTextColor;
			}
			if ((Object)(object)healthAreaTransform != (Object)null)
			{
				float num = ((ConfigManager.EffectiveStatusEffectsUnderMinimap && !Game.m_noMap && !showSpeed) ? 0f : (-27f));
				healthAreaTransform.anchoredPosition = new Vector2(0f, num);
			}
			float num2 = Mathf.Clamp01(cachedWear.GetHealthPercentage());
			float weightPercent = Mathf.Clamp01((1f - num2) / 0.7f);
			Color weightFillColor = UIStyleManager.GetWeightFillColor(weightPercent);
			if ((Object)(object)healthFillImage != (Object)null)
			{
				if ((int)healthFillImage.type == 3)
				{
					healthFillImage.fillAmount = num2;
				}
				else if ((Object)(object)healthFillTransform != (Object)null)
				{
					healthFillTransform.SetSizeWithCurrentAnchors((Axis)0, 46f * num2);
				}
				((Graphic)healthFillImage).color = weightFillColor;
			}
			UIHealthArea.SetActive(true);
		}

		private static void CreateUI(GameObject parent)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: 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_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)UIHealthArea != (Object)null) || !((Object)(object)UIHealthArea.transform.parent == (Object)(object)parent.transform))
			{
				UIHealthArea = new GameObject("BoatHealthArea");
				UIHealthArea.layer = 5;
				UIHealthArea.transform.SetParent(parent.transform, false);
				healthAreaTransform = UIHealthArea.AddComponent<RectTransform>();
				healthAreaTransform.anchorMin = new Vector2(0.5f, 0.5f);
				healthAreaTransform.anchorMax = new Vector2(0.5f, 0.5f);
				healthAreaTransform.anchoredPosition = Vector2.zero;
				healthAreaTransform.sizeDelta = new Vector2(80f, 20f);
				((Transform)healthAreaTransform).localScale = Vector3.one;
				boatIcon = UIController.CreateUIImageObject("BoatHealthIcon", UIHealthArea, new Vector2(-23f, 0f), new Vector2(24f, 24f));
				boatIcon.preserveAspect = true;
				((Graphic)boatIcon).raycastTarget = false;
				boatHealthLabel = UIController.CreateTextObject("BoatHealthLabel", UIHealthArea, UIStyleManager.Current.LabelTextColor, "AveriaSansLibre-Bold", 16, (TextAnchor)5, new Vector2(-52f, 0f), new Vector2(72f, 20f));
				boatHealthLabel.text = "Boat HP";
				((Graphic)boatHealthLabel).raycastTarget = false;
				float num = 13f;
				Image val = UIController.CreateUIImageObject("BoatHealthBackground", UIHealthArea, new Vector2(num, 0f), new Vector2(46f, 11f));
				((Graphic)val).color = new Color(0.12f, 0.12f, 0.12f, 0.78f);
				((Graphic)val).raycastTarget = false;
				healthFillImage = UIController.CreateUIImageObject("BoatHealthFill", ((Component)val).gameObject, Vector2.zero, new Vector2(46f, 11f));
				((Graphic)healthFillImage).raycastTarget = false;
				healthFillTransform = ((Graphic)healthFillImage).rectTransform;
				healthFillTransform.anchorMin = new Vector2(0f, 0.5f);
				healthFillTransform.anchorMax = new Vector2(0f, 0.5f);
				healthFillTransform.pivot = new Vector2(0f, 0.5f);
				healthFillTransform.anchoredPosition = Vector2.zero;
				Sprite val2 = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite sprite) => ((Object)sprite).name == "bar_monster_hp_5"));
				if ((Object)(object)val2 != (Object)null)
				{
					healthFillImage.sprite = val2;
					healthFillImage.type = (Type)3;
					healthFillImage.fillMethod = (FillMethod)0;
					healthFillImage.fillOrigin = 0;
					healthFillImage.fillAmount = 1f;
				}
				else
				{
					log.Warn("Could not find the vanilla HP bar sprite. Using the default fill.");
				}
				UIHealthArea.SetActive(false);
				UIStyleManager.StyleChanged -= ApplyBoatIconStyle;
				UIStyleManager.StyleChanged += ApplyBoatIconStyle;
				ApplyBoatIconStyle();
				log.Info("Created boat health indicator.");
			}
		}

		private static void ApplyBoatIconStyle()
		{
			if (!((Object)(object)boatIcon == (Object)null))
			{
				string text = UIStyleManager.Current.BoatIcon;
				boatIcon.sprite = IconManager.LoadHudIcon(text);
				boatIcon.preserveAspect = true;
				if ((Object)(object)boatIcon.sprite == (Object)null)
				{
					log.Warn("Could not load boat icon '" + text + "'.");
				}
			}
		}
	}
	internal class UICraftingTabs
	{
		private sealed class RecipeSortEntry
		{
			internal object RecipeData { get; }

			internal RectTransform Rect { get; }

			internal CraftingTabsLogic.RecipeSortData SortData { get; }

			internal RecipeSortEntry(object recipeData, Recipe recipe, RectTransform rect, int originalIndex, bool canCraft)
			{
				RecipeData = recipeData;
				Rect = rect;
				SortData = new CraftingTabsLogic.RecipeSortData(recipe, originalIndex, canCraft);
			}
		}

		private sealed class RectTransformState
		{
			private readonly Vector2 anchorMin;

			private readonly Vector2 anchorMax;

			private readonly Vector2 pivot;

			private readonly Vector2 anchoredPosition;

			private readonly Vector2 sizeDelta;

			private readonly Vector