using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SpaceCraft;
using TMPro;
using Ui_Tweaks.Modules;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("UnloadedHangar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds colorization to Ui gauges. Configurable!")]
[assembly: AssemblyFileVersion("0.3.0")]
[assembly: AssemblyInformationalVersion("0.2.5+d87a588011a985c052b96195bbe5cf59e4692dc7")]
[assembly: AssemblyProduct("Ui_Tweaks")]
[assembly: AssemblyTitle("Ui_Tweaks")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Ui_Tweaks
{
internal class ConfigManager
{
public ExtendedConfigEntry<bool> EnableConfiguration;
public ExtendedConfigEntry<bool> DebugLogging;
public ExtendedConfigEntry<float> OxygenLowWarningValue;
public ExtendedConfigEntry<float> OxygenCriticalWarningValue;
public ExtendedConfigEntry<float> HungerLowWarningValue;
public ExtendedConfigEntry<float> HungerCriticalWarningValue;
public ExtendedConfigEntry<float> ThirstLowWarningValue;
public ExtendedConfigEntry<float> ThirstCriticalWarningValue;
public ExtendedConfigEntry<float> ToxicHighWarningValue;
public ExtendedConfigEntry<float> ToxicCriticalWarningValue;
public ExtendedConfigEntry<string> OxygenGaugeSystem;
public ExtendedConfigEntry<bool> DisableSideLines;
public ExtendedConfigEntry<bool> DisableVersionAndFpsText;
public ExtendedConfigEntry<string> CompassColor;
public ExtendedConfigEntry<string> InventoryColor;
public ConfigManager()
{
BindConfigs();
ClearUnusedEntries();
}
private void BindConfigs()
{
EnableConfiguration = new ExtendedConfigEntry<bool>("General Settings", "EnableConfiguration", defaultValue: false, "Enable if you want to use custom set config setting values. If disabled, the default config setting values will be used.");
DebugLogging = new ExtendedConfigEntry<bool>("General Settings", "DebugLogging", defaultValue: false, "Enable if you want Debug logging to function.", useEnableConfiguration: true);
OxygenLowWarningValue = new ExtendedConfigEntry<float>("General Settings", "OxygenLowWarningValue", 30f, "When does Oxygen Low warning go off. Value must be bigger than OxygenCriticalWarningValue.", useEnableConfiguration: true);
OxygenCriticalWarningValue = new ExtendedConfigEntry<float>("General Settings", "OxygenCriticalWarningValue", 16f, "When does Oxygen Critical warning go off. Value must be smaller than OxygenLowWarningValue.", useEnableConfiguration: true);
HungerLowWarningValue = new ExtendedConfigEntry<float>("General Settings", "HungerLowWarningValue", 25f, "When does Food Low warning go off. Value must be bigger than HungerCriticalWarningValue.", useEnableConfiguration: true);
HungerCriticalWarningValue = new ExtendedConfigEntry<float>("General Settings", "HungerCriticalWarningValue", 10f, "When does Food Critical warning go off. Value must be smaller than HungerLowWarningValue.", useEnableConfiguration: true);
ThirstLowWarningValue = new ExtendedConfigEntry<float>("General Settings", "ThirstLowWarningValue", 25f, "When does Water Low warning go off. Value must be bigger than ThirstCriticalWarningValue.", useEnableConfiguration: true);
ThirstCriticalWarningValue = new ExtendedConfigEntry<float>("General Settings", "ThirstCriticalWarningValue", 10f, "When does Water Critical warning go off. Value must be smaller than ThirstLowWarningValue.", useEnableConfiguration: true);
ToxicHighWarningValue = new ExtendedConfigEntry<float>("General Settings", "ToxicHighWarningValue", 80f, "When does Toxicity High warning go off. Value must be smaller than ToxicCriticalWarningValue.", useEnableConfiguration: true);
ToxicCriticalWarningValue = new ExtendedConfigEntry<float>("General Settings", "ToxicCriticalWarningValue", 90f, "When does Toxicity Critical warning go off. Value must be bigger than ToxicHighWarningValue.", useEnableConfiguration: true);
OxygenGaugeSystem = new ExtendedConfigEntry<string>("General Settings", "OxygenGaugeSystem", "Dynamic", "What system should the Oxygen gauge use. Options --> Legacy = Uses static setpoints. Dynamic = Calculates setpoints based on the maximal oxygen gauge value.", useEnableConfiguration: true);
DisableSideLines = new ExtendedConfigEntry<bool>("HUD General", "DisableSideLines", defaultValue: false, "Will disable HUD side lines if set true.", useEnableConfiguration: true);
DisableVersionAndFpsText = new ExtendedConfigEntry<bool>("HUD General", "DisableVersionAndFpsText", defaultValue: false, "Will disable HUD version and FPS text if set true(The thing at bottom right of the screen).", useEnableConfiguration: true);
CompassColor = new ExtendedConfigEntry<string>("HUD General", "CompassColor", "#FFFFFF", "What hex color should the compass use.", useEnableConfiguration: true);
InventoryColor = new ExtendedConfigEntry<string>("HUD General", "InventoryColor", "#FFFFFF", "What hex color should the inventory slots use.", useEnableConfiguration: true);
}
private void ClearUnusedEntries()
{
ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config;
PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null);
dictionary.Clear();
config.Save();
}
}
public class ExtendedConfigEntry<T>
{
public ConfigEntry<T> ConfigEntry;
public Func<T> GetValue;
public Action<T> SetValue;
public bool UseEnableConfiguration = false;
public T DefaultValue => (T)((ConfigEntryBase)ConfigEntry).DefaultValue;
public T Value
{
get
{
return GetValue();
}
set
{
SetValue(value);
}
}
public ExtendedConfigEntry(string section, string key, T defaultValue, string description, bool useEnableConfiguration = false)
{
ConfigEntry = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, description);
UseEnableConfiguration = useEnableConfiguration;
Initialize();
}
public ExtendedConfigEntry(string section, string key, T defaultValue, ConfigDescription configDescription = null, bool useEnableConfiguration = false)
{
ConfigEntry = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, configDescription);
UseEnableConfiguration = useEnableConfiguration;
Initialize();
}
private void Initialize()
{
if (GetValue == null)
{
GetValue = () => (UseEnableConfiguration && !Plugin.ConfigManager.EnableConfiguration.Value) ? DefaultValue : ConfigEntry.Value;
}
if (SetValue == null)
{
SetValue = delegate(T value)
{
ConfigEntry.Value = value;
};
}
}
public void ResetToDefault()
{
ConfigEntry.Value = (T)((ConfigEntryBase)ConfigEntry).DefaultValue;
}
}
[BepInProcess("Planet Crafter.exe")]
[BepInPlugin("Ui_Tweaks-UnloadedHangar", "Ui_Tweaks", "0.3.0")]
public class Plugin : BaseUnityPlugin
{
public static class PluginInfo
{
public const string Guid = "Ui_Tweaks-UnloadedHangar";
public const string Name = "Ui_Tweaks";
public const string Ver = "0.3.0";
}
internal static Plugin Instance;
internal static ManualLogSource logger;
internal static ConfigManager ConfigManager;
internal Harmony _harmony;
private void Awake()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
logger = Logger.CreateLogSource("Ui_Tweaks");
logger.LogInfo((object)"Ui_Tweaks has awoken!");
ConfigManager = new ConfigManager();
_harmony = new Harmony("Ui_Tweaks-UnloadedHangar");
_harmony.PatchAll(typeof(OxygenGaugePatch));
_harmony.PatchAll(typeof(HealthGaugePatch));
_harmony.PatchAll(typeof(ThirstGaugePatch));
_harmony.PatchAll(typeof(ToxicGaugePatch));
_harmony.PatchAll(typeof(LinesPatch));
_harmony.PatchAll(typeof(CompassPatch));
_harmony.PatchAll(typeof(InventoryPatch));
}
}
}
namespace Ui_Tweaks.Modules
{
[HarmonyPatch(typeof(PlayerGaugeOxygen))]
internal class OxygenGaugePatch
{
private static Image thisImage;
[HarmonyPrefix]
[HarmonyPatch("GaugeVerifications")]
public static bool GaugeVerifications(PlayerGaugeOxygen __instance)
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
if (((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).isInited)
{
if ((Object)(object)thisImage == (Object)null)
{
thisImage = ((Component)((Component)((Component)((Component)__instance).transform.GetChild(0)).gameObject.GetComponent<Slider>().fillRect).gameObject.transform).gameObject.GetComponent<Image>();
}
if (((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).gaugeValue <= Utils.CheckForInvalidConfigurationValues(OxygenConfigType.OxygenLow, ((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).maxValue, Utils.StringToEnum(Plugin.ConfigManager.OxygenGaugeSystem.Value)) - 10f)
{
((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).playerAudio.SetIsPanting(true);
}
else
{
((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).playerAudio.SetIsPanting(false);
}
if (((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).gaugeValue > Utils.CheckForInvalidConfigurationValues(OxygenConfigType.OxygenLow, ((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).maxValue, Utils.StringToEnum(Plugin.ConfigManager.OxygenGaugeSystem.Value)))
{
__instance.hasAlertedLow = false;
__instance.hasAlertedCritical = false;
((Graphic)thisImage).color = Color.white;
((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).StopBlinking();
}
else if (((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).gaugeValue <= Utils.CheckForInvalidConfigurationValues(OxygenConfigType.OxygenLow, ((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).maxValue, Utils.StringToEnum(Plugin.ConfigManager.OxygenGaugeSystem.Value)) && !__instance.hasAlertedLow)
{
Utils.DisplayInfoText(Object.FindFirstObjectByType<BaseHudHandler>(), "UI_WARN_OXYGEN_LOW", 3f, "", "");
((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).globalAudioHandler.PlayAlertLow();
((Graphic)thisImage).color = Color.yellow;
__instance.hasAlertedLow = true;
}
else if (((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).gaugeValue <= Utils.CheckForInvalidConfigurationValues(OxygenConfigType.OxygenCritical, ((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).maxValue, Utils.StringToEnum(Plugin.ConfigManager.OxygenGaugeSystem.Value)) && !__instance.hasAlertedCritical)
{
Utils.DisplayInfoText(Object.FindFirstObjectByType<BaseHudHandler>(), "UI_WARN_OXYGEN_CRITICAL", 3f, "", "");
((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).globalAudioHandler.PlayAlertCritical();
__instance.hasAlertedCritical = true;
((Graphic)thisImage).color = Color.red;
((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).StartBlinking();
}
else if (((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).gaugeValue <= 0f)
{
((PlayerGauge<PlayerGaugeOxygen>)(object)__instance).playerAudio.PlayDie();
}
}
return false;
}
}
[HarmonyPatch(typeof(PlayerGaugeHealth))]
internal class HealthGaugePatch
{
private static Image thisImage;
[HarmonyPrefix]
[HarmonyPatch("GaugeVerifications")]
public static bool GaugeVerifications(PlayerGaugeHealth __instance)
{
//IL_007a: 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_0151: Unknown result type (might be due to invalid IL or missing references)
if (((PlayerGauge<PlayerGaugeHealth>)(object)__instance).isInited)
{
if ((Object)(object)thisImage == (Object)null)
{
thisImage = ((Component)((Component)((Component)((Component)__instance).transform.GetChild(0)).gameObject.GetComponent<Slider>().fillRect).gameObject.transform).gameObject.GetComponent<Image>();
}
if (((PlayerGauge<PlayerGaugeHealth>)(object)__instance).gaugeValue > Utils.CheckForInvalidConfigurationValues(HungerConfigType.FoodLow))
{
__instance.hasAlertedLow = false;
__instance.hasAlertedCritical = false;
((Graphic)thisImage).color = Color.white;
((PlayerGauge<PlayerGaugeHealth>)(object)__instance).StopBlinking();
}
else if (((PlayerGauge<PlayerGaugeHealth>)(object)__instance).gaugeValue <= Utils.CheckForInvalidConfigurationValues(HungerConfigType.FoodLow) && !__instance.hasAlertedLow)
{
Utils.DisplayInfoText(Object.FindFirstObjectByType<BaseHudHandler>(), "UI_WARN_FOOD_LOW", 3f, "", "");
((PlayerGauge<PlayerGaugeHealth>)(object)__instance).globalAudioHandler.PlayAlertLow();
((Graphic)thisImage).color = Color.yellow;
__instance.hasAlertedLow = true;
}
else if (((PlayerGauge<PlayerGaugeHealth>)(object)__instance).gaugeValue <= Utils.CheckForInvalidConfigurationValues(HungerConfigType.FoodCritical) && !__instance.hasAlertedCritical)
{
Utils.DisplayInfoText(Object.FindFirstObjectByType<BaseHudHandler>(), "UI_WARN_FOOD_CRITICAL", 3f, "", "");
((PlayerGauge<PlayerGaugeHealth>)(object)__instance).globalAudioHandler.PlayAlertCritical();
__instance.hasAlertedCritical = true;
((Graphic)thisImage).color = Color.red;
((PlayerGauge<PlayerGaugeHealth>)(object)__instance).StartBlinking();
}
else if (((PlayerGauge<PlayerGaugeHealth>)(object)__instance).gaugeValue <= 0f)
{
((PlayerGauge<PlayerGaugeHealth>)(object)__instance).playerAudio.PlayDie();
}
}
return false;
}
}
[HarmonyPatch(typeof(PlayerGaugeThirst))]
internal class ThirstGaugePatch
{
private static Image thisImage;
internal static GlobalAudioHandler globalAudioHandlerToCopy { get; private set; }
[HarmonyPrefix]
[HarmonyPatch("GaugeVerifications")]
public static bool GaugeVerifications(PlayerGaugeThirst __instance)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
if (((PlayerGauge<PlayerGaugeThirst>)(object)__instance).isInited)
{
if ((Object)(object)thisImage == (Object)null)
{
thisImage = ((Component)((Component)((Component)((Component)__instance).transform.GetChild(0)).gameObject.GetComponent<Slider>().fillRect).gameObject.transform).gameObject.GetComponent<Image>();
}
if ((Object)(object)globalAudioHandlerToCopy == (Object)null)
{
globalAudioHandlerToCopy = ((PlayerGauge<PlayerGaugeThirst>)(object)__instance).globalAudioHandler;
}
if (((PlayerGauge<PlayerGaugeThirst>)(object)__instance).gaugeValue > Utils.CheckForInvalidConfigurationValues(ThirstConfigType.WaterLow))
{
__instance.hasAlertedLow = false;
__instance.hasAlertedCritical = false;
((Graphic)thisImage).color = Color.white;
((PlayerGauge<PlayerGaugeThirst>)(object)__instance).StopBlinking();
}
else if (((PlayerGauge<PlayerGaugeThirst>)(object)__instance).gaugeValue <= Utils.CheckForInvalidConfigurationValues(ThirstConfigType.WaterLow) && !__instance.hasAlertedLow)
{
Utils.DisplayInfoText(Object.FindFirstObjectByType<BaseHudHandler>(), "UI_WARN_THIRST_LOW", 3f, "", "");
((PlayerGauge<PlayerGaugeThirst>)(object)__instance).globalAudioHandler.PlayAlertLow();
((Graphic)thisImage).color = Color.yellow;
__instance.hasAlertedLow = true;
}
else if (((PlayerGauge<PlayerGaugeThirst>)(object)__instance).gaugeValue <= Utils.CheckForInvalidConfigurationValues(ThirstConfigType.WaterCritical) && !__instance.hasAlertedCritical)
{
Utils.DisplayInfoText(Object.FindFirstObjectByType<BaseHudHandler>(), "UI_WARN_THIRST_CRITICAL", 3f, "", "");
((PlayerGauge<PlayerGaugeThirst>)(object)__instance).globalAudioHandler.PlayAlertCritical();
__instance.hasAlertedCritical = true;
((Graphic)thisImage).color = Color.red;
((PlayerGauge<PlayerGaugeThirst>)(object)__instance).StartBlinking();
}
else if (((PlayerGauge<PlayerGaugeThirst>)(object)__instance).gaugeValue <= 0f)
{
((PlayerGauge<PlayerGaugeThirst>)(object)__instance).playerAudio.PlayDie();
}
}
return false;
}
}
[HarmonyPatch(typeof(PlayerGaugeToxic))]
internal class ToxicGaugePatch
{
private static Image thisImage;
private static bool AlertedCritical;
private static bool AlertedLow;
private static GlobalAudioHandler globalAudioHandler;
[HarmonyPrefix]
[HarmonyPatch("GaugeVerifications")]
public static bool GaugeVerifications(PlayerGaugeToxic __instance)
{
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
if (!((PlayerGauge<PlayerGaugeToxic>)(object)__instance).isInited)
{
((Component)__instance).gameObject.SetActive(false);
return false;
}
if ((Object)(object)thisImage == (Object)null)
{
thisImage = ((Component)((Component)((Component)((Component)__instance).transform.GetChild(0)).gameObject.GetComponent<Slider>().fillRect).gameObject.transform).gameObject.GetComponent<Image>();
}
if ((Object)(object)((PlayerGauge<PlayerGaugeToxic>)(object)__instance).globalAudioHandler == (Object)null && (Object)(object)ThirstGaugePatch.globalAudioHandlerToCopy != (Object)null)
{
((PlayerGauge<PlayerGaugeToxic>)(object)__instance).globalAudioHandler = ThirstGaugePatch.globalAudioHandlerToCopy;
}
__instance.SetVisible(((PlayerGauge<PlayerGaugeToxic>)(object)__instance).gaugeValue > 0f && !Managers.GetManager<WindowsHandler>().GetHasUiOpen());
if (((PlayerGauge<PlayerGaugeToxic>)(object)__instance).gaugeValue < Utils.CheckForInvalidConfigurationValues(ToxicConfigType.ToxicWarning, ((PlayerGauge<PlayerGaugeToxic>)(object)__instance).maxValue))
{
AlertedLow = false;
AlertedCritical = false;
((Graphic)thisImage).color = Color.white;
}
else if (((PlayerGauge<PlayerGaugeToxic>)(object)__instance).gaugeValue >= Utils.CheckForInvalidConfigurationValues(ToxicConfigType.ToxicCritical, ((PlayerGauge<PlayerGaugeToxic>)(object)__instance).maxValue) && !AlertedCritical)
{
Utils.DisplayInfoTextCustom(Object.FindFirstObjectByType<BaseHudHandler>(), "WARNING - Toxicity level critical", 3f, "", "");
GlobalAudioHandler obj = ((PlayerGauge<PlayerGaugeToxic>)(object)__instance).globalAudioHandler;
if (obj != null)
{
obj.PlayAlertCritical();
}
AlertedCritical = true;
((Graphic)thisImage).color = Color.red;
}
else if (((PlayerGauge<PlayerGaugeToxic>)(object)__instance).gaugeValue >= Utils.CheckForInvalidConfigurationValues(ToxicConfigType.ToxicWarning, ((PlayerGauge<PlayerGaugeToxic>)(object)__instance).maxValue) && !AlertedLow)
{
Utils.DisplayInfoTextCustom(Object.FindFirstObjectByType<BaseHudHandler>(), "WARNING - Toxicity level high", 3f, "", "");
GlobalAudioHandler obj2 = ((PlayerGauge<PlayerGaugeToxic>)(object)__instance).globalAudioHandler;
if (obj2 != null)
{
obj2.PlayAlertLow();
}
AlertedLow = true;
((Graphic)thisImage).color = Color.yellow;
}
((PlayerGauge<PlayerGaugeToxic>)(object)__instance).gaugeValue = ((PlayerGauge<PlayerGaugeToxic>)(object)__instance).maxValue - ((PlayerGauge<PlayerGaugeToxic>)(object)__instance).gaugeValue;
return false;
}
}
[HarmonyPatch(typeof(BaseHudHandler))]
internal class LinesPatch
{
[HarmonyPostfix]
[HarmonyPatch("UpdateHud")]
public static void Start(BaseHudHandler __instance)
{
if (Plugin.ConfigManager.DisableSideLines.Value && ((Component)((Component)__instance).gameObject.transform.Find("LinesBorders")).gameObject.activeSelf)
{
((Component)((Component)__instance).gameObject.transform.Find("LinesBorders")).gameObject.SetActive(false);
}
if (Plugin.ConfigManager.DisableVersionAndFpsText.Value && ((Component)((Component)__instance).gameObject.transform.Find("Early Alpha")).gameObject.activeSelf)
{
((Component)((Component)__instance).gameObject.transform.Find("Early Alpha")).gameObject.SetActive(false);
}
}
}
[HarmonyPatch(typeof(CanvasCompass))]
internal class CompassPatch
{
[HarmonyPostfix]
[HarmonyPatch("SetStatus")]
public static void SetStatus(CanvasCompass __instance)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
Color color = default(Color);
if (ColorUtility.TryParseHtmlString(Plugin.ConfigManager.CompassColor.Value, ref color))
{
((Graphic)__instance.compass).color = color;
((Graphic)((Component)((Component)((Component)__instance.compass).gameObject.transform.GetChild(0)).transform).gameObject.GetComponent<Image>()).color = color;
}
else
{
Plugin.logger.LogError((object)"The provided color is invalid!");
}
}
}
[HarmonyPatch(typeof(InventoryDisplayer))]
internal class InventoryPatch
{
[HarmonyPostfix]
[HarmonyPatch("SetInventoryBlocks")]
public static void RefreshContent(InventoryDisplayer __instance)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)((Component)__instance).gameObject.transform.Find("InventoryBlocks")).gameObject;
Color color = default(Color);
if (ColorUtility.TryParseHtmlString(Plugin.ConfigManager.InventoryColor.Value, ref color))
{
for (int i = 0; gameObject.transform.childCount > i; i++)
{
((Graphic)((Component)((Component)((Component)gameObject.transform.GetChild(i)).gameObject.transform.Find("Border")).gameObject.transform.GetChild(0)).gameObject.GetComponent<Image>()).color = color;
}
}
else
{
Plugin.logger.LogError((object)"The provided color is invalid!");
}
}
}
internal static class Utils
{
private static DoOnce doOnceOxygen;
private static DoOnce doOnceHunger;
private static DoOnce doOnceThirst;
private static DoOnce doOnceToxicity;
private static float OxygenGaugeLowResultPercentage;
private static float OxygenGaugeCriticalResultPercentage;
private static float ToxicGaugeLowResultPercentage;
private static float ToxicGaugeCriticalResultPercentage;
internal static float CheckForInvalidConfigurationValues(OxygenConfigType configType, float gaugeMaxInput, SystemType systemType = SystemType.Legacy)
{
switch (systemType)
{
case SystemType.Legacy:
if (Plugin.ConfigManager.OxygenLowWarningValue.Value <= Plugin.ConfigManager.OxygenCriticalWarningValue.Value)
{
if (doOnceOxygen == null)
{
doOnceOxygen = new DoOnce(delegate
{
Plugin.logger.LogError((object)new InvalidOperationException("OxygenLowWarningValue can not be smaller than OxygenCriticalWarningValue! Using default values!"));
});
}
switch (configType)
{
case OxygenConfigType.OxygenLow:
return Plugin.ConfigManager.OxygenLowWarningValue.DefaultValue;
case OxygenConfigType.OxygenCritical:
return Plugin.ConfigManager.OxygenCriticalWarningValue.DefaultValue;
}
}
else
{
switch (configType)
{
case OxygenConfigType.OxygenLow:
return Plugin.ConfigManager.OxygenLowWarningValue.Value;
case OxygenConfigType.OxygenCritical:
return Plugin.ConfigManager.OxygenCriticalWarningValue.Value;
}
}
break;
case SystemType.Dynamic:
if (Plugin.ConfigManager.OxygenLowWarningValue.Value <= Plugin.ConfigManager.OxygenCriticalWarningValue.Value)
{
if (doOnceOxygen == null)
{
doOnceOxygen = new DoOnce(delegate
{
Plugin.logger.LogError((object)new InvalidOperationException("OxygenLowWarningValue can not be smaller than OxygenCriticalWarningValue! Using default values!"));
});
}
switch (configType)
{
case OxygenConfigType.OxygenLow:
OxygenGaugeLowResultPercentage = gaugeMaxInput / 100f * Plugin.ConfigManager.OxygenLowWarningValue.DefaultValue;
return OxygenGaugeLowResultPercentage;
case OxygenConfigType.OxygenCritical:
OxygenGaugeCriticalResultPercentage = gaugeMaxInput / 100f * Plugin.ConfigManager.OxygenCriticalWarningValue.DefaultValue;
return OxygenGaugeCriticalResultPercentage;
}
}
else
{
switch (configType)
{
case OxygenConfigType.OxygenLow:
OxygenGaugeLowResultPercentage = gaugeMaxInput / 100f * Plugin.ConfigManager.OxygenLowWarningValue.Value;
return OxygenGaugeLowResultPercentage;
case OxygenConfigType.OxygenCritical:
OxygenGaugeCriticalResultPercentage = gaugeMaxInput / 100f * Plugin.ConfigManager.OxygenCriticalWarningValue.Value;
return Plugin.ConfigManager.OxygenCriticalWarningValue.Value;
}
}
break;
}
return float.NaN;
}
internal static float CheckForInvalidConfigurationValues(HungerConfigType configType)
{
if (Plugin.ConfigManager.HungerLowWarningValue.Value <= Plugin.ConfigManager.HungerCriticalWarningValue.Value)
{
if (doOnceHunger == null)
{
doOnceHunger = new DoOnce(delegate
{
Plugin.logger.LogError((object)new InvalidOperationException("HungerLowWarningValue can not be smaller than HungerCriticalWarningValue! Using default values!"));
});
}
switch (configType)
{
case HungerConfigType.FoodLow:
return Plugin.ConfigManager.HungerLowWarningValue.DefaultValue;
case HungerConfigType.FoodCritical:
return Plugin.ConfigManager.HungerCriticalWarningValue.DefaultValue;
}
}
else
{
switch (configType)
{
case HungerConfigType.FoodLow:
return Plugin.ConfigManager.HungerLowWarningValue.Value;
case HungerConfigType.FoodCritical:
return Plugin.ConfigManager.HungerCriticalWarningValue.Value;
}
}
return float.NaN;
}
internal static float CheckForInvalidConfigurationValues(ThirstConfigType configType)
{
if (Plugin.ConfigManager.ThirstLowWarningValue.Value <= Plugin.ConfigManager.ThirstCriticalWarningValue.Value)
{
if (doOnceThirst == null)
{
doOnceThirst = new DoOnce(delegate
{
Plugin.logger.LogError((object)new InvalidOperationException("ThirstLowWarningValue can not be smaller than ThirstCriticalWarningValue! Using default values!"));
});
}
switch (configType)
{
case ThirstConfigType.WaterLow:
return Plugin.ConfigManager.ThirstLowWarningValue.DefaultValue;
case ThirstConfigType.WaterCritical:
return Plugin.ConfigManager.ThirstCriticalWarningValue.DefaultValue;
}
}
else
{
switch (configType)
{
case ThirstConfigType.WaterLow:
return Plugin.ConfigManager.ThirstLowWarningValue.Value;
case ThirstConfigType.WaterCritical:
return Plugin.ConfigManager.ThirstCriticalWarningValue.Value;
}
}
return float.NaN;
}
internal static float CheckForInvalidConfigurationValues(ToxicConfigType configType, float gaugeMaxInput, SystemType systemType = SystemType.Dynamic)
{
switch (systemType)
{
case SystemType.Legacy:
if (Plugin.ConfigManager.ToxicHighWarningValue.Value >= Plugin.ConfigManager.ToxicCriticalWarningValue.Value)
{
if (doOnceToxicity == null)
{
doOnceToxicity = new DoOnce(delegate
{
Plugin.logger.LogError((object)new InvalidOperationException("ToxicCriticalWarningValue can not be smaller than ToxicHighWarningValue! Using default values!"));
});
}
switch (configType)
{
case ToxicConfigType.ToxicWarning:
return Plugin.ConfigManager.ToxicHighWarningValue.DefaultValue;
case ToxicConfigType.ToxicCritical:
return Plugin.ConfigManager.ToxicCriticalWarningValue.DefaultValue;
}
}
else
{
switch (configType)
{
case ToxicConfigType.ToxicWarning:
return Plugin.ConfigManager.ToxicHighWarningValue.Value;
case ToxicConfigType.ToxicCritical:
return Plugin.ConfigManager.ToxicCriticalWarningValue.Value;
}
}
break;
case SystemType.Dynamic:
if (Plugin.ConfigManager.OxygenLowWarningValue.Value <= Plugin.ConfigManager.OxygenCriticalWarningValue.Value)
{
if (doOnceToxicity == null)
{
doOnceToxicity = new DoOnce(delegate
{
Plugin.logger.LogError((object)new InvalidOperationException("ToxicCriticalWarningValue can not be smaller than ToxicHighWarningValue! Using default values!"));
});
}
switch (configType)
{
case ToxicConfigType.ToxicWarning:
ToxicGaugeLowResultPercentage = gaugeMaxInput / 100f * Plugin.ConfigManager.ToxicHighWarningValue.DefaultValue;
return ToxicGaugeLowResultPercentage;
case ToxicConfigType.ToxicCritical:
ToxicGaugeCriticalResultPercentage = gaugeMaxInput / 100f * Plugin.ConfigManager.ToxicCriticalWarningValue.DefaultValue;
return ToxicGaugeCriticalResultPercentage;
}
}
else
{
switch (configType)
{
case ToxicConfigType.ToxicWarning:
ToxicGaugeLowResultPercentage = gaugeMaxInput / 100f * Plugin.ConfigManager.ToxicHighWarningValue.Value;
return ToxicGaugeLowResultPercentage;
case ToxicConfigType.ToxicCritical:
ToxicGaugeCriticalResultPercentage = gaugeMaxInput / 100f * Plugin.ConfigManager.ToxicCriticalWarningValue.Value;
return ToxicGaugeCriticalResultPercentage;
}
}
break;
}
return float.NaN;
}
internal static void DisplayInfoText(BaseHudHandler __instance, string localizationCode, float timeStayDisplayer, string postfix, string prefix)
{
if (!__instance._menuOpen)
{
string localizedString = Localization.GetLocalizedString(localizationCode);
((Component)__instance.hoverText).gameObject.SetActive(true);
((TMP_Text)__instance.hoverText).text = prefix + (string.IsNullOrEmpty(localizedString) ? localizationCode : localizedString) + " " + postfix;
__instance._keepCurrentText = false;
((MonoBehaviour)__instance).CancelInvoke();
if (timeStayDisplayer > 0f)
{
__instance._keepCurrentText = true;
((MonoBehaviour)__instance).Invoke("CleanCursorText", timeStayDisplayer);
}
}
}
internal static void DisplayInfoTextCustom(BaseHudHandler __instance, string text, float timeStayDisplayer, string postfix, string prefix)
{
if (!__instance._menuOpen)
{
((Component)__instance.hoverText).gameObject.SetActive(true);
((TMP_Text)__instance.hoverText).text = prefix + (string.IsNullOrEmpty(text) ? text : text) + " " + postfix;
__instance._keepCurrentText = false;
((MonoBehaviour)__instance).CancelInvoke();
if (timeStayDisplayer > 0f)
{
__instance._keepCurrentText = true;
((MonoBehaviour)__instance).Invoke("CleanCursorText", timeStayDisplayer);
}
}
}
internal static SystemType StringToEnum(string objectToConvert)
{
return Enum.Parse<SystemType>(objectToConvert);
}
}
internal class DoOnce
{
private bool actionPerformed = false;
internal DoOnce(Action action)
{
if (!actionPerformed)
{
action();
actionPerformed = true;
}
}
}
internal enum OxygenConfigType
{
OxygenLow,
OxygenCritical
}
internal enum HungerConfigType
{
FoodLow,
FoodCritical
}
internal enum ThirstConfigType
{
WaterLow,
WaterCritical
}
internal enum ToxicConfigType
{
ToxicWarning,
ToxicCritical
}
internal enum SystemType
{
Legacy,
Dynamic
}
}