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 SimpleHUD v2.0.0
SimpleHUD.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using InfectionHUD.Patches; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("SimpleHUD")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0.0")] [assembly: AssemblyProduct("SimpleHUD")] [assembly: AssemblyTitle("SimpleHUD")] [assembly: AssemblyVersion("2.0.0.0")] namespace SimpleHUD; internal static class PluginInfo { public const string PLUGIN_GUID = "SimpleHUD"; public const string PLUGIN_NAME = "SimpleHUD"; public const string PLUGIN_VERSION = "2.0.0"; } [BepInPlugin("SimpleHUD", "SimpleHUD", "2.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class SimpleHUDPlugin : BaseUnityPlugin { internal static ConfigEntry<bool> AlwaysShowNumbers; internal static ConfigEntry<bool> HideSimpleHUD; internal static ConfigEntry<bool> HideVanillaHUD; internal static ConfigEntry<bool> HideVanillaHealthBar; internal static ConfigEntry<bool> HideVanillaStaminaBar; internal static ConfigEntry<bool> HideVanillaBatteries; internal static ConfigEntry<bool> HideVanillaWeight; internal static ConfigEntry<float> PosOffsetX; internal static ConfigEntry<float> PosOffsetY; internal static ConfigEntry<float> StaminaColorR; internal static ConfigEntry<float> StaminaColorG; internal static ConfigEntry<float> StaminaColorB; internal static ConfigEntry<bool> HideOxygen; internal static ConfigEntry<bool> ShowOxygenOnlyInWater; internal static ConfigEntry<bool> EnvironmentSimulation; internal static ConfigEntry<bool> SyncHostConfig; internal static ConfigEntry<bool> HostShareConfig; internal static ConfigEntry<bool> ClientSideMode; internal static ConfigEntry<bool> HideHealth; internal static ConfigEntry<bool> HideStamina; internal static ConfigEntry<bool> HideWeight; internal static ConfigEntry<bool> HideBattery; internal static ConfigEntry<bool> HideFear; internal static ConfigEntry<bool> HideInfection; internal static ConfigEntry<float> FontSize; internal static ConfigEntry<float> LineGapCfg; internal static ConfigEntry<float> HealthColorFullR; internal static ConfigEntry<float> HealthColorFullG; internal static ConfigEntry<float> HealthColorFullB; internal static ConfigEntry<float> HealthColorLowR; internal static ConfigEntry<float> HealthColorLowG; internal static ConfigEntry<float> HealthColorLowB; internal static ConfigEntry<float> WeightColorR; internal static ConfigEntry<float> WeightColorG; internal static ConfigEntry<float> WeightColorB; internal static ConfigEntry<float> BatteryColorR; internal static ConfigEntry<float> BatteryColorG; internal static ConfigEntry<float> BatteryColorB; internal static ConfigEntry<float> OxygenColorR; internal static ConfigEntry<float> OxygenColorG; internal static ConfigEntry<float> OxygenColorB; internal static ConfigEntry<float> OxygenLowColorR; internal static ConfigEntry<float> OxygenLowColorG; internal static ConfigEntry<float> OxygenLowColorB; internal static ConfigEntry<float> FearColorR; internal static ConfigEntry<float> FearColorG; internal static ConfigEntry<float> FearColorB; internal static ConfigEntry<float> FearHighColorR; internal static ConfigEntry<float> FearHighColorG; internal static ConfigEntry<float> FearHighColorB; internal static bool CfgHideSimpleHUD; internal static bool CfgHideVanillaHUD; internal static bool CfgAlwaysShowNumbers; internal static bool CfgHideVanillaHealthBar; internal static bool CfgHideVanillaStaminaBar; internal static bool CfgHideVanillaBatteries; internal static bool CfgHideVanillaWeight; internal static float CfgStaminaColorR; internal static float CfgStaminaColorG; internal static float CfgStaminaColorB; internal static bool CfgHideOxygen; internal static bool CfgShowOxygenOnlyInWater; internal static bool CfgEnvironmentSimulation; internal static bool CfgSyncHostConfig; internal static bool CfgHostShareConfig; internal static bool CfgClientSideMode; internal static bool CfgHideHealth; internal static bool CfgHideStamina; internal static bool CfgHideWeight; internal static bool CfgHideBattery; internal static bool CfgHideFear; internal static bool CfgHideInfection; internal static float CfgFontSize; internal static float CfgLineGap; internal static Color CfgHealthColorFull; internal static Color CfgHealthColorLow; internal static Color CfgWeightColor; internal static Color CfgBatteryColor; internal static Color CfgOxygenColor; internal static Color CfgOxygenLowColor; internal static Color CfgFearColor; internal static Color CfgFearHighColor; private static bool cachedOxygenDisplayOnlyInWater; private static float lastOxygenCfgReadTime = -1f; private const string MsgSyncHostConfig = "SimpleHUD_SyncHostConfig"; private const string MsgHandshake = "SimpleHUD_Handshake"; private const string MsgReject = "SimpleHUD_Reject"; private const float HandshakeGraceSeconds = 15f; private const float HandshakeRetrySeconds = 2f; private static bool netHandlersRegistered; private static bool handshakeSent; private static float lastHandshakeTime = -1f; private static int lastHostClientCount = -1; private static bool hostConfigDirty = true; private static readonly HashSet<ulong> handshakenClients = new HashSet<ulong>(); private static readonly Dictionary<ulong, float> clientJoinTime = new Dictionary<ulong, float>(); public static SimpleHUDPlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static void RefreshConfigCache() { //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) CfgHideSimpleHUD = HideSimpleHUD != null && HideSimpleHUD.Value; CfgHideVanillaHUD = HideVanillaHUD != null && HideVanillaHUD.Value; bool cfgAlwaysShowNumbers = CfgAlwaysShowNumbers; CfgAlwaysShowNumbers = AlwaysShowNumbers != null && AlwaysShowNumbers.Value; CfgHideVanillaHealthBar = HideVanillaHealthBar != null && HideVanillaHealthBar.Value; CfgHideVanillaStaminaBar = HideVanillaStaminaBar != null && HideVanillaStaminaBar.Value; CfgHideVanillaBatteries = HideVanillaBatteries != null && HideVanillaBatteries.Value; CfgHideVanillaWeight = HideVanillaWeight != null && HideVanillaWeight.Value; CfgStaminaColorR = ((StaminaColorR != null) ? StaminaColorR.Value : 1f); CfgStaminaColorG = ((StaminaColorG != null) ? StaminaColorG.Value : 0.9f); CfgStaminaColorB = ((StaminaColorB != null) ? StaminaColorB.Value : 0.15f); CfgHideOxygen = HideOxygen != null && HideOxygen.Value; CfgShowOxygenOnlyInWater = ShowOxygenOnlyInWater != null && ShowOxygenOnlyInWater.Value; CfgEnvironmentSimulation = EnvironmentSimulation != null && EnvironmentSimulation.Value; CfgSyncHostConfig = SyncHostConfig != null && SyncHostConfig.Value; CfgHostShareConfig = HostShareConfig != null && HostShareConfig.Value; CfgClientSideMode = ClientSideMode != null && ClientSideMode.Value; CfgHideHealth = HideHealth != null && HideHealth.Value; CfgHideStamina = HideStamina != null && HideStamina.Value; CfgHideWeight = HideWeight != null && HideWeight.Value; CfgHideBattery = HideBattery != null && HideBattery.Value; CfgHideFear = HideFear != null && HideFear.Value; CfgHideInfection = HideInfection != null && HideInfection.Value; CfgFontSize = ((FontSize != null) ? FontSize.Value : 0f); CfgLineGap = ((LineGapCfg != null) ? LineGapCfg.Value : 22f); HUDPatches.LineGap = CfgLineGap; CfgHealthColorFull = new Color((HealthColorFullR != null) ? HealthColorFullR.Value : 1f, (HealthColorFullG != null) ? HealthColorFullG.Value : 0f, (HealthColorFullB != null) ? HealthColorFullB.Value : 0f); CfgHealthColorLow = new Color((HealthColorLowR != null) ? HealthColorLowR.Value : 0f, (HealthColorLowG != null) ? HealthColorLowG.Value : 1f, (HealthColorLowB != null) ? HealthColorLowB.Value : 0f); CfgWeightColor = new Color((WeightColorR != null) ? WeightColorR.Value : 1f, (WeightColorG != null) ? WeightColorG.Value : 1f, (WeightColorB != null) ? WeightColorB.Value : 1f); CfgBatteryColor = new Color((BatteryColorR != null) ? BatteryColorR.Value : 1f, (BatteryColorG != null) ? BatteryColorG.Value : 1f, (BatteryColorB != null) ? BatteryColorB.Value : 1f); CfgOxygenColor = new Color((OxygenColorR != null) ? OxygenColorR.Value : 1f, (OxygenColorG != null) ? OxygenColorG.Value : 1f, (OxygenColorB != null) ? OxygenColorB.Value : 1f); CfgOxygenLowColor = new Color((OxygenLowColorR != null) ? OxygenLowColorR.Value : 1f, (OxygenLowColorG != null) ? OxygenLowColorG.Value : 0f, (OxygenLowColorB != null) ? OxygenLowColorB.Value : 0f); CfgFearColor = new Color((FearColorR != null) ? FearColorR.Value : 1f, (FearColorG != null) ? FearColorG.Value : 1f, (FearColorB != null) ? FearColorB.Value : 1f); CfgFearHighColor = new Color((FearHighColorR != null) ? FearHighColorR.Value : 1f, (FearHighColorG != null) ? FearHighColorG.Value : 0f, (FearHighColorB != null) ? FearHighColorB.Value : 0f); if (cfgAlwaysShowNumbers != CfgAlwaysShowNumbers) { PlayerPatches.ResetAlphaCaches(); } PlayerPatches.ResetValueCaches(); HUDPatches.ApplyStaticRowColors(); PlayerPatches.RebuildStaminaColorTable(); } internal static bool GetOxygenDisplayOnlyInWater() { if (Time.unscaledTime - lastOxygenCfgReadTime > 2f) { lastOxygenCfgReadTime = Time.unscaledTime; cachedOxygenDisplayOnlyInWater = false; try { string path = Path.Combine(Paths.ConfigPath, "OxygenDisplay.cfg"); if (File.Exists(path)) { string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.StartsWith("Show Only In Water", StringComparison.OrdinalIgnoreCase)) { int num = text.IndexOf('='); if (num >= 0 && text.Substring(num + 1).Trim().Equals("true", StringComparison.OrdinalIgnoreCase)) { cachedOxygenDisplayOnlyInWater = true; } break; } } } } catch (Exception ex) { Log.LogWarning((object)("SimpleHUD: failed to read OxygenDisplay.cfg: " + ex.Message)); } } return cachedOxygenDisplayOnlyInWater; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Instance = this; AlwaysShowNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AlwaysShowNumbers", true, "If true, the health/stamina numbers are always visible no matter the value. If false, when a number reaches 100 (full) it starts fading out immediately and becomes fully invisible after 5 seconds; the number reappears right away once the value drops below 100. Health and stamina fade independently."); HideSimpleHUD = ((BaseUnityPlugin)this).Config.Bind<bool>("SimpleHUDSetting", "HideSimpleHUD", false, "Master switch: hide ALL SimpleHUD number lines at once. Default false (numbers shown), so the SimpleHUD works right after installation. Individual Hide* switches below control each line."); HideVanillaHUD = ((BaseUnityPlugin)this).Config.Bind<bool>("VanillaHUDSetting", "HideVanillaHUD", true, "You must enable this option for the settings below (HideVanillaHealthBar / HideVanillaStaminaBar / HideVanillaBatteries / HideVanillaWeight) to take effect. When disabled, all vanilla HUD elements stay visible no matter what the sub-switches say. The item toolbar / hotbar is NOT affected and stays visible. Default true."); HideVanillaHealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("VanillaHUDSetting", "HideVanillaHealthBar", true, "Hide the vanilla health bar (the 'Self' player info element, top-left). Only takes effect while HideVanillaHUD is ON. Default true."); HideVanillaStaminaBar = ((BaseUnityPlugin)this).Config.Bind<bool>("VanillaHUDSetting", "HideVanillaStaminaBar", true, "Hide the vanilla stamina bar ('SprintMeter' element). Only takes effect while HideVanillaHUD is ON. Default true."); HideVanillaBatteries = ((BaseUnityPlugin)this).Config.Bind<bool>("VanillaHUDSetting", "HideVanillaBatteries", true, "Hide the vanilla battery icons ('Batteries'/'BatteriesOff' elements). Only takes effect while HideVanillaHUD is ON. Default true."); HideVanillaWeight = ((BaseUnityPlugin)this).Config.Bind<bool>("VanillaHUDSetting", "HideVanillaWeight", true, "Hide the vanilla weight counter text ('X lb', shown near the tool slot sidebar). Only takes effect while HideVanillaHUD is ON, and only while the SimpleHUD numbers are shown (HideSimpleHUD must be false). Default true."); PosOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Texts", "PosOffsetX", 50f, "Horizontal offset (px) of the SimpleHUD numbers from the base position (aligned with the InfectionHUD infection text). Right is positive."); PosOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Texts", "PosOffsetY", 120f, "Vertical offset (px) of the SimpleHUD numbers from the base position. Up is positive."); StaminaColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "StaminaColorR", 1f, "Stamina text red channel (0-1). Default bright yellow."); StaminaColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "StaminaColorG", 0.9f, "Stamina text green channel (0-1). Default bright yellow."); StaminaColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "StaminaColorB", 0.15f, "Stamina text blue channel (0-1). Default bright yellow."); HideOxygen = ((BaseUnityPlugin)this).Config.Bind<bool>("SimpleHUDSetting", "HideOxygen", false, "Hide the oxygen value line (e.g. '100 O2') below the weight number. Oxygen is computed from StartOfRound.drowningTimer, the same data source as the OxygenDisplay mod (install it as a prerequisite). The line turns red below 30% oxygen. Default false (shown)."); ShowOxygenOnlyInWater = ((BaseUnityPlugin)this).Config.Bind<bool>("SimpleHUDSetting", "ShowOxygenOnlyInWater", true, "Only show the oxygen line while the player is in water (uses HUDManager.setUnderwaterFilter). Default true (only while in water)."); EnvironmentSimulation = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnvironmentSimulation", false, "Environment Simulation: when enabled, simulates the environment for the HUD so that ALL SimpleHUD lines are displayed. This option has no other effect; it only controls showing this mod's HUD. Default false."); HideHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("SimpleHUDSetting", "HideHealth", false, "Hide the health number line ('X HP'). Set to true to hide this line entirely (overrides EnvironmentSimulation). Default false (shown)."); HideStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("SimpleHUDSetting", "HideStamina", false, "Hide the stamina number line ('X% SP'). Set to true to hide this line entirely (overrides EnvironmentSimulation). Default false (shown)."); HideWeight = ((BaseUnityPlugin)this).Config.Bind<bool>("SimpleHUDSetting", "HideWeight", false, "Hide the weight number line ('X lb'). Set to true to hide this line entirely (overrides EnvironmentSimulation). Default false (shown)."); HideBattery = ((BaseUnityPlugin)this).Config.Bind<bool>("SimpleHUDSetting", "HideBattery", false, "Hide the battery percentage line while holding a battery-powered item. Set to true to hide this line entirely (overrides EnvironmentSimulation). Default false (shown)."); HideFear = ((BaseUnityPlugin)this).Config.Bind<bool>("SimpleHUDSetting", "HideFear", true, "Hide the fear value line ('X Fear'). Set to true to hide this line entirely (overrides EnvironmentSimulation). Default true (hidden)."); HideInfection = ((BaseUnityPlugin)this).Config.Bind<bool>("SimpleHUDSetting", "HideInfection", true, "Hide the InfectionHUD infection value line ('X% infected'). Set to true to hide the infection text entirely (the InfectionHUD mod must still be installed as a prerequisite). Default true (hidden)."); FontSize = ((BaseUnityPlugin)this).Config.Bind<float>("Texts", "FontSize", 0f, "Font size for all SimpleHUD number lines. 0 = keep the vanilla weight counter font size. Any positive value overrides all lines. Default 0."); LineGapCfg = ((BaseUnityPlugin)this).Config.Bind<float>("Texts", "LineGap", 22f, "Vertical gap (px) between consecutive SimpleHUD number lines. Default 22."); HealthColorFullR = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "HealthColorFullR", 1f, "Health text red channel at full health (0-1). Default red."); HealthColorFullG = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "HealthColorFullG", 0f, "Health text green channel at full health (0-1). Default red."); HealthColorFullB = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "HealthColorFullB", 0f, "Health text blue channel at full health (0-1). Default red."); HealthColorLowR = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "HealthColorLowR", 0f, "Health text red channel at low health (0-1). Default green."); HealthColorLowG = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "HealthColorLowG", 1f, "Health text green channel at low health (0-1). Default green."); HealthColorLowB = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "HealthColorLowB", 0f, "Health text blue channel at low health (0-1). Default green."); WeightColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "WeightColorR", 1f, "Weight text red channel (0-1). Default white."); WeightColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "WeightColorG", 1f, "Weight text green channel (0-1). Default white."); WeightColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "WeightColorB", 1f, "Weight text blue channel (0-1). Default white."); BatteryColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "BatteryColorR", 1f, "Battery text red channel (0-1). Default white."); BatteryColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "BatteryColorG", 1f, "Battery text green channel (0-1). Default white."); BatteryColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "BatteryColorB", 1f, "Battery text blue channel (0-1). Default white."); OxygenColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "OxygenColorR", 1f, "Oxygen text red channel above 30% (0-1). Default white."); OxygenColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "OxygenColorG", 1f, "Oxygen text green channel above 30% (0-1). Default white."); OxygenColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "OxygenColorB", 1f, "Oxygen text blue channel above 30% (0-1). Default white."); OxygenLowColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "OxygenLowColorR", 1f, "Oxygen text red channel at or below 30% (0-1). Default red."); OxygenLowColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "OxygenLowColorG", 0f, "Oxygen text green channel at or below 30% (0-1). Default red."); OxygenLowColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "OxygenLowColorB", 0f, "Oxygen text blue channel at or below 30% (0-1). Default red."); FearColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "FearColorR", 1f, "Fear text red channel below 60% (0-1). Default white."); FearColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "FearColorG", 1f, "Fear text green channel below 60% (0-1). Default white."); FearColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "FearColorB", 1f, "Fear text blue channel below 60% (0-1). Default white."); FearHighColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "FearHighColorR", 1f, "Fear text red channel at or above 60% (0-1). Default red."); FearHighColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "FearHighColorG", 0f, "Fear text green channel at or above 60% (0-1). Default red."); FearHighColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "FearHighColorB", 0f, "Fear text blue channel at or above 60% (0-1). Default red."); SyncHostConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Network", "SyncHostConfig", true, "Sync host's show/hide toggles: when enabled, this client automatically applies the host's Hide* visibility switches (ON/OFF state only; colors and other visual details are NOT synced). When disabled, host config is ignored. The sole purpose of this feature is to prevent other behaviors from tampering with the config file (host-authoritative visibility). Default true."); HostShareConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Network", "HostShareConfig", true, "Host shares show/hide toggles: when enabled, the host broadcasts its Hide* visibility switches to all clients; clients with SyncHostConfig ON apply them (state only, colors untouched). The sole purpose of this feature is to prevent other behaviors from tampering with the config file. Default true."); ClientSideMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Network", "ClientSideMode", true, "Client-side Mode: when enabled, vanilla (unmodded) players are allowed to join this room. When disabled, clients without this mod are blocked from joining and get the message \"You cannot join a non-vanilla room.\". Default true."); AlwaysShowNumbers.SettingChanged += OnConfigChanged; HideSimpleHUD.SettingChanged += OnConfigChanged; HideVanillaHUD.SettingChanged += OnConfigChanged; HideVanillaHealthBar.SettingChanged += OnConfigChanged; HideVanillaStaminaBar.SettingChanged += OnConfigChanged; HideVanillaBatteries.SettingChanged += OnConfigChanged; HideVanillaWeight.SettingChanged += OnConfigChanged; StaminaColorR.SettingChanged += OnConfigChanged; StaminaColorG.SettingChanged += OnConfigChanged; StaminaColorB.SettingChanged += OnConfigChanged; HideOxygen.SettingChanged += OnConfigChanged; ShowOxygenOnlyInWater.SettingChanged += OnConfigChanged; EnvironmentSimulation.SettingChanged += OnConfigChanged; HideHealth.SettingChanged += OnConfigChanged; HideStamina.SettingChanged += OnConfigChanged; HideWeight.SettingChanged += OnConfigChanged; HideBattery.SettingChanged += OnConfigChanged; HideFear.SettingChanged += OnConfigChanged; HideInfection.SettingChanged += OnConfigChanged; FontSize.SettingChanged += OnConfigChanged; LineGapCfg.SettingChanged += OnConfigChanged; HealthColorFullR.SettingChanged += OnConfigChanged; HealthColorFullG.SettingChanged += OnConfigChanged; HealthColorFullB.SettingChanged += OnConfigChanged; HealthColorLowR.SettingChanged += OnConfigChanged; HealthColorLowG.SettingChanged += OnConfigChanged; HealthColorLowB.SettingChanged += OnConfigChanged; WeightColorR.SettingChanged += OnConfigChanged; WeightColorG.SettingChanged += OnConfigChanged; WeightColorB.SettingChanged += OnConfigChanged; BatteryColorR.SettingChanged += OnConfigChanged; BatteryColorG.SettingChanged += OnConfigChanged; BatteryColorB.SettingChanged += OnConfigChanged; OxygenColorR.SettingChanged += OnConfigChanged; OxygenColorG.SettingChanged += OnConfigChanged; OxygenColorB.SettingChanged += OnConfigChanged; OxygenLowColorR.SettingChanged += OnConfigChanged; OxygenLowColorG.SettingChanged += OnConfigChanged; OxygenLowColorB.SettingChanged += OnConfigChanged; FearColorR.SettingChanged += OnConfigChanged; FearColorG.SettingChanged += OnConfigChanged; FearColorB.SettingChanged += OnConfigChanged; FearHighColorR.SettingChanged += OnConfigChanged; FearHighColorG.SettingChanged += OnConfigChanged; FearHighColorB.SettingChanged += OnConfigChanged; SyncHostConfig.SettingChanged += OnConfigChanged; HostShareConfig.SettingChanged += OnConfigChanged; ClientSideMode.SettingChanged += OnConfigChanged; RefreshConfigCache(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); Log.LogInfo((object)"SimpleHUD v2.0.0 has loaded!"); } private static void OnConfigChanged(object sender, object e) { RefreshConfigCache(); hostConfigDirty = true; } private void Update() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown if ((Object)(object)NetworkManager.Singleton == (Object)null) { return; } if (!netHandlersRegistered) { netHandlersRegistered = true; try { NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("SimpleHUD_SyncHostConfig", new HandleNamedMessageDelegate(OnHostConfigMessage)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("SimpleHUD_Handshake", new HandleNamedMessageDelegate(OnHandshakeMessage)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("SimpleHUD_Reject", new HandleNamedMessageDelegate(OnRejectMessage)); } catch (Exception ex) { Log.LogWarning((object)("SimpleHUD: failed to register network handlers: " + ex.Message)); netHandlersRegistered = false; } } if (NetworkManager.Singleton.IsServer) { IEnumerable<ulong> keys = NetworkManager.Singleton.ConnectedClients.Keys; foreach (ulong item in keys) { if (item != NetworkManager.Singleton.LocalClientId && !clientJoinTime.ContainsKey(item)) { clientJoinTime[item] = Time.unscaledTime; } } if (clientJoinTime.Count > 0) { List<ulong> list = new List<ulong>(); foreach (KeyValuePair<ulong, float> item2 in clientJoinTime) { if (!NetworkManager.Singleton.ConnectedClients.ContainsKey(item2.Key)) { list.Add(item2.Key); } } foreach (ulong item3 in list) { clientJoinTime.Remove(item3); handshakenClients.Remove(item3); } } if (!CfgClientSideMode) { foreach (ulong item4 in keys) { if (item4 != NetworkManager.Singleton.LocalClientId && !handshakenClients.Contains(item4) && clientJoinTime.TryGetValue(item4, out var value) && Time.unscaledTime - value > 15f) { KickNonModdedClient(item4); } } } if (CfgHostShareConfig) { int count = NetworkManager.Singleton.ConnectedClients.Count; if (count != lastHostClientCount || hostConfigDirty) { lastHostClientCount = count; hostConfigDirty = false; BroadcastHostConfig(); } } } else if (NetworkManager.Singleton.IsConnectedClient && (!handshakeSent || Time.unscaledTime - lastHandshakeTime > 2f)) { handshakeSent = true; lastHandshakeTime = Time.unscaledTime; SendHandshake(); } } private unsafe static void BroadcastHostConfig() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00d2: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer) { return; } ulong localClientId = NetworkManager.Singleton.LocalClientId; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { byte b = (CfgHideSimpleHUD ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideVanillaHUD ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideVanillaHealthBar ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideVanillaStaminaBar ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideVanillaBatteries ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideVanillaWeight ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideHealth ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideStamina ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideWeight ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideBattery ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideFear ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideInfection ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); b = (CfgHideOxygen ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); foreach (ulong key in NetworkManager.Singleton.ConnectedClients.Keys) { if (key != localClientId) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("SimpleHUD_SyncHostConfig", key, val, (NetworkDelivery)2); } } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private static void OnHostConfigMessage(ulong clientId, FastBufferReader reader) { //IL_000f: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) if (!CfgSyncHostConfig) { return; } try { byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); byte b2 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b2, default(ForPrimitives)); byte b3 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b3, default(ForPrimitives)); byte b4 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b4, default(ForPrimitives)); byte b5 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b5, default(ForPrimitives)); byte b6 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b6, default(ForPrimitives)); byte b7 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b7, default(ForPrimitives)); byte b8 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b8, default(ForPrimitives)); byte b9 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b9, default(ForPrimitives)); byte b10 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b10, default(ForPrimitives)); byte b11 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b11, default(ForPrimitives)); byte b12 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b12, default(ForPrimitives)); byte b13 = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b13, default(ForPrimitives)); HideSimpleHUD.Value = b != 0; HideVanillaHUD.Value = b2 != 0; HideVanillaHealthBar.Value = b3 != 0; HideVanillaStaminaBar.Value = b4 != 0; HideVanillaBatteries.Value = b5 != 0; HideVanillaWeight.Value = b6 != 0; HideHealth.Value = b7 != 0; HideStamina.Value = b8 != 0; HideWeight.Value = b9 != 0; HideBattery.Value = b10 != 0; HideFear.Value = b11 != 0; HideInfection.Value = b12 != 0; HideOxygen.Value = b13 != 0; } catch (Exception ex) { Log.LogWarning((object)("SimpleHUD: failed to parse host config message: " + ex.Message)); } } private unsafe static void SendHandshake() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsConnectedClient) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1); try { byte b = 1; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("SimpleHUD_Handshake", 0uL, val, (NetworkDelivery)2); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private static void OnHandshakeMessage(ulong clientId, FastBufferReader reader) { if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsServer) { handshakenClients.Add(clientId); } } private unsafe static void KickNonModdedClient(ulong clientId) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Log.LogInfo((object)$"SimpleHUD: client {clientId} does not run SimpleHUD and ClientSideMode is off - rejecting entry."); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1); try { byte b = 1; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("SimpleHUD_Reject", clientId, val, (NetworkDelivery)2); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } NetworkManager.Singleton.DisconnectClient(clientId); } private static void OnRejectMessage(ulong clientId, FastBufferReader reader) { try { if ((Object)(object)GameNetworkManager.Instance != (Object)null) { GameNetworkManager.Instance.disconnectionReasonMessage = "You cannot join a non-vanilla room."; } if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip("SimpleHUD", "You cannot join a non-vanilla room.", false, false, "SimpleHUD_RejectTip"); } } catch (Exception ex) { Log.LogWarning((object)("SimpleHUD: failed to show reject tip: " + ex.Message)); } } } [HarmonyPatch(typeof(HUDManager))] internal static class HUDPatches { public static CanvasGroup OriginalPlayerInfoCanvasGroup; public static CanvasGroup OriginalSelfRedCanvasGroup; public static Transform OriginalStaminaParent; public static Transform OriginalBatteryParent; public static TextMeshProUGUI HealthText; public static TextMeshProUGUI StaminaText; public static TextMeshProUGUI WeightText; public static TextMeshProUGUI BatteryText; public static TextMeshProUGUI OxygenText; public static TextMeshProUGUI FearText; public static TextMeshProUGUI VanillaWeightCounter; internal static float LineGap = 22f; private static Transform weightParent; private static readonly List<GameObject> hiddenVanillaObjects = new List<GameObject>(); private static readonly HashSet<string> loggedKeptNames = new HashSet<string>(); private static readonly HashSet<string> VanillaHideWhitelist = new HashSet<string> { "Self", "SprintMeter", "BatteriesOff", "Batteries" }; [HarmonyPostfix] [HarmonyPatch("Start")] private unsafe static void Start_Postfix(HUDManager __instance) { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0113: 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_0155: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) SimpleHUDPlugin.Log.LogInfo((object)"SimpleHUD Start hook fired."); PlayerPatches.ResetInfectionAlignment(); HUDElement[] array = (HUDElement[])typeof(HUDManager).GetField("HUDElements", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); if (array != null && array.Length >= 3) { OriginalPlayerInfoCanvasGroup = array[2].canvasGroup; OriginalSelfRedCanvasGroup = __instance.selfRedCanvasGroup; OriginalBatteryParent = ((Component)__instance.batteryMeter).transform.parent; } if ((Object)(object)__instance.weightCounter == (Object)null) { SimpleHUDPlugin.Log.LogError((object)"SimpleHUD: weightCounter is null, aborting."); return; } weightParent = ((TMP_Text)__instance.weightCounter).transform.parent; VanillaWeightCounter = __instance.weightCounter; Transform val = weightParent; float fontSize = ((TMP_Text)__instance.weightCounter).fontSize; float fontSize2 = ((SimpleHUDPlugin.CfgFontSize > 0f) ? SimpleHUDPlugin.CfgFontSize : fontSize); Vector3 localPosition = default(Vector3); ((Vector3)(ref localPosition))..ctor(-20f, -30f, 0f); Transform val2 = val.Find("MyCustomHUDText"); if ((Object)(object)val2 != (Object)null) { localPosition = val2.localPosition; ManualLogSource log = SimpleHUDPlugin.Log; Vector3 val3 = localPosition; log.LogInfo((object)("SimpleHUD: aligned to InfectionHUD text at local " + ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString())); } else { SimpleHUDPlugin.Log.LogInfo((object)"SimpleHUD: InfectionHUD text not found, using default base."); } HealthText = CreateHUDText(val, "SimpleHUDHealthText", localPosition + new Vector3(0f, 0f - LineGap, 0f), ((TMP_Text)__instance.weightCounter).font, fontSize2); StaminaText = CreateHUDText(val, "SimpleHUDStaminaText", localPosition + new Vector3(0f, (0f - LineGap) * 2f, 0f), ((TMP_Text)__instance.weightCounter).font, fontSize2); WeightText = CreateHUDText(val, "SimpleHUDWeightText", localPosition + new Vector3(0f, (0f - LineGap) * 3f, 0f), ((TMP_Text)__instance.weightCounter).font, fontSize2); float num = (((Object)(object)val2 != (Object)null) ? LineGap : 0f); BatteryText = CreateHUDText(val, "SimpleHUDBatteryText", localPosition + new Vector3(0f, num, 0f), ((TMP_Text)__instance.weightCounter).font, fontSize2); OxygenText = CreateHUDText(val, "SimpleHUDOxygenText", localPosition + new Vector3(0f, (0f - LineGap) * 4f, 0f), ((TMP_Text)__instance.weightCounter).font, fontSize2); FearText = CreateHUDText(val, "SimpleHUDFearText", localPosition + new Vector3(0f, (0f - LineGap) * 5f, 0f), ((TMP_Text)__instance.weightCounter).font, fontSize2); ((TMP_Text)HealthText).transform.SetAsLastSibling(); ((TMP_Text)StaminaText).transform.SetAsLastSibling(); ((TMP_Text)WeightText).transform.SetAsLastSibling(); ((TMP_Text)BatteryText).transform.SetAsLastSibling(); ((TMP_Text)OxygenText).transform.SetAsLastSibling(); ((TMP_Text)FearText).transform.SetAsLastSibling(); ApplyStaticRowColors(); SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD: HealthText localPos=" + ((object)((Transform)((TMP_Text)HealthText).rectTransform).localPosition/*cast due to .constrained prefix*/).ToString() + " StaminaText localPos=" + ((object)((Transform)((TMP_Text)StaminaText).rectTransform).localPosition/*cast due to .constrained prefix*/).ToString() + " WeightText localPos=" + ((object)((Transform)((TMP_Text)WeightText).rectTransform).localPosition/*cast due to .constrained prefix*/).ToString() + " BatteryText localPos=" + ((object)((Transform)((TMP_Text)BatteryText).rectTransform).localPosition/*cast due to .constrained prefix*/).ToString() + " OxygenText localPos=" + ((object)((Transform)((TMP_Text)OxygenText).rectTransform).localPosition/*cast due to .constrained prefix*/).ToString() + " FearText localPos=" + ((object)((Transform)((TMP_Text)FearText).rectTransform).localPosition/*cast due to .constrained prefix*/).ToString() + " parent=" + ((Object)val).name + " fontSize=" + fontSize2 + " weightParentLocalScale=" + ((object)weightParent.localScale/*cast due to .constrained prefix*/).ToString() + " healthActive=" + ((Component)HealthText).gameObject.activeInHierarchy)); SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD: weightParent=" + ((Object)weightParent).name + " batteryParent=" + (((Object)(object)OriginalBatteryParent != (Object)null) ? ((Object)OriginalBatteryParent).name : "null") + " batteryOnWeightChain=" + ((Object)(object)OriginalBatteryParent != (Object)null && IsWeightParentChain(OriginalBatteryParent)) + " staminaParent=" + (((Object)(object)OriginalStaminaParent != (Object)null) ? ((Object)OriginalStaminaParent).name : "null") + " staminaOnWeightChain=" + ((Object)(object)OriginalStaminaParent != (Object)null && IsWeightParentChain(OriginalStaminaParent)))); ApplyPositionOffset(); ApplyVanillaVisibility(); ApplyVanillaWeightVisibility(); DisableVanillaWeightPunchAnimator(__instance); } private static void DisableVanillaWeightPunchAnimator(HUDManager __instance) { if ((Object)(object)__instance.weightCounterAnimator == (Object)null) { SimpleHUDPlugin.Log.LogWarning((object)"SimpleHUD: weightCounterAnimator is null, nothing to disable."); return; } SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD: weightCounterAnimator on '" + ((Object)((Component)__instance.weightCounterAnimator).gameObject).name + "' (enabled=" + ((Behaviour)__instance.weightCounterAnimator).enabled + ", onWeightParent=" + ((Object)(object)((Component)__instance.weightCounterAnimator).transform == (Object)(object)weightParent) + ")")); if (((Behaviour)__instance.weightCounterAnimator).enabled) { ((Behaviour)__instance.weightCounterAnimator).enabled = false; SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD: disabled vanilla weight punch animator on '" + ((Object)((Component)__instance.weightCounterAnimator).gameObject).name + "' to keep HUD numbers stable.")); } } private static void ApplyPositionOffset() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_0126: Unknown result type (might be due to invalid IL or missing references) float num = ((SimpleHUDPlugin.PosOffsetX != null) ? SimpleHUDPlugin.PosOffsetX.Value : 0f); float num2 = ((SimpleHUDPlugin.PosOffsetY != null) ? SimpleHUDPlugin.PosOffsetY.Value : 0f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num, num2, 0f); if ((Object)(object)HealthText != (Object)null) { RectTransform rectTransform = ((TMP_Text)HealthText).rectTransform; ((Transform)rectTransform).localPosition = ((Transform)rectTransform).localPosition + val; } if ((Object)(object)StaminaText != (Object)null) { RectTransform rectTransform2 = ((TMP_Text)StaminaText).rectTransform; ((Transform)rectTransform2).localPosition = ((Transform)rectTransform2).localPosition + val; } if ((Object)(object)WeightText != (Object)null) { RectTransform rectTransform3 = ((TMP_Text)WeightText).rectTransform; ((Transform)rectTransform3).localPosition = ((Transform)rectTransform3).localPosition + val; } if ((Object)(object)BatteryText != (Object)null) { RectTransform rectTransform4 = ((TMP_Text)BatteryText).rectTransform; ((Transform)rectTransform4).localPosition = ((Transform)rectTransform4).localPosition + val; } if ((Object)(object)OxygenText != (Object)null) { RectTransform rectTransform5 = ((TMP_Text)OxygenText).rectTransform; ((Transform)rectTransform5).localPosition = ((Transform)rectTransform5).localPosition + val; } if ((Object)(object)FearText != (Object)null) { RectTransform rectTransform6 = ((TMP_Text)FearText).rectTransform; ((Transform)rectTransform6).localPosition = ((Transform)rectTransform6).localPosition + val; } } private static TextMeshProUGUI CreateHUDText(Transform parent, string name, Vector3 localPos, TMP_FontAsset font, float fontSize) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).font = font; ((TMP_Text)obj).fontSize = fontSize; ((Graphic)obj).color = Color.white; ((TMP_Text)obj).alignment = (TextAlignmentOptions)257; ((TMP_Text)obj).text = ""; ((Graphic)obj).raycastTarget = false; ((TMP_Text)obj).enableWordWrapping = false; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).rectTransform.sizeDelta = new Vector2(300f, 60f); ((Transform)((TMP_Text)obj).rectTransform).localPosition = localPos; return obj; } public static void ApplyVanillaVisibility() { if (!((Object)(object)SimpleHUDPlugin.Instance == (Object)null)) { ApplyVanillaElementVisibility(); bool flag = !SimpleHUDPlugin.CfgHideSimpleHUD || SimpleHUDPlugin.CfgEnvironmentSimulation; if ((Object)(object)HealthText != (Object)null) { ((Component)HealthText).gameObject.SetActive(flag && !SimpleHUDPlugin.CfgHideHealth); } if ((Object)(object)StaminaText != (Object)null) { ((Component)StaminaText).gameObject.SetActive(flag && !SimpleHUDPlugin.CfgHideStamina); } if ((Object)(object)WeightText != (Object)null) { ((Component)WeightText).gameObject.SetActive(flag && !SimpleHUDPlugin.CfgHideWeight); } if ((Object)(object)BatteryText != (Object)null) { ((Component)BatteryText).gameObject.SetActive(flag && !SimpleHUDPlugin.CfgHideBattery); } if ((Object)(object)OxygenText != (Object)null) { ((Component)OxygenText).gameObject.SetActive(flag && !SimpleHUDPlugin.CfgHideOxygen); } if ((Object)(object)FearText != (Object)null) { ((Component)FearText).gameObject.SetActive(flag && !SimpleHUDPlugin.CfgHideFear); } } } internal static void ApplyStaticRowColors() { //IL_0012: 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) if ((Object)(object)WeightText != (Object)null) { ((Graphic)WeightText).color = SimpleHUDPlugin.CfgWeightColor; } if ((Object)(object)BatteryText != (Object)null) { ((Graphic)BatteryText).color = SimpleHUDPlugin.CfgBatteryColor; } } private static bool GetHideVanillaElement(string elementName) { if (!SimpleHUDPlugin.CfgHideVanillaHUD) { return false; } switch (elementName) { case "Self": return SimpleHUDPlugin.CfgHideVanillaHealthBar; case "SprintMeter": return SimpleHUDPlugin.CfgHideVanillaStaminaBar; case "Batteries": case "BatteriesOff": return SimpleHUDPlugin.CfgHideVanillaBatteries; default: return false; } } private static void ApplyVanillaElementVisibility() { if ((Object)(object)OriginalPlayerInfoCanvasGroup == (Object)null || (Object)(object)weightParent == (Object)null) { return; } Transform transform = ((Component)OriginalPlayerInfoCanvasGroup).transform; for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if ((Object)(object)child == (Object)(object)weightParent || weightParent.IsChildOf(child)) { continue; } if (!VanillaHideWhitelist.Contains(((Object)child).name)) { if (loggedKeptNames.Add(((Object)child).name)) { SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD: kept non-vanilla element " + ((Object)child).name)); } continue; } GameObject gameObject = ((Component)child).gameObject; if (GetHideVanillaElement(((Object)child).name)) { if (gameObject.activeSelf && !hiddenVanillaObjects.Contains(gameObject)) { hiddenVanillaObjects.Add(gameObject); gameObject.SetActive(false); SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD: hid vanilla element " + ((Object)child).name)); } } else if (hiddenVanillaObjects.Remove(gameObject)) { gameObject.SetActive(true); SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD: restored vanilla element " + ((Object)child).name)); } } } public static void ApplyVanillaWeightVisibility() { if (!((Object)(object)VanillaWeightCounter == (Object)null)) { bool cfgHideSimpleHUD = SimpleHUDPlugin.CfgHideSimpleHUD; bool flag = !SimpleHUDPlugin.CfgHideVanillaHUD || !SimpleHUDPlugin.CfgHideVanillaWeight || cfgHideSimpleHUD; if (((Component)VanillaWeightCounter).gameObject.activeSelf != flag) { ((Component)VanillaWeightCounter).gameObject.SetActive(flag); } } } private static bool IsWeightParentChain(Transform target) { if ((Object)(object)weightParent == (Object)null || (Object)(object)target == (Object)null) { return false; } if (!((Object)(object)target == (Object)(object)weightParent)) { return weightParent.IsChildOf(target); } return true; } } [HarmonyPatch(typeof(HUDManager), "UpdateHealthUI")] internal static class UpdateHealthUIPatch { [HarmonyPostfix] private static void Postfix(HUDManager __instance) { if (SimpleHUDPlugin.CfgHideVanillaHUD && SimpleHUDPlugin.CfgHideVanillaHealthBar && (Object)(object)HUDPatches.OriginalSelfRedCanvasGroup != (Object)null) { HUDPatches.OriginalSelfRedCanvasGroup.alpha = 0f; } } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class PlayerPatches { private static bool wasDead; private static bool loggedLateUpdate; private static bool loggedTextSet; private static int lastHealth = -1; private static int lastStaminaPct = -1; private static string lastWeightText; private static int lastBatteryPct = -1; private static int lastOxygenPct = -1; private static int lastFearPct = -1; private static int infectionCheckFrames; private static bool infectionAligned; private static TextMeshProUGUI cachedInfectionText; private static float lastHealthAlpha = -1f; private static float lastStaminaAlpha = -1f; private static float lastWeightAlpha = -1f; private static float lastBatteryAlpha = -1f; private static float lastOxygenAlpha = -1f; private static float lastFearAlpha = -1f; private static Color[] staminaColorTable; private static bool hideFlagsInitialized; private static bool lastHideVanillaHUD; private static bool lastHideSimpleHUD; private static bool lastHideHealthBar; private static bool lastHideStaminaBar; private static bool lastHideBatteries; private static float healthFullSince = -1f; private static float staminaFullSince = -1f; private const float FullFadeSeconds = 5f; public static void ResetInfectionAlignment() { infectionAligned = false; cachedInfectionText = null; } private static void TryAlignInfectionHud() { //IL_0064: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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) if (infectionAligned) { return; } try { TextMeshProUGUI infectionText = Patches.InfectionText; if (!((Object)(object)infectionText == (Object)null) && !((Object)(object)HUDPatches.OxygenText == (Object)null)) { Transform val = (((Object)(object)HUDPatches.FearText != (Object)null) ? ((TMP_Text)HUDPatches.FearText).transform : ((TMP_Text)HUDPatches.OxygenText).transform); RectTransform component = ((Component)val).GetComponent<RectTransform>(); TextMeshProUGUI component2 = ((Component)val).GetComponent<TextMeshProUGUI>(); RectTransform rectTransform = ((TMP_Text)infectionText).rectTransform; rectTransform.pivot = component.pivot; rectTransform.sizeDelta = component.sizeDelta; ((TMP_Text)infectionText).alignment = ((TMP_Text)component2).alignment; ((Transform)rectTransform).localPosition = ((Transform)component).localPosition + new Vector3(0f, 0f - HUDPatches.LineGap, 0f); ((TMP_Text)infectionText).transform.SetAsLastSibling(); if (!SimpleHUDPlugin.CfgHideInfection) { SetActiveIfInactive(infectionText); } SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD: aligned InfectionHUD text below " + ((Object)val).name + " at " + ((object)((Transform)((TMP_Text)infectionText).rectTransform).localPosition/*cast due to .constrained prefix*/).ToString())); cachedInfectionText = infectionText; infectionAligned = true; } } catch (Exception ex) { SimpleHUDPlugin.Log.LogWarning((object)("SimpleHUD: failed to align InfectionHUD text: " + ex)); } } [HarmonyPrefix] [HarmonyPatch("LateUpdate")] private static void LateUpdate_Prefix(PlayerControllerB __instance) { //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_0747: Unknown result type (might be due to invalid IL or missing references) //IL_074c: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) if (++infectionCheckFrames >= 120) { infectionCheckFrames = 0; TryAlignInfectionHud(); } if ((Object)(object)cachedInfectionText != (Object)null) { if (!SimpleHUDPlugin.CfgHideInfection) { SetActiveIfInactive(cachedInfectionText); if (((TMP_Text)cachedInfectionText).text.Length == 0) { ((TMP_Text)cachedInfectionText).text = "0% infected"; } } else { SetInactiveIfActive(cachedInfectionText); } } if (!loggedLateUpdate) { loggedLateUpdate = true; SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD LateUpdate fired: IsOwner=" + ((NetworkBehaviour)__instance).IsOwner + " IsServer=" + ((NetworkBehaviour)__instance).IsServer + " isHostPlayerObject=" + __instance.isHostPlayerObject + " health=" + __instance.health + " sprintMeter=" + __instance.sprintMeter + " dead=" + __instance.isPlayerDead)); } if (!((NetworkBehaviour)__instance).IsOwner || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) { return; } bool num = (Object)(object)__instance.sprintMeterUI != (Object)null && (Object)(object)((Component)__instance.sprintMeterUI).transform.parent != (Object)null && (Object)(object)HUDPatches.OriginalStaminaParent != (Object)(object)((Component)__instance.sprintMeterUI).transform.parent; bool cfgHideVanillaHUD = SimpleHUDPlugin.CfgHideVanillaHUD; bool cfgHideSimpleHUD = SimpleHUDPlugin.CfgHideSimpleHUD; bool cfgHideVanillaHealthBar = SimpleHUDPlugin.CfgHideVanillaHealthBar; bool cfgHideVanillaStaminaBar = SimpleHUDPlugin.CfgHideVanillaStaminaBar; bool cfgHideVanillaBatteries = SimpleHUDPlugin.CfgHideVanillaBatteries; bool flag = !hideFlagsInitialized || cfgHideVanillaHUD != lastHideVanillaHUD || cfgHideSimpleHUD != lastHideSimpleHUD || cfgHideVanillaHealthBar != lastHideHealthBar || cfgHideVanillaStaminaBar != lastHideStaminaBar || cfgHideVanillaBatteries != lastHideBatteries; if (num) { HUDPatches.OriginalStaminaParent = ((Component)__instance.sprintMeterUI).transform.parent; SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD: staminaParent assigned=" + ((Object)HUDPatches.OriginalStaminaParent).name)); } if (num || flag) { hideFlagsInitialized = true; lastHideVanillaHUD = cfgHideVanillaHUD; lastHideSimpleHUD = cfgHideSimpleHUD; lastHideHealthBar = cfgHideVanillaHealthBar; lastHideStaminaBar = cfgHideVanillaStaminaBar; lastHideBatteries = cfgHideVanillaBatteries; HUDPatches.ApplyVanillaVisibility(); } if ((Object)(object)HUDPatches.HealthText == (Object)null || (Object)(object)HUDPatches.StaminaText == (Object)null || (Object)(object)HUDPatches.WeightText == (Object)null || (Object)(object)HUDPatches.BatteryText == (Object)null || (Object)(object)HUDPatches.OxygenText == (Object)null || (Object)(object)HUDPatches.FearText == (Object)null) { return; } int num2 = Mathf.Clamp(__instance.health, 0, 100); int num3 = Mathf.FloorToInt(Mathf.Clamp01(__instance.sprintMeter) * 100f); string text = (((Object)(object)HUDPatches.VanillaWeightCounter != (Object)null) ? ((TMP_Text)HUDPatches.VanillaWeightCounter).text : null); string text2 = (string.IsNullOrEmpty(text) ? "0 lb" : text); if (text2 != lastWeightText) { lastWeightText = text2; ((TMP_Text)HUDPatches.WeightText).text = text2; } bool isPlayerDead = __instance.isPlayerDead; bool cfgEnvironmentSimulation = SimpleHUDPlugin.CfgEnvironmentSimulation; if (isPlayerDead != wasDead) { wasDead = isPlayerDead; if (!cfgEnvironmentSimulation) { SetRowActive(!isPlayerDead && !SimpleHUDPlugin.CfgHideHealth, HUDPatches.HealthText); SetRowActive(!isPlayerDead && !SimpleHUDPlugin.CfgHideStamina, HUDPatches.StaminaText); SetRowActive(!isPlayerDead && !SimpleHUDPlugin.CfgHideWeight, HUDPatches.WeightText); SetRowActive(!isPlayerDead && !SimpleHUDPlugin.CfgHideBattery, HUDPatches.BatteryText); SetRowActive(!isPlayerDead && !SimpleHUDPlugin.CfgHideOxygen, HUDPatches.OxygenText); SetRowActive(!isPlayerDead && !SimpleHUDPlugin.CfgHideFear, HUDPatches.FearText); } if (isPlayerDead) { healthFullSince = -1f; staminaFullSince = -1f; } } if (isPlayerDead) { if (!cfgEnvironmentSimulation) { SetInactiveIfActive(HUDPatches.HealthText); SetInactiveIfActive(HUDPatches.StaminaText); SetInactiveIfActive(HUDPatches.WeightText); SetInactiveIfActive(HUDPatches.BatteryText); SetInactiveIfActive(HUDPatches.OxygenText); SetInactiveIfActive(HUDPatches.FearText); return; } SetRowActive(!SimpleHUDPlugin.CfgHideHealth, HUDPatches.HealthText); SetRowActive(!SimpleHUDPlugin.CfgHideStamina, HUDPatches.StaminaText); SetRowActive(!SimpleHUDPlugin.CfgHideWeight, HUDPatches.WeightText); SetRowActive(!SimpleHUDPlugin.CfgHideOxygen, HUDPatches.OxygenText); SetRowActive(!SimpleHUDPlugin.CfgHideFear, HUDPatches.FearText); } if (num2 != lastHealth) { lastHealth = num2; ((TMP_Text)HUDPatches.HealthText).text = num2 + " HP"; ((Graphic)HUDPatches.HealthText).color = Color.Lerp(SimpleHUDPlugin.CfgHealthColorLow, SimpleHUDPlugin.CfgHealthColorFull, (float)num2 / 100f); lastHealthAlpha = 1f; } if (num3 != lastStaminaPct) { lastStaminaPct = num3; ((TMP_Text)HUDPatches.StaminaText).text = num3 + "% SP"; ((Graphic)HUDPatches.StaminaText).color = GetStaminaColor(__instance.sprintMeter); lastStaminaAlpha = 1f; } bool flag2 = __instance.isHoldingObject && (Object)(object)__instance.currentlyHeldObjectServer != (Object)null && __instance.currentlyHeldObjectServer.itemProperties.requiresBattery && __instance.currentlyHeldObjectServer.insertedBattery != null; int num4 = -1; if (flag2) { num4 = Mathf.RoundToInt(Mathf.Clamp01(__instance.currentlyHeldObjectServer.insertedBattery.charge) * 100f); if (num4 != lastBatteryPct) { lastBatteryPct = num4; ((TMP_Text)HUDPatches.BatteryText).text = num4 + "%"; } } else if (lastBatteryPct != -1) { lastBatteryPct = -1; } float num5 = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.drowningTimer : 0f); int num6 = Mathf.RoundToInt((1f - Mathf.Clamp01(num5)) * 100f); if (num6 != lastOxygenPct) { lastOxygenPct = num6; ((TMP_Text)HUDPatches.OxygenText).text = num6 + " O2"; ((Graphic)HUDPatches.OxygenText).color = ((num6 <= 30) ? SimpleHUDPlugin.CfgOxygenLowColor : SimpleHUDPlugin.CfgOxygenColor); lastOxygenAlpha = 1f; } int num7 = Mathf.RoundToInt(Mathf.Clamp01(((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.fearLevel : 0f) * 100f); if (num7 != lastFearPct) { lastFearPct = num7; ((TMP_Text)HUDPatches.FearText).text = num7 + " Fear"; ((Graphic)HUDPatches.FearText).color = ((num7 >= 60) ? SimpleHUDPlugin.CfgFearHighColor : SimpleHUDPlugin.CfgFearColor); lastFearAlpha = 1f; } UpdateNumberVisibility(num2, num3, flag2, num6); if (!loggedTextSet) { loggedTextSet = true; SimpleHUDPlugin.Log.LogInfo((object)("SimpleHUD text set: healthText='" + ((TMP_Text)HUDPatches.HealthText).text + "' staminaText='" + ((TMP_Text)HUDPatches.StaminaText).text + "' healthActive=" + ((Component)HUDPatches.HealthText).gameObject.activeInHierarchy + " healthColor=" + ((object)((Graphic)HUDPatches.HealthText).color/*cast due to .constrained prefix*/).ToString() + " fontSize=" + ((TMP_Text)HUDPatches.HealthText).fontSize)); } } private static void UpdateNumberVisibility(int health, int staminaPct, bool holdingBatteryItem, int oxygenPct) { bool cfgHideSimpleHUD = SimpleHUDPlugin.CfgHideSimpleHUD; bool cfgAlwaysShowNumbers = SimpleHUDPlugin.CfgAlwaysShowNumbers; if (cfgHideSimpleHUD && !SimpleHUDPlugin.CfgEnvironmentSimulation) { SetInactiveIfActive(HUDPatches.HealthText); SetInactiveIfActive(HUDPatches.StaminaText); SetInactiveIfActive(HUDPatches.WeightText); SetInactiveIfActive(HUDPatches.BatteryText); SetInactiveIfActive(HUDPatches.OxygenText); SetInactiveIfActive(HUDPatches.FearText); healthFullSince = -1f; staminaFullSince = -1f; HUDPatches.ApplyVanillaWeightVisibility(); return; } SetRowActive(!SimpleHUDPlugin.CfgHideHealth, HUDPatches.HealthText); SetRowActive(!SimpleHUDPlugin.CfgHideStamina, HUDPatches.StaminaText); SetRowActive(!SimpleHUDPlugin.CfgHideWeight, HUDPatches.WeightText); SetRowActive(!SimpleHUDPlugin.CfgHideFear, HUDPatches.FearText); if (holdingBatteryItem) { SetRowActive(!SimpleHUDPlugin.CfgHideBattery, HUDPatches.BatteryText); } else { SetInactiveIfActive(HUDPatches.BatteryText); } if (!SimpleHUDPlugin.CfgHideOxygen && (SimpleHUDPlugin.CfgEnvironmentSimulation || (!SimpleHUDPlugin.CfgShowOxygenOnlyInWater && !SimpleHUDPlugin.GetOxygenDisplayOnlyInWater()) || ((Object)(object)HUDManager.Instance != (Object)null && HUDManager.Instance.setUnderwaterFilter))) { SetActiveIfInactive(HUDPatches.OxygenText); } else { SetInactiveIfActive(HUDPatches.OxygenText); } SetTextAlphaCached(HUDPatches.WeightText, 1f, ref lastWeightAlpha); SetTextAlphaCached(HUDPatches.BatteryText, 1f, ref lastBatteryAlpha); SetTextAlphaCached(HUDPatches.OxygenText, 1f, ref lastOxygenAlpha); SetTextAlphaCached(HUDPatches.FearText, 1f, ref lastFearAlpha); HUDPatches.ApplyVanillaWeightVisibility(); if (cfgAlwaysShowNumbers || SimpleHUDPlugin.CfgEnvironmentSimulation) { healthFullSince = -1f; staminaFullSince = -1f; SetTextAlphaCached(HUDPatches.HealthText, 1f, ref lastHealthAlpha); SetTextAlphaCached(HUDPatches.StaminaText, 1f, ref lastStaminaAlpha); SetTextAlphaCached(HUDPatches.WeightText, 1f, ref lastWeightAlpha); SetTextAlphaCached(HUDPatches.BatteryText, 1f, ref lastBatteryAlpha); } else { float unscaledTime = Time.unscaledTime; UpdateFullValueFade(health, 100, ref healthFullSince, HUDPatches.HealthText, unscaledTime, ref lastHealthAlpha); UpdateFullValueFade(staminaPct, 100, ref staminaFullSince, HUDPatches.StaminaText, unscaledTime, ref lastStaminaAlpha); } } private static void SetInactiveIfActive(TextMeshProUGUI text) { if ((Object)(object)text != (Object)null && ((Component)text).gameObject.activeSelf) { ((Component)text).gameObject.SetActive(false); } } private static void SetActiveIfInactive(TextMeshProUGUI text) { if ((Object)(object)text != (Object)null && !((Component)text).gameObject.activeSelf) { ((Component)text).gameObject.SetActive(true); } } private static void SetRowActive(bool show, TextMeshProUGUI text) { if (show) { SetActiveIfInactive(text); } else { SetInactiveIfActive(text); } } private static void UpdateFullValueFade(int value, int fullValue, ref float fullSince, TextMeshProUGUI text, float now, ref float lastAlpha) { if ((Object)(object)text == (Object)null) { fullSince = -1f; lastAlpha = 1f; return; } if (value < fullValue) { fullSince = -1f; SetTextAlphaCached(text, 1f, ref lastAlpha); return; } if (fullSince < 0f) { fullSince = now; } float num = (now - fullSince) / 5f; SetTextAlphaCached(text, Mathf.Clamp01(1f - num), ref lastAlpha); } private static void SetTextAlphaCached(TextMeshProUGUI text, float alpha, ref float lastAlpha) { //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_0023: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Abs(lastAlpha - alpha) > 0.001f) { lastAlpha = alpha; Color color = ((Graphic)text).color; color.a = alpha; ((Graphic)text).color = color; } } internal static void ResetAlphaCaches() { lastHealthAlpha = -1f; lastStaminaAlpha = -1f; lastWeightAlpha = -1f; lastBatteryAlpha = -1f; lastOxygenAlpha = -1f; lastFearAlpha = -1f; healthFullSince = -1f; staminaFullSince = -1f; } internal static void ResetValueCaches() { lastHealth = -1; lastStaminaPct = -1; lastWeightText = null; lastBatteryPct = -1; lastOxygenPct = -1; lastFearPct = -1; ResetAlphaCaches(); } internal static void RebuildStaminaColorTable() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); ((Color)(ref val))..ctor(SimpleHUDPlugin.CfgStaminaColorR, SimpleHUDPlugin.CfgStaminaColorG, SimpleHUDPlugin.CfgStaminaColorB, 1f); Color[] array = (Color[])(object)new Color[5] { Color.black, default(Color), default(Color), default(Color), default(Color) }; for (int i = 1; i <= 4; i++) { float num = (float)i / 4f; array[i] = Color.Lerp(new Color(0.6f, 0.6f, 0.6f, 1f), val, num); } staminaColorTable = array; } private static Color GetStaminaColor(float stamina) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.FloorToInt(Mathf.Clamp01(stamina) * 5f); if (num >= 5) { num = 4; } if (num <= 0) { num = 0; } Color[] array = staminaColorTable; if (array == null) { return Color.black; } return array[num]; } }