Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of EladsLethalHUD v0.0.7
EladsLethalHUD.dll
Decompiled 2 days agousing System; using System.Collections; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EladsLethalHUD.MonoBehaviours; using EladsLethalHUD.Patches; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalHUD; using LethalHUD.CustomHUD; using LethalHUD.CustomHUD.Refs; using LethalHUD.HUD; using Microsoft.CodeAnalysis; using Oxygen.General; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EladsLethalHUD")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.0.7.0")] [assembly: AssemblyInformationalVersion("0.0.7")] [assembly: AssemblyProduct("EladsLethalHUD")] [assembly: AssemblyTitle("EladsLethalHUD")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.7.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 EladsLethalHUD { internal static class Log { internal static void Debug(string message) { Write((LogLevel)32, message); } internal static void Info(string message) { Write((LogLevel)16, message); } internal static void Warn(string message) { Write((LogLevel)4, message); } internal static void Error(string message) { Write((LogLevel)2, message); } internal static void Fatal(string message) { Write((LogLevel)1, message); } private static void Write(LogLevel logLevel, string message) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (Plugin.mls != null) { Plugin.mls.Log(logLevel, (object)message); } } } [BepInPlugin("MrHat.EladsLethalHUD", "EladsLethalHUD", "0.0.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private const string OxygenGUID = "consequential.Oxygen"; internal const string modGUID = "MrHat.EladsLethalHUD"; internal const string modName = "EladsLethalHUD"; internal const string modVersion = "0.0.7"; private readonly Harmony _harmony = new Harmony("MrHat.EladsLethalHUD"); internal static ManualLogSource mls; internal static ConfigEntry<bool> AutoHideHealth { get; private set; } internal static ConfigEntry<float> HealthHideDelay { get; private set; } internal static ConfigEntry<float> HealthFadeOpacity { get; private set; } internal static ConfigEntry<bool> AutoHideStamina { get; private set; } internal static ConfigEntry<float> StaminaHideDelay { get; private set; } internal static ConfigEntry<float> StaminaFadeOpacity { get; private set; } internal static ConfigEntry<bool> UseStaminaPopupPercentage { get; private set; } internal static ConfigEntry<float> StaminaPopupPercentage { get; private set; } internal static ConfigEntry<bool> AutoHideOxygen { get; private set; } internal static ConfigEntry<float> OxygenHideDelay { get; private set; } internal static ConfigEntry<float> OxygenFadeOpacity { get; private set; } internal static ConfigEntry<bool> UseOxygenPopupPercentage { get; private set; } internal static ConfigEntry<float> OxygenPopupPercentage { get; private set; } internal static ConfigEntry<bool> DisableOxygenBar { get; private set; } internal static ConfigEntry<bool> ShowPocketFlashlight { get; private set; } internal static ConfigEntry<bool> ShowBatteryPercentage { get; private set; } internal static ConfigEntry<float> HUDScale { get; private set; } internal static ConfigEntry<bool> AffectVoiceActivityIcon { get; private set; } internal static ConfigEntry<bool> ReplaceVoiceIcon { get; private set; } internal static ConfigEntry<bool> AffectUtilitySlot { get; private set; } internal static ConfigEntry<bool> AutoHideUtilitySlot { get; private set; } internal static ConfigEntry<bool> AutoHideOccupiedUtilitySlot { get; private set; } internal static ConfigEntry<float> UtilitySlotHideDelay { get; private set; } internal static ConfigEntry<float> UtilitySlotFadeOpacity { get; private set; } internal static bool HasOxygen { get; private set; } private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Expected O, but got Unknown //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Expected O, but got Unknown //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Expected O, but got Unknown //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Expected O, but got Unknown //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Expected O, but got Unknown //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Expected O, but got Unknown //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Expected O, but got Unknown //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Expected O, but got Unknown //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Expected O, but got Unknown //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Expected O, but got Unknown //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Expected O, but got Unknown //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Expected O, but got Unknown //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Expected O, but got Unknown //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Expected O, but got Unknown //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Expected O, but got Unknown //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Expected O, but got Unknown //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Expected O, but got Unknown //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Expected O, but got Unknown //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Expected O, but got Unknown //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Expected O, but got Unknown //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Expected O, but got Unknown //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Expected O, but got Unknown //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_057f: Expected O, but got Unknown //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Expected O, but got Unknown //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Expected O, but got Unknown //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Expected O, but got Unknown //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Expected O, but got Unknown //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Expected O, but got Unknown mls = ((BaseUnityPlugin)this).Logger; AutoHideHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("Health", "Auto Hide Health", true, "If true, hides the health display after the configured delay"); HealthHideDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Health", "Health Hide Delay", 4f, new ConfigDescription("Seconds before the health display fades out", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>())); HealthFadeOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Health", "Auto Fade Opacity", 0f, new ConfigDescription("Opacity used after the health display automatically fades", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); AutoHideStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("Stamina", "Auto Hide Stamina", true, "If true, hides the stamina and weight display after the configured delay"); StaminaHideDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Stamina Hide Delay", 4f, new ConfigDescription("Seconds before the stamina and weight display fades out", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>())); StaminaFadeOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Auto Fade Opacity", 0f, new ConfigDescription("Opacity used after the stamina and weight display automatically fades", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); UseStaminaPopupPercentage = ((BaseUnityPlugin)this).Config.Bind<bool>("Stamina", "Use Minimum Percentage Until Popup", false, "If true, uses the configured percentage as the reveal threshold"); StaminaPopupPercentage = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Minimum Percentage Until Popup", 70f, new ConfigDescription("Show the stamina display when stamina reaches this percentage or lower", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); AutoHideOxygen = ((BaseUnityPlugin)this).Config.Bind<bool>("Oxygen", "Auto Hide Oxygen", true, "If true, fades the oxygen display when oxygen is not low enough to keep it visible"); OxygenHideDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Oxygen", "Oxygen Hide Delay", 4f, new ConfigDescription("Seconds before the oxygen display fades out", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>())); OxygenFadeOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Oxygen", "Auto Fade Opacity", 0f, new ConfigDescription("Opacity used after the oxygen display automatically fades", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); UseOxygenPopupPercentage = ((BaseUnityPlugin)this).Config.Bind<bool>("Oxygen", "Use Minimum Percentage Until Popup", false, "If true, uses the configured percentage as the reveal threshold"); OxygenPopupPercentage = ((BaseUnityPlugin)this).Config.Bind<float>("Oxygen", "Minimum Percentage Until Popup", 70f, new ConfigDescription("Show the oxygen display when oxygen reaches this percentage or lower", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); DisableOxygenBar = ((BaseUnityPlugin)this).Config.Bind<bool>("Oxygen", "Disable Oxygen Display", false, "If true, disables the oxygen display"); ShowPocketFlashlight = ((BaseUnityPlugin)this).Config.Bind<bool>("Battery", "Show Pocketed Item Battery", false, "If true, shows the battery usage when you aren't holding the item in use"); ShowBatteryPercentage = ((BaseUnityPlugin)this).Config.Bind<bool>("Battery", "Show Battery Percentage", false, "If true, shows the percentage text on the battery"); HUDScale = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "HUD Scale", 0.75f, new ConfigDescription("Sets the size of the HUD", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>())); AffectVoiceActivityIcon = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Affect Voice Activity Icon", true, "If true, applies custom changes to the voice activity icon"); ReplaceVoiceIcon = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Replace Voice Activity Icon", true, "If true, replaces the vanilla voice activity icon with a custom icon"); AffectUtilitySlot = ((BaseUnityPlugin)this).Config.Bind<bool>("Utility Slot", "Affect Utility Slot", true, "If true, applies custom changes to the utility slot"); AutoHideUtilitySlot = ((BaseUnityPlugin)this).Config.Bind<bool>("Utility Slot", "Auto Hide", true, "If true, fades the utility slot after the configured delay"); AutoHideOccupiedUtilitySlot = ((BaseUnityPlugin)this).Config.Bind<bool>("Utility Slot", "Auto Hide When Occupied", false, "If true, allows the utility slot to fade while it holds an item"); UtilitySlotHideDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Utility Slot", "Hide Delay", 4f, new ConfigDescription("Seconds before the utility slot fades out", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>())); UtilitySlotFadeOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Utility Slot", "Auto Fade Opacity", 0f, new ConfigDescription("Opacity used after the utility slot automatically fades", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); LethalConfigManager.SkipAutoGen(); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(HUDScale, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(AffectVoiceActivityIcon, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(ReplaceVoiceIcon, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(AffectUtilitySlot, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(AutoHideUtilitySlot, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(AutoHideOccupiedUtilitySlot, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(UtilitySlotHideDelay, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(UtilitySlotFadeOpacity, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(AutoHideHealth, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(HealthHideDelay, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(HealthFadeOpacity, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(AutoHideStamina, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(StaminaHideDelay, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(StaminaFadeOpacity, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(DisableOxygenBar, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(AutoHideOxygen, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(UseOxygenPopupPercentage, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(OxygenPopupPercentage, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(OxygenHideDelay, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(OxygenFadeOpacity, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(ShowPocketFlashlight, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(ShowBatteryPercentage, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(UseStaminaPopupPercentage, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(StaminaPopupPercentage, false)); HasOxygen = Chainloader.PluginInfos.ContainsKey("consequential.Oxygen"); HUDScale.SettingChanged += OnHUDLayoutChanged; AffectVoiceActivityIcon.SettingChanged += OnHUDLayoutChanged; ReplaceVoiceIcon.SettingChanged += OnHUDLayoutChanged; ShowBatteryPercentage.SettingChanged += OnHUDLayoutChanged; AffectUtilitySlot.SettingChanged += OnHUDLayoutChanged; Plugins.ConfigEntries.CustomHealthBar.SettingChanged += OnHUDLayoutChanged; Plugins.ConfigEntries.CustomStaminaBar.SettingChanged += OnHUDLayoutChanged; Plugins.ConfigEntries.CustomBatteryBar.SettingChanged += OnHUDLayoutChanged; _harmony.PatchAll(typeof(PlayerControllerBPatches)); _harmony.PatchAll(typeof(HUDManagerPatches)); Log.Debug("Applied HUD and player patches"); if (HasOxygen) { _harmony.PatchAll(typeof(OxygenCompatibility)); Log.Info("Oxygen compatibility enabled"); } Log.Info("EladsLethalHUD 0.0.7 loaded~"); } private void OnHUDLayoutChanged(object sender, EventArgs args) { //IL_0023: 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_0037: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if ((Object)(object)EladsHealthDisplay.Instance != (Object)null && ((Behaviour)EladsHealthDisplay.Instance).isActiveAndEnabled) { Utility.ResizeHUD((RectTransform)((Component)EladsHealthDisplay.Instance).transform, EladsHealthDisplay.Instance.Scale); } if ((Object)(object)EladsStaminaDisplay.Instance != (Object)null && ((Behaviour)EladsStaminaDisplay.Instance).isActiveAndEnabled) { Utility.ResizeHUD((RectTransform)((Component)EladsStaminaDisplay.Instance).transform, EladsStaminaDisplay.Instance.Scale); } if ((Object)(object)EladsBatteryDisplay.Instance != (Object)null && ((Behaviour)EladsBatteryDisplay.Instance).isActiveAndEnabled) { Utility.ResizeHUD((RectTransform)((Component)EladsBatteryDisplay.Instance).transform, EladsBatteryDisplay.Instance.Scale); } HUDManagerPatches.RefreshHUDLayout(); Log.Debug("HUD layout refreshed"); } } internal static class Utility { internal static readonly int FlowColorId = Shader.PropertyToID("_FlowColor"); internal static string PercentageText(int percentage) { return $"{percentage}<size=75%><voffset=1>%</voffset></size>"; } internal static Color ParseHtmlColor(string hexColor, Color fallback) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); if (ColorUtility.TryParseHtmlString(hexColor, ref result)) { return result; } Log.Warn("Could not parse color '" + hexColor + "', using the fallback color"); return fallback; } internal static void ResizeHUD(RectTransform HUD, Vector3 scale) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) ((Transform)HUD).localScale = scale * Plugin.HUDScale.Value; HUDManagerPatches.MoveHUDElements(HUD); } internal static void PositionHUDTransform(RectTransform target, RectTransform configuredTransform, RectTransform HUD) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) ((Transform)target).SetParent(HUDManagerPatches.topLeftCorner.transform, false); target.anchorMin = configuredTransform.anchorMin; target.anchorMax = configuredTransform.anchorMax; target.sizeDelta = configuredTransform.sizeDelta; target.pivot = configuredTransform.pivot; ((Transform)target).position = ((Transform)HUD).TransformPoint(((Transform)configuredTransform).localPosition); ((Transform)target).rotation = ((Transform)HUD).rotation * ((Transform)configuredTransform).localRotation; ((Transform)target).localScale = Vector3.Scale(((Transform)HUD).localScale, ((Transform)configuredTransform).localScale); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "EladsLethalHUD"; public const string PLUGIN_NAME = "EladsLethalHUD"; public const string PLUGIN_VERSION = "0.0.7"; } } namespace EladsLethalHUD.Patches { internal static class HUDManagerPatches { internal static GameObject topLeftCorner; private static RectTransform statusEffectsRoot; private static RectTransform movedWithHUD; private static Vector2 originalAnchorMin; private static Vector2 originalAnchorMax; private static Vector2 originalAnchoredPosition; private static Vector3 originalScale; private static Quaternion originalRotation; private static Quaternion originalTextRotation; private static float originalFontSize; private static Color originalStatusEffectsColor; private static Image originalVoiceIcon; private static Image voiceIcon; private static Image voiceIconIfBatteryTextOn; private static TMP_Text statusEffectsText; private static Transform originalVoiceParent; private static int originalVoiceSiblingIndex; private static Vector2 originalVoiceAnchorMin; private static Vector2 originalVoiceAnchorMax; private static Vector3 originalVoicePosition; private static Vector2 originalVoiceSize; private static Vector2 originalVoicePivot; private static Vector3 originalVoiceScale; private static Quaternion originalVoiceRotation; private static Sprite originalVoiceOverrideSprite; private static Material originalVoiceMaterial; private static Color originalVoiceColor; private static Color originalVoiceRendererColor; private static RectTransform utilitySlot; private static RectTransform utilitySlotPoint; internal static EladsUtilitySlotDisplay utilitySlotDisplay; private static Transform originalUtilitySlotParent; private static int originalUtilitySlotSiblingIndex; private static Vector2 originalUtilitySlotAnchorMin; private static Vector2 originalUtilitySlotAnchorMax; private static Vector3 originalUtilitySlotPosition; private static Vector2 originalUtilitySlotSize; private static Vector2 originalUtilitySlotPivot; private static Vector3 originalUtilitySlotScale; private static Quaternion originalUtilitySlotRotation; [HarmonyPatch(typeof(HUDManager), "Awake")] [HarmonyPrefix] private static void AwakePrefix() { topLeftCorner = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/TopLeftCorner"); } [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyAfter(new string[] { "LethalHUD" })] [HarmonyPriority(0)] [HarmonyPostfix] private static void StartPostfix() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0248: 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) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) statusEffectsRoot = (RectTransform)topLeftCorner.transform.Find("StatusEffects"); RectTransform val = statusEffectsRoot; RectTransform rectTransform = ((TMP_Text)HUDManager.Instance.statusEffectText).rectTransform; originalAnchorMin = val.anchorMin; originalAnchorMax = val.anchorMax; originalAnchoredPosition = val.anchoredPosition; originalScale = ((Transform)val).localScale; originalRotation = ((Transform)val).localRotation; originalTextRotation = ((Transform)rectTransform).localRotation; originalFontSize = ((TMP_Text)HUDManager.Instance.statusEffectText).fontSize; originalStatusEffectsColor = ((Graphic)HUDManager.Instance.statusEffectText).color; originalVoiceIcon = HUDManager.Instance.PTTIcon; RectTransform rectTransform2 = ((Graphic)originalVoiceIcon).rectTransform; originalVoiceParent = ((Transform)rectTransform2).parent; originalVoiceSiblingIndex = ((Transform)rectTransform2).GetSiblingIndex(); originalVoiceAnchorMin = rectTransform2.anchorMin; originalVoiceAnchorMax = rectTransform2.anchorMax; originalVoicePosition = rectTransform2.anchoredPosition3D; originalVoiceSize = rectTransform2.sizeDelta; originalVoicePivot = rectTransform2.pivot; originalVoiceScale = ((Transform)rectTransform2).localScale; originalVoiceRotation = ((Transform)rectTransform2).localRotation; originalVoiceOverrideSprite = originalVoiceIcon.overrideSprite; originalVoiceMaterial = ((Graphic)originalVoiceIcon).material; originalVoiceColor = ((Graphic)originalVoiceIcon).color; originalVoiceRendererColor = ((Graphic)originalVoiceIcon).canvasRenderer.GetColor(); utilitySlot = ((Graphic)HUDManager.Instance.itemOnlySlotIconFrame).rectTransform; utilitySlotDisplay = ((Component)HUDManager.Instance).gameObject.AddComponent<EladsUtilitySlotDisplay>(); EladsBatteryDisplay component = Plugins.BatteryPrefabs["EladsHUD Battery"].Asset.GetComponent<EladsBatteryDisplay>(); EladsHealthDisplay component2 = Plugins.HealthBarPrefabs["EladsHUD Health"].Asset.GetComponent<EladsHealthDisplay>(); utilitySlotDisplay.Initialise(utilitySlot, component.utilitySlotAnimator, component.utilitySlotSprite, component.utilitySlotColor); voiceIcon = component.voiceIcon; voiceIconIfBatteryTextOn = component.voiceIconIfBatteryTextOn; statusEffectsText = component2.statusEffectsText; utilitySlotPoint = component.utilitySlotPoint; originalUtilitySlotParent = ((Transform)utilitySlot).parent; originalUtilitySlotSiblingIndex = ((Transform)utilitySlot).GetSiblingIndex(); originalUtilitySlotAnchorMin = utilitySlot.anchorMin; originalUtilitySlotAnchorMax = utilitySlot.anchorMax; originalUtilitySlotPosition = utilitySlot.anchoredPosition3D; originalUtilitySlotSize = utilitySlot.sizeDelta; originalUtilitySlotPivot = utilitySlot.pivot; originalUtilitySlotScale = ((Transform)utilitySlot).localScale; originalUtilitySlotRotation = ((Transform)utilitySlot).localRotation; RefreshHUDLayout(); } [HarmonyPatch(typeof(HUDManager), "UpdateHealthUI")] [HarmonyAfter(new string[] { "LethalHUD" })] [HarmonyPriority(0)] [HarmonyPostfix] private static void UpdateHealthUIPostfix(int health) { EladsHealthDisplay instance = EladsHealthDisplay.Instance; if ((Object)(object)instance != (Object)null) { instance.HealthChanged(health); } } internal static void MoveHUDElements(RectTransform HUD) { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) RectTransform val = statusEffectsRoot; RectTransform rectTransform = ((TMP_Text)HUDManager.Instance.statusEffectText).rectTransform; RectTransform rectTransform2 = statusEffectsText.rectTransform; if (Plugin.AffectVoiceActivityIcon.Value) { Image val2 = ((!Plugin.ShowBatteryPercentage.Value) ? voiceIcon : voiceIconIfBatteryTextOn); RectTransform rectTransform3 = ((Graphic)originalVoiceIcon).rectTransform; RectTransform rectTransform4 = ((Graphic)val2).rectTransform; bool enabled = ((Behaviour)originalVoiceIcon).enabled; ((Behaviour)originalVoiceIcon).enabled = false; Utility.PositionHUDTransform(rectTransform3, rectTransform4, HUD); ((Graphic)originalVoiceIcon).material = ((Graphic)val2).material; if (Plugin.ReplaceVoiceIcon.Value) { originalVoiceIcon.overrideSprite = val2.sprite; } else { originalVoiceIcon.overrideSprite = originalVoiceOverrideSprite; } ((Graphic)originalVoiceIcon).color = ((Graphic)val2).color; ((Graphic)originalVoiceIcon).canvasRenderer.SetColor(((Graphic)val2).canvasRenderer.GetColor()); ((Behaviour)originalVoiceIcon).enabled = enabled; } else { RestoreVoiceIcon(); } ((Transform)val).localScale = ((Transform)HUD).localScale; ((Transform)val).localRotation = ((Transform)HUD).localRotation; ((Transform)rectTransform).localRotation = ((Transform)rectTransform2).localRotation; ((TMP_Text)HUDManager.Instance.statusEffectText).fontSize = statusEffectsText.fontSize; Color color = ((Graphic)statusEffectsText).color; color.a = ((Graphic)HUDManager.Instance.statusEffectText).color.a; ((Graphic)HUDManager.Instance.statusEffectText).color = color; ((Transform)val).position = ((Transform)val).position + (((Transform)HUD).TransformPoint(rectTransform2.anchoredPosition3D) - ((Transform)rectTransform).position); if (Plugin.AffectUtilitySlot.Value) { Utility.PositionHUDTransform(utilitySlot, utilitySlotPoint, HUD); utilitySlotDisplay.Customise(); } else { RestoreUtilitySlot(); } movedWithHUD = HUD; } internal static void RefreshHUDLayout() { //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown EladsBatteryDisplay eladsBatteryDisplay = default(EladsBatteryDisplay); if (Plugins.ConfigEntries.CustomBatteryBar.Value == "EladsHUD Battery" && (Object)(object)CustomBattery.Refs != (Object)null && ((Component)CustomBattery.Refs).TryGetComponent<EladsBatteryDisplay>(ref eladsBatteryDisplay)) { eladsBatteryDisplay.Initialise(); } bool flag = Plugins.ConfigEntries.CustomHealthBar.Value == "EladsHUD Health"; bool flag2 = Plugins.ConfigEntries.CustomStaminaBar.Value == "EladsHUD Stamina"; bool flag3 = Plugins.ConfigEntries.CustomBatteryBar.Value == "EladsHUD Battery"; if (!flag && !flag2 && !flag3) { if (!((Object)(object)movedWithHUD == (Object)null)) { RectTransform val = statusEffectsRoot; val.anchorMin = originalAnchorMin; val.anchorMax = originalAnchorMax; val.anchoredPosition = originalAnchoredPosition; ((Transform)val).localScale = originalScale; ((Transform)val).localRotation = originalRotation; ((Transform)((TMP_Text)HUDManager.Instance.statusEffectText).rectTransform).localRotation = originalTextRotation; ((TMP_Text)HUDManager.Instance.statusEffectText).fontSize = originalFontSize; ((Graphic)HUDManager.Instance.statusEffectText).color = originalStatusEffectsColor; RestoreVoiceIcon(); RestoreUtilitySlot(); movedWithHUD = null; } return; } RectTransform hUD; if (flag && (Object)(object)EladsHealthDisplay.Instance != (Object)null && ((Behaviour)EladsHealthDisplay.Instance).isActiveAndEnabled) { hUD = (RectTransform)((Component)EladsHealthDisplay.Instance).transform; } else if (flag2 && (Object)(object)EladsStaminaDisplay.Instance != (Object)null && ((Behaviour)EladsStaminaDisplay.Instance).isActiveAndEnabled) { hUD = (RectTransform)((Component)EladsStaminaDisplay.Instance).transform; } else { if (!flag3 || !((Object)(object)EladsBatteryDisplay.Instance != (Object)null) || !((Behaviour)EladsBatteryDisplay.Instance).isActiveAndEnabled) { return; } hUD = (RectTransform)((Component)EladsBatteryDisplay.Instance).transform; } MoveHUDElements(hUD); } private static void RestoreVoiceIcon() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((Graphic)originalVoiceIcon).rectTransform; bool enabled = ((Behaviour)originalVoiceIcon).enabled; ((Behaviour)originalVoiceIcon).enabled = false; ((Transform)rectTransform).SetParent(originalVoiceParent, false); ((Transform)rectTransform).SetSiblingIndex(originalVoiceSiblingIndex); rectTransform.anchorMin = originalVoiceAnchorMin; rectTransform.anchorMax = originalVoiceAnchorMax; rectTransform.anchoredPosition3D = originalVoicePosition; rectTransform.sizeDelta = originalVoiceSize; rectTransform.pivot = originalVoicePivot; ((Transform)rectTransform).localScale = originalVoiceScale; ((Transform)rectTransform).localRotation = originalVoiceRotation; originalVoiceIcon.overrideSprite = originalVoiceOverrideSprite; ((Graphic)originalVoiceIcon).material = originalVoiceMaterial; ((Graphic)originalVoiceIcon).color = originalVoiceColor; ((Graphic)originalVoiceIcon).canvasRenderer.SetColor(originalVoiceRendererColor); ((Behaviour)originalVoiceIcon).enabled = enabled; } private static void RestoreUtilitySlot() { //IL_002e: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0088: Unknown result type (might be due to invalid IL or missing references) utilitySlotDisplay.Restore(); ((Transform)utilitySlot).SetParent(originalUtilitySlotParent, false); ((Transform)utilitySlot).SetSiblingIndex(originalUtilitySlotSiblingIndex); utilitySlot.anchorMin = originalUtilitySlotAnchorMin; utilitySlot.anchorMax = originalUtilitySlotAnchorMax; utilitySlot.anchoredPosition3D = originalUtilitySlotPosition; utilitySlot.sizeDelta = originalUtilitySlotSize; utilitySlot.pivot = originalUtilitySlotPivot; ((Transform)utilitySlot).localScale = originalUtilitySlotScale; ((Transform)utilitySlot).localRotation = originalUtilitySlotRotation; } } internal static class OxygenCompatibility { [HarmonyPatch(typeof(OxygenInit), "Init")] [HarmonyPostfix] private static void InitPostfix() { if ((Object)(object)EladsOxygenDisplay.Instance != (Object)null && ((Behaviour)EladsOxygenDisplay.Instance).isActiveAndEnabled && !Plugin.DisableOxygenBar.Value) { HideOxygenMeter(); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static float OxygenPercent() { return OxygenInit.Percent; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void HideOxygenMeter() { if (OxygenInit.IsOxygenHUDInitialized && ((Component)OxygenInit.oxygenHUD).gameObject.activeSelf) { ((Component)OxygenInit.oxygenHUD).gameObject.SetActive(false); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void ShowOxygenMeter() { if (OxygenInit.IsOxygenHUDInitialized && !((Component)OxygenInit.oxygenHUD).gameObject.activeSelf) { ((Component)OxygenInit.oxygenHUD).gameObject.SetActive(true); } } } internal static class PlayerControllerBPatches { private static PlayerControllerB? lastPlayer; private static int lastWeight; [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] [HarmonyAfter(new string[] { "LethalHUD" })] [HarmonyPriority(0)] [HarmonyPostfix] private static void LateUpdatePostfix(PlayerControllerB __instance) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)__instance != (Object)(object)localPlayerController) { if ((Object)(object)localPlayerController != (Object)null && Plugins.ConfigEntries.CustomBatteryBar.Value == "EladsHUD Battery") { BatteryController.Update(localPlayerController); EladsBatteryDisplay instance = EladsBatteryDisplay.Instance; if ((Object)(object)instance != (Object)null) { instance.Refresh(localPlayerController); } } return; } if ((Object)(object)lastPlayer != (Object)(object)__instance) { lastPlayer = __instance; lastWeight = Mathf.RoundToInt(Mathf.Clamp(__instance.carryWeight - 1f, 0f, 100f) * 105f); } int num = Mathf.RoundToInt(Mathf.Clamp(__instance.carryWeight - 1f, 0f, 100f) * 105f); bool flag = lastWeight != num; if (flag) { lastWeight = num; } float num2 = Mathf.InverseLerp(0.1f, 1f, __instance.sprintMeter); int num3 = Mathf.RoundToInt(num2 * 100f); bool staminaBusy = ((!Plugin.UseStaminaPopupPercentage.Value) ? (__instance.isSprinting || num2 < 0.9995f) : ((float)num3 <= Plugin.StaminaPopupPercentage.Value)); EladsHealthDisplay instance2 = EladsHealthDisplay.Instance; EladsStaminaDisplay instance3 = EladsStaminaDisplay.Instance; EladsOxygenDisplay instance4 = EladsOxygenDisplay.Instance; EladsBatteryDisplay instance5 = EladsBatteryDisplay.Instance; if ((Object)(object)instance3 != (Object)null && ((Behaviour)instance3).isActiveAndEnabled) { instance3.Refresh(num2, staminaBusy, flag); } if ((Object)(object)instance4 != (Object)null && ((Behaviour)instance4).isActiveAndEnabled) { float oxygen = ((!Plugin.HasOxygen) ? Mathf.Clamp01(StartOfRound.Instance.drowningTimer) : OxygenCompatibility.OxygenPercent()); instance4.Refresh(oxygen); } if ((Object)(object)instance2 != (Object)null && ((Behaviour)instance2).isActiveAndEnabled) { instance2.RefreshHealthSettings(__instance.health); instance2.RefreshWeight(staminaBusy, flag); } if ((Object)(object)instance5 != (Object)null && Plugins.ConfigEntries.CustomBatteryBar.Value == "EladsHUD Battery") { instance5.Refresh(__instance); } HUDManagerPatches.utilitySlotDisplay.Refresh(__instance); } } } namespace EladsLethalHUD.MonoBehaviours { internal class EladsBatteryDisplay : MonoBehaviour { [SerializeField] private LHBatteryRefs batteryRefs; [SerializeField] private GameObject heldBattery; [SerializeField] private GameObject pocketFlashlight; [SerializeField] private Image pocketFill; [SerializeField] private TMP_Text pocketText; [SerializeField] private Graphic[] pocketGraphics = Array.Empty<Graphic>(); [SerializeField] internal Image voiceIcon; [SerializeField] internal Image voiceIconIfBatteryTextOn; [SerializeField] internal RectTransform utilitySlotPoint; [SerializeField] internal RuntimeAnimatorController utilitySlotAnimator; [SerializeField] internal Sprite utilitySlotSprite; [SerializeField] internal Color utilitySlotColor; private int lastPocketPercent = -1; private bool showPercentage; internal static EladsBatteryDisplay? Instance { get; private set; } internal Vector3 Scale { get; private set; } private void Awake() { Initialise(); } internal void Initialise() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Instance == (Object)(object)this)) { Instance = this; RectTransform val = (RectTransform)((Component)this).transform; Scale = ((Transform)val).localScale; ((Graphic)pocketFill).material = Object.Instantiate<Material>(((Graphic)pocketFill).material); ((Transform)val).SetParent(HUDManagerPatches.topLeftCorner.transform, false); } } private void Start() { //IL_0006: 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_0016: Expected O, but got Unknown Utility.ResizeHUD((RectTransform)((Component)this).transform, Scale); } private void OnEnable() { Plugins.ConfigEntries.CustomBatteryColor.SettingChanged += OnBatteryColorChanged; showPercentage = Plugin.ShowBatteryPercentage.Value; ((Component)batteryRefs.text).gameObject.SetActive(showPercentage); ((Component)pocketText).gameObject.SetActive(showPercentage); UpdateBatteryColor(); } private void OnDisable() { Plugins.ConfigEntries.CustomBatteryColor.SettingChanged -= OnBatteryColorChanged; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } internal void Refresh(PlayerControllerB player) { bool value = Plugin.ShowBatteryPercentage.Value; if (value != showPercentage) { showPercentage = value; ((Component)batteryRefs.text).gameObject.SetActive(showPercentage); ((Component)pocketText).gameObject.SetActive(showPercentage); } GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; bool flag = false; if (player.isHoldingObject && (Object)(object)currentlyHeldObjectServer != (Object)null && currentlyHeldObjectServer.itemProperties.requiresBattery) { flag = true; float num = Mathf.Clamp01(currentlyHeldObjectServer.insertedBattery.charge); batteryRefs.UpdateBattery(num); } heldBattery.SetActive(flag); GrabbableObject pocketedFlashlight = player.pocketedFlashlight; bool active = false; if (!flag && Plugin.ShowPocketFlashlight.Value && (Object)(object)player.helmetLight != (Object)null && ((Behaviour)player.helmetLight).enabled && (Object)(object)pocketedFlashlight != (Object)null && (Object)(object)pocketedFlashlight != (Object)(object)currentlyHeldObjectServer && pocketedFlashlight.itemProperties.requiresBattery) { active = true; float num2 = Mathf.Clamp01(pocketedFlashlight.insertedBattery.charge); pocketFill.fillAmount = num2; int num3 = Mathf.RoundToInt(num2 * 100f); if (num3 != lastPocketPercent) { pocketText.text = $"{num3}%"; lastPocketPercent = num3; } } pocketFlashlight.SetActive(active); } private void OnBatteryColorChanged(object sender, EventArgs args) { UpdateBatteryColor(); } private void UpdateBatteryColor() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Color val = Utility.ParseHtmlColor(Plugins.ConfigEntries.CustomBatteryColor.Value, Color.white); batteryRefs.SetColor(val); ((Graphic)batteryRefs.fill).material.SetColor(Utility.FlowColorId, val); ((Graphic)pocketFill).material.SetColor(Utility.FlowColorId, val); Graphic[] array = pocketGraphics; foreach (Graphic val2 in array) { val2.color = val; } } } internal class EladsHealthDisplay : MonoBehaviour { [SerializeField] private TMP_Text healthText; [SerializeField] private TMP_Text healthTextShadow; [SerializeField] private TMP_Text weightText; [SerializeField] private ShaderFadeGroup healthFade; [SerializeField] private ShaderFadeGroup weightFade; [SerializeField] internal TMP_Text statusEffectsText; [SerializeField] internal RectTransform weightOxygenPoint; private int lastHealth = -1; private bool lastHealthAutoHide; private bool lastStaminaAutoHide; private bool staminaBusy; private float lastHealthDelay; private float lastStaminaDelay; private float lastHealthFadeOpacity; private float lastStaminaFadeOpacity; private Vector3 weightPosition; private float weightAlpha; internal static EladsHealthDisplay? Instance { get; private set; } internal Vector3 Scale { get; private set; } private void Awake() { //IL_0007: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Scale = ((Component)this).transform.localScale; weightPosition = ((Transform)weightText.rectTransform).localPosition; weightAlpha = ((Graphic)weightText).color.a; } private void Start() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Instance = this; Utility.ResizeHUD((RectTransform)((Component)this).transform, Scale); float oxygenExpansion = 0f; if ((Object)(object)EladsOxygenDisplay.Instance != (Object)null && ((Behaviour)EladsOxygenDisplay.Instance).isActiveAndEnabled && !Plugin.DisableOxygenBar.Value) { oxygenExpansion = EladsOxygenDisplay.Instance.OxygenExpansion; } PositionWeightForOxygen(oxygenExpansion); } private void OnEnable() { float oxygenExpansion = 0f; if ((Object)(object)EladsOxygenDisplay.Instance != (Object)null && ((Behaviour)EladsOxygenDisplay.Instance).isActiveAndEnabled && !Plugin.DisableOxygenBar.Value) { oxygenExpansion = EladsOxygenDisplay.Instance.OxygenExpansion; } PositionWeightForOxygen(oxygenExpansion); lastHealthAutoHide = Plugin.AutoHideHealth.Value; lastStaminaAutoHide = Plugin.AutoHideStamina.Value; lastHealthDelay = Plugin.HealthHideDelay.Value; lastStaminaDelay = Plugin.StaminaHideDelay.Value; lastHealthFadeOpacity = Plugin.HealthFadeOpacity.Value; lastStaminaFadeOpacity = Plugin.StaminaFadeOpacity.Value; healthFade.Reveal(); weightFade.Reveal(); if (lastHealthAutoHide && lastHealth >= 20) { healthFade.FadeAfter(lastHealthDelay, lastHealthFadeOpacity); } if (lastStaminaAutoHide) { if (lastStaminaDelay <= 0f) { weightFade.Hide(lastStaminaFadeOpacity); } else { weightFade.FadeAfter(lastStaminaDelay, lastStaminaFadeOpacity); } } } private void OnDisable() { HUDManagerPatches.RefreshHUDLayout(); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } internal void HealthChanged(int health) { lastHealth = health; healthFade.Reveal(instant: true); if (Plugin.AutoHideHealth.Value && health >= 20) { healthFade.FadeAfter(Plugin.HealthHideDelay.Value, Plugin.HealthFadeOpacity.Value); } } internal void RefreshHealthSettings(int health) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) bool value = Plugin.AutoHideHealth.Value; float value2 = Plugin.HealthHideDelay.Value; float value3 = Plugin.HealthFadeOpacity.Value; bool flag = health != lastHealth; bool flag2 = value != lastHealthAutoHide || !Mathf.Approximately(value2, lastHealthDelay) || !Mathf.Approximately(value3, lastHealthFadeOpacity); if (healthTextShadow.text != healthText.text) { healthTextShadow.text = healthText.text; } if (!Mathf.Approximately(healthTextShadow.fontSize, healthText.fontSize)) { healthTextShadow.fontSize = healthText.fontSize; } if (((Graphic)healthTextShadow).color != ((Graphic)healthText).color) { ((Graphic)healthTextShadow).color = ((Graphic)healthText).color; } if (healthTextShadow.rectTransform.anchoredPosition != healthText.rectTransform.anchoredPosition) { healthTextShadow.rectTransform.anchoredPosition = healthText.rectTransform.anchoredPosition; } if (flag || flag2) { lastHealthAutoHide = value; lastHealthDelay = value2; lastHealthFadeOpacity = value3; lastHealth = health; healthFade.Reveal(); if (value && health >= 20) { healthFade.FadeAfter(value2, value3); } } } internal void RefreshWeight(bool staminaBusy, bool weightChanged) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Color color = ((Graphic)weightText).color; color.a = weightAlpha; ((Graphic)weightText).color = color; bool value = Plugin.AutoHideStamina.Value; float value2 = Plugin.StaminaHideDelay.Value; float value3 = Plugin.StaminaFadeOpacity.Value; bool flag = value != lastStaminaAutoHide || !Mathf.Approximately(value2, lastStaminaDelay) || !Mathf.Approximately(value3, lastStaminaFadeOpacity); bool flag2 = staminaBusy != this.staminaBusy; lastStaminaAutoHide = value; lastStaminaDelay = value2; lastStaminaFadeOpacity = value3; this.staminaBusy = staminaBusy; if (flag || flag2 || weightChanged) { weightFade.Reveal(); if (value && !staminaBusy) { weightFade.FadeAfter(value2, value3); } } } internal void PositionWeightForOxygen(float oxygenExpansion) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) ((Transform)weightText.rectTransform).localPosition = Vector3.Lerp(weightPosition, ((Transform)weightOxygenPoint).localPosition, Mathf.Clamp01(oxygenExpansion)); } } internal class EladsOxygenDisplay : MonoBehaviour { [SerializeField] private RectTransform oxygenRoot; [SerializeField] private Image oxygenFill; [SerializeField] private TMP_Text oxygenText; [SerializeField] private RectTransform percentageRow; [SerializeField] private HorizontalLayoutGroup percentageLayout; [SerializeField] private LayoutElement staminaSlot; [SerializeField] private LayoutElement oxygenSlot; [SerializeField] private RectTransform percentageOxygenPoint; [SerializeField] private ShaderFadeGroup staminaFade; [SerializeField] private ShaderFadeGroup oxygenFade; private int lastPercent = -1; private bool oxygenBusy; private bool lastAutoHide; private bool lastUsePopupPercentage; private bool lastDisabled; private float lastDelay; private float lastFadeOpacity; private float lastPopupPercentage; private Vector3 percentagePosition; private Vector3 percentageOxygenPosition; private float percentageSpacing; private float staminaSlotWidth; private float oxygenSlotWidth; private Coroutine layoutTransition; internal static EladsOxygenDisplay? Instance { get; private set; } internal float OxygenExpansion { get; private set; } private void Awake() { //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_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) percentagePosition = ((Transform)percentageRow).localPosition; percentageOxygenPosition = ((Transform)percentageOxygenPoint).localPosition; percentageSpacing = ((HorizontalOrVerticalLayoutGroup)percentageLayout).spacing; staminaSlotWidth = staminaSlot.preferredWidth; oxygenSlotWidth = oxygenSlot.preferredWidth; } private void OnEnable() { staminaFade.VisibilityChanged += MovePercentageLayout; oxygenFade.VisibilityChanged += MovePercentageLayout; lastAutoHide = Plugin.AutoHideOxygen.Value; lastUsePopupPercentage = Plugin.UseOxygenPopupPercentage.Value; lastDelay = Plugin.OxygenHideDelay.Value; lastFadeOpacity = Plugin.OxygenFadeOpacity.Value; lastPopupPercentage = Plugin.OxygenPopupPercentage.Value; lastDisabled = Plugin.DisableOxygenBar.Value; if (lastDisabled) { oxygenFade.Hide(); ((Component)oxygenRoot).gameObject.SetActive(false); ((Component)oxygenSlot).gameObject.SetActive(false); } else { ((Component)oxygenRoot).gameObject.SetActive(true); ((Component)oxygenSlot).gameObject.SetActive(true); oxygenFade.Reveal(); if (lastAutoHide && !oxygenBusy) { oxygenFade.FadeAfter(lastDelay, lastFadeOpacity); } } MovePercentageLayout(); if (Plugin.HasOxygen) { if (lastDisabled) { OxygenCompatibility.ShowOxygenMeter(); } else { OxygenCompatibility.HideOxygenMeter(); } } } private void OnDisable() { staminaFade.VisibilityChanged -= MovePercentageLayout; oxygenFade.VisibilityChanged -= MovePercentageLayout; if (layoutTransition != null) { ((MonoBehaviour)this).StopCoroutine(layoutTransition); layoutTransition = null; } OxygenExpansion = 0f; EladsHealthDisplay instance = EladsHealthDisplay.Instance; if ((Object)(object)instance != (Object)null && ((Behaviour)instance).isActiveAndEnabled) { instance.PositionWeightForOxygen(0f); } if (Plugin.HasOxygen) { OxygenCompatibility.ShowOxygenMeter(); } } private void Start() { Instance = this; PositionPercentageLayout(); if (Plugin.HasOxygen && !Plugin.DisableOxygenBar.Value) { OxygenCompatibility.HideOxygenMeter(); } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } internal void Refresh(float oxygen) { bool value = Plugin.DisableOxygenBar.Value; bool flag = value != lastDisabled; if (flag) { if (value) { oxygenFade.Hide(); } lastDisabled = value; ((Component)oxygenRoot).gameObject.SetActive(!value); ((Component)oxygenSlot).gameObject.SetActive(!value); if (Plugin.HasOxygen) { if (value) { OxygenCompatibility.ShowOxygenMeter(); } else { OxygenCompatibility.HideOxygenMeter(); } } MovePercentageLayout(); } if (value) { return; } oxygen = Mathf.Clamp01(oxygen); oxygenFill.fillAmount = oxygen; int num = Mathf.RoundToInt(oxygen * 100f); bool flag2 = lastPercent < 0; if (num != lastPercent) { oxygenText.text = Utility.PercentageText(num); lastPercent = num; } bool value2 = Plugin.AutoHideOxygen.Value; bool value3 = Plugin.UseOxygenPopupPercentage.Value; float value4 = Plugin.OxygenHideDelay.Value; float value5 = Plugin.OxygenFadeOpacity.Value; float value6 = Plugin.OxygenPopupPercentage.Value; bool flag3 = ((!value3) ? (num < 100) : ((float)num <= value6)); bool flag4 = value2 != lastAutoHide || value3 != lastUsePopupPercentage || !Mathf.Approximately(value4, lastDelay) || !Mathf.Approximately(value5, lastFadeOpacity) || !Mathf.Approximately(value6, lastPopupPercentage); bool flag5 = flag3 != oxygenBusy; lastAutoHide = value2; lastUsePopupPercentage = value3; lastDelay = value4; lastFadeOpacity = value5; lastPopupPercentage = value6; oxygenBusy = flag3; if (flag4 || flag5 || flag || flag2) { oxygenFade.Reveal(); if (value2 && !flag3) { oxygenFade.FadeAfter(value4, value5); } } } private void MovePercentageLayout() { if (layoutTransition != null) { ((MonoBehaviour)this).StopCoroutine(layoutTransition); } layoutTransition = ((MonoBehaviour)this).StartCoroutine(MovePercentageLayoutUntilFinished()); } private IEnumerator MovePercentageLayoutUntilFinished() { do { PositionPercentageLayout(); yield return null; } while (staminaFade.IsFading || (!lastDisabled && oxygenFade.IsFading)); PositionPercentageLayout(); layoutTransition = null; } private void PositionPercentageLayout() { //IL_008b: 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_0097: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.SmoothStep(0f, 1f, staminaFade.Visibility); float num2 = 0f; if (!lastDisabled) { num2 = Mathf.SmoothStep(0f, 1f, oxygenFade.Visibility); } OxygenExpansion = num2; staminaSlot.preferredWidth = staminaSlotWidth * num; oxygenSlot.preferredWidth = oxygenSlotWidth * num2; ((HorizontalOrVerticalLayoutGroup)percentageLayout).spacing = percentageSpacing * num; ((Transform)percentageRow).localPosition = Vector3.Lerp(percentagePosition, percentageOxygenPosition, num2); EladsHealthDisplay instance = EladsHealthDisplay.Instance; if ((Object)(object)instance != (Object)null && ((Behaviour)instance).isActiveAndEnabled) { instance.PositionWeightForOxygen(OxygenExpansion); } } } internal class EladsStaminaDisplay : MonoBehaviour { [SerializeField] private LHStaminaBarRefs staminaRefs; [SerializeField] private TMP_Text staminaText; [SerializeField] private ShaderFadeGroup staminaFade; private int lastPercent = -1; private bool lastAutoHide; private bool staminaBusy; private float lastDelay; private float lastFadeOpacity; private Color fillColor; private Color canvasColor; private float staminaAlpha; internal static EladsStaminaDisplay? Instance { get; private set; } internal Vector3 Scale { get; private set; } private void Awake() { //IL_0007: 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_0022: 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) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Scale = ((Component)this).transform.localScale; fillColor = ((Graphic)staminaRefs.fill).color; canvasColor = ((Graphic)staminaRefs.fill).canvasRenderer.GetColor(); staminaAlpha = ((Graphic)staminaText).color.a; Log.Info("Found and cached stamina elements"); } private void Start() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Instance = this; Utility.ResizeHUD((RectTransform)((Component)this).transform, Scale); } private void OnEnable() { Plugins.ConfigEntries.CustomStaminaShaderColor.SettingChanged += OnStaminaBarColorChanged; Plugins.ConfigEntries.SprintMeterColor.SettingChanged += OnStaminaColorChanged; UpdateStaminaBarColor(); UpdateStaminaTextColor(); lastAutoHide = Plugin.AutoHideStamina.Value; lastDelay = Plugin.StaminaHideDelay.Value; lastFadeOpacity = Plugin.StaminaFadeOpacity.Value; staminaFade.Reveal(); if (lastAutoHide) { staminaFade.FadeAfter(lastDelay, lastFadeOpacity); } } private void OnDisable() { Plugins.ConfigEntries.CustomStaminaShaderColor.SettingChanged -= OnStaminaBarColorChanged; Plugins.ConfigEntries.SprintMeterColor.SettingChanged -= OnStaminaColorChanged; HUDManagerPatches.RefreshHUDLayout(); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } internal void Refresh(float correctedStamina, bool staminaBusy, bool weightChanged) { //IL_0008: 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_0039: Unknown result type (might be due to invalid IL or missing references) staminaRefs.UpdateStaminaUI(correctedStamina, fillColor); ((Graphic)staminaRefs.fill).color = fillColor; ((Graphic)staminaRefs.fill).canvasRenderer.SetColor(canvasColor); int num = Mathf.RoundToInt(correctedStamina * 100f); if (num != lastPercent) { staminaText.text = Utility.PercentageText(num); lastPercent = num; } bool value = Plugin.AutoHideStamina.Value; float value2 = Plugin.StaminaHideDelay.Value; float value3 = Plugin.StaminaFadeOpacity.Value; bool flag = value != lastAutoHide || !Mathf.Approximately(value2, lastDelay) || !Mathf.Approximately(value3, lastFadeOpacity); bool flag2 = staminaBusy != this.staminaBusy; lastAutoHide = value; lastDelay = value2; lastFadeOpacity = value3; this.staminaBusy = staminaBusy; if (flag || flag2 || weightChanged) { staminaFade.Reveal(); if (value && !staminaBusy) { staminaFade.FadeAfter(value2, value3); } } } private void OnStaminaColorChanged(object sender, EventArgs args) { UpdateStaminaTextColor(); } private void OnStaminaBarColorChanged(object sender, EventArgs args) { UpdateStaminaBarColor(); } private void UpdateStaminaBarColor() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Color val = Utility.ParseHtmlColor(Plugins.ConfigEntries.CustomStaminaShaderColor.Value, fillColor); ((Graphic)staminaRefs.fill).material.SetColor(Utility.FlowColorId, val); } private void UpdateStaminaTextColor() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) Color color = Utility.ParseHtmlColor(Plugins.ConfigEntries.SprintMeterColor.Value, Color.white); color.a = staminaAlpha; ((Graphic)staminaText).color = color; } } internal class EladsUtilitySlotDisplay : MonoBehaviour { private const float FadeSeconds = 1f; private Animator animator; private RuntimeAnimatorController originalAnimator; private RuntimeAnimatorController utilitySlotAnimator; private CanvasGroup fadeGroup; private GameObject utilitySlot; private GameObject slotTransparent; private Image[] utilitySlotImages = Array.Empty<Image>(); private Sprite[] originalUtilitySlotSprites = Array.Empty<Sprite>(); private Color[] originalUtilitySlotColors = Array.Empty<Color>(); private bool slotTransparentActive; private Sprite utilitySlotSprite; private Color utilitySlotColor; private GameObject[] hiddenElements = Array.Empty<GameObject>(); private bool[] hiddenElementStates = Array.Empty<bool>(); private bool utilitySlotActive; private bool customised; private bool occupied; private bool equipped; private bool lastAutoHide; private bool lastAutoHideOccupied; private float lastDelay; private float lastFadeOpacity; private Coroutine fadeProcess; internal void Initialise(RectTransform slot, RuntimeAnimatorController replacementAnimator, Sprite replacementSprite, Color replacementColor) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) utilitySlot = ((Component)slot).gameObject; utilitySlotActive = utilitySlot.activeSelf; animator = ((Component)slot).GetComponent<Animator>(); originalAnimator = animator.runtimeAnimatorController; utilitySlotAnimator = replacementAnimator; utilitySlotImages = (Image[])(object)new Image[1] { ((Component)slot).GetComponent<Image>() }; slotTransparent = ((Component)((Transform)slot).Find("SlotTransparent")).gameObject; slotTransparentActive = slotTransparent.activeSelf; originalUtilitySlotSprites = (Sprite[])(object)new Sprite[1] { utilitySlotImages[0].sprite }; originalUtilitySlotColors = (Color[])(object)new Color[1] { ((Graphic)utilitySlotImages[0]).color }; utilitySlotSprite = replacementSprite; utilitySlotColor = replacementColor; fadeGroup = utilitySlot.AddComponent<CanvasGroup>(); ((Behaviour)fadeGroup).enabled = false; fadeGroup.interactable = false; fadeGroup.blocksRaycasts = false; hiddenElements = (GameObject[])(object)new GameObject[6] { ((Component)((Transform)slot).Find("ItemOnlySlotTipText")).gameObject, ((Component)((Transform)slot).Find("Image (1)")).gameObject, ((Component)((Transform)slot).Find("Image (3)")).gameObject, ((Component)((Transform)slot).Find("Image (4)")).gameObject, ((Component)((Transform)slot).Find("Image (2)")).gameObject, ((Component)((Transform)slot).Find("Image")).gameObject }; hiddenElementStates = new bool[hiddenElements.Length]; for (int i = 0; i < hiddenElements.Length; i++) { hiddenElementStates[i] = hiddenElements[i].activeSelf; } Log.Info("Found and cached utility slot"); } internal void Customise() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) if (!customised) { customised = true; occupied = false; equipped = false; lastAutoHide = Plugin.AutoHideUtilitySlot.Value; lastAutoHideOccupied = Plugin.AutoHideOccupiedUtilitySlot.Value; lastDelay = Plugin.UtilitySlotHideDelay.Value; lastFadeOpacity = Plugin.UtilitySlotFadeOpacity.Value; utilitySlot.SetActive(true); Image[] array = utilitySlotImages; foreach (Image val in array) { val.sprite = utilitySlotSprite; ((Graphic)val).color = utilitySlotColor; } slotTransparent.SetActive(false); animator.runtimeAnimatorController = utilitySlotAnimator; ((Behaviour)fadeGroup).enabled = true; fadeGroup.alpha = 1f; GameObject[] array2 = hiddenElements; foreach (GameObject val2 in array2) { val2.SetActive(false); } if (fadeProcess != null) { ((MonoBehaviour)this).StopCoroutine(fadeProcess); } if (lastAutoHide) { fadeProcess = ((MonoBehaviour)this).StartCoroutine(FadeAfter(lastDelay, lastFadeOpacity)); } } } internal void Restore() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (customised) { customised = false; if (fadeProcess != null) { ((MonoBehaviour)this).StopCoroutine(fadeProcess); fadeProcess = null; } fadeGroup.alpha = 1f; ((Behaviour)fadeGroup).enabled = false; for (int i = 0; i < utilitySlotImages.Length; i++) { utilitySlotImages[i].sprite = originalUtilitySlotSprites[i]; ((Graphic)utilitySlotImages[i]).color = originalUtilitySlotColors[i]; } animator.runtimeAnimatorController = originalAnimator; for (int j = 0; j < hiddenElements.Length; j++) { hiddenElements[j].SetActive(hiddenElementStates[j]); } slotTransparent.SetActive(slotTransparentActive); utilitySlot.SetActive(utilitySlotActive); Log.Info("Restored the vanilla utility slot"); } } internal void Refresh(PlayerControllerB player) { if (!customised) { return; } if (!utilitySlot.activeSelf) { utilitySlot.SetActive(true); } bool flag = (Object)(object)player.ItemOnlySlot != (Object)null; bool flag2 = player.currentItemSlot == 50; bool value = Plugin.AutoHideUtilitySlot.Value; bool value2 = Plugin.AutoHideOccupiedUtilitySlot.Value; float value3 = Plugin.UtilitySlotHideDelay.Value; float value4 = Plugin.UtilitySlotFadeOpacity.Value; bool flag3 = flag != occupied; bool flag4 = flag2 != equipped; bool flag5 = value != lastAutoHide || value2 != lastAutoHideOccupied || !Mathf.Approximately(value3, lastDelay) || !Mathf.Approximately(value4, lastFadeOpacity); if (flag3 || flag4 || flag5) { occupied = flag; equipped = flag2; lastAutoHide = value; lastAutoHideOccupied = value2; lastDelay = value3; lastFadeOpacity = value4; if (fadeProcess != null) { ((MonoBehaviour)this).StopCoroutine(fadeProcess); } bool flag6 = false; if (value && !equipped && (!occupied || value2)) { flag6 = true; } if (flag6) { fadeProcess = ((MonoBehaviour)this).StartCoroutine(FadeAfter(value3, value4)); } else { fadeProcess = ((MonoBehaviour)this).StartCoroutine(FadeTo(1f)); } } } private IEnumerator FadeAfter(float seconds, float targetAlpha) { yield return FadeTo(1f); if (seconds > 0f) { yield return (object)new WaitForSeconds(seconds); } yield return FadeTo(targetAlpha); } private IEnumerator FadeTo(float targetAlpha) { if (Mathf.Approximately(fadeGroup.alpha, targetAlpha)) { fadeGroup.alpha = targetAlpha; yield break; } float startAlpha = fadeGroup.alpha; float elapsed = 0f; while (elapsed < 1f) { elapsed += Time.deltaTime; fadeGroup.alpha = Mathf.Lerp(startAlpha, targetAlpha, Mathf.Clamp01(elapsed / 1f)); yield return null; } fadeGroup.alpha = targetAlpha; } } [DefaultExecutionOrder(-100)] internal class ShaderFadeGroup : MonoBehaviour { private static readonly int FadeStartTimeId = Shader.PropertyToID("_FadeStartTime"); private static readonly int FadeStartAlphaId = Shader.PropertyToID("_FadeStartAlpha"); private static readonly int FadeTargetAlphaId = Shader.PropertyToID("_FadeTargetAlpha"); private static readonly int FadeDurationId = Shader.PropertyToID("_FadeDuration"); [SerializeField] private Graphic[] fadeGraphics = Array.Empty<Graphic>(); [SerializeField] private float fadeSeconds = 1f; private Material[] materials = Array.Empty<Material>(); private Coroutine fadeWait; private float fadeStartTime; private float fadeStartAlpha = 1f; private float fadeTargetAlpha = 1f; private float fadeDuration = 1f; private float fadeAt = -1f; private float fadeAfterAlpha; internal float Visibility { get { float num = Mathf.Max(0f, Time.timeSinceLevelLoad - fadeStartTime); return Mathf.Lerp(fadeStartAlpha, fadeTargetAlpha, Mathf.Clamp01(num / Mathf.Max(fadeDuration, 0.0001f))); } } internal bool IsFading => !Mathf.Approximately(Visibility, fadeTargetAlpha); internal event Action? VisibilityChanged; private void Awake() { fadeDuration = fadeSeconds; materials = (Material[])(object)new Material[fadeGraphics.Length]; for (int i = 0; i < fadeGraphics.Length; i++) { Graphic val = fadeGraphics[i]; Material material = val.material; TMP_Text val2 = (TMP_Text)(object)((val is TMP_Text) ? val : null); material = ((val2 == null) ? (val.material = Object.Instantiate<Material>(material)) : (val2.fontMaterial = Object.Instantiate<Material>(val2.fontSharedMaterial))); materials[i] = material; } ChangeAlpha(1f); } private void OnEnable() { if (!(fadeAt < 0f)) { float num = fadeAt - Time.time; if (num <= 0f) { fadeAt = -1f; ChangeAlpha(fadeAfterAlpha); this.VisibilityChanged?.Invoke(); } else { fadeWait = ((MonoBehaviour)this).StartCoroutine(FadeWhenReady(num, fadeAfterAlpha)); } } } private void OnDisable() { if (fadeWait != null) { ((MonoBehaviour)this).StopCoroutine(fadeWait); fadeWait = null; } } private void OnDestroy() { Material[] array = materials; foreach (Material val in array) { Object.Destroy((Object)(object)val); } } internal void Reveal(bool instant = false) { if (fadeWait != null) { ((MonoBehaviour)this).StopCoroutine(fadeWait); fadeWait = null; } fadeAt = -1f; ChangeAlpha(1f, instant); this.VisibilityChanged?.Invoke(); } internal void Hide(float opacity = 0f) { if (fadeWait != null) { ((MonoBehaviour)this).StopCoroutine(fadeWait); fadeWait = null; } fadeAt = -1f; ChangeAlpha(opacity, instant: true); this.VisibilityChanged?.Invoke(); } internal void FadeAfter(float seconds, float opacity) { if (fadeWait != null) { ((MonoBehaviour)this).StopCoroutine(fadeWait); } fadeAt = Time.time + seconds; fadeAfterAlpha = opacity; fadeWait = ((MonoBehaviour)this).StartCoroutine(FadeWhenReady(seconds, opacity)); } private IEnumerator FadeWhenReady(float seconds, float opacity) { if (seconds > 0f) { yield return (object)new WaitForSeconds(seconds); } fadeWait = null; fadeAt = -1f; ChangeAlpha(opacity); this.VisibilityChanged?.Invoke(); } private void ChangeAlpha(float alpha, bool instant = false) { float timeSinceLevelLoad = Time.timeSinceLevelLoad; float num = ((!instant) ? Visibility : alpha); if (Mathf.Approximately(num, alpha) && Mathf.Approximately(fadeTargetAlpha, alpha)) { return; } fadeStartTime = timeSinceLevelLoad; fadeStartAlpha = num; fadeTargetAlpha = alpha; fadeDuration = fadeSeconds; for (int i = 0; i < materials.Length; i++) { Material val = materials[i]; val.SetFloat(FadeStartTimeId, fadeStartTime); val.SetFloat(FadeStartAlphaId, fadeStartAlpha); val.SetFloat(FadeTargetAlphaId, fadeTargetAlpha); val.SetFloat(FadeDurationId, fadeDuration); Material materialForRendering = fadeGraphics[i].materialForRendering; if ((Object)(object)materialForRendering != (Object)null && (Object)(object)materialForRendering != (Object)(object)val) { materialForRendering.SetFloat(FadeStartTimeId, fadeStartTime); materialForRendering.SetFloat(FadeStartAlphaId, fadeStartAlpha); materialForRendering.SetFloat(FadeTargetAlphaId, fadeTargetAlpha); materialForRendering.SetFloat(FadeDurationId, fadeDuration); } } } } }