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 AccurateStaminaDisplay v2.2.1
AccurateStaminaDisplay.dll
Decompiled a year agousing System; using System.Diagnostics; using System.IO; 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 GameNetcodeStuff; using HarmonyLib; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using Microsoft.CodeAnalysis; 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("AccurateStaminaDisplay")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Fixes the stamina meter display on the HUD, so it more accurately represents your current stamina percentage.")] [assembly: AssemblyFileVersion("2.2.1.0")] [assembly: AssemblyInformationalVersion("2.2.1+d2c756ff1e57c52dbcd0ec4b2a3f6d5b449abe15")] [assembly: AssemblyProduct("AccurateStaminaDisplay")] [assembly: AssemblyTitle("AccurateStaminaDisplay")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.2.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AccurateStaminaDisplay { internal static class LobbyCompatibility { internal static void Init() { PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.accuratestaminadisplay", Version.Parse("2.2.1"), (CompatibilityLevel)0, (VersionStrictness)0); } } internal static class NewStaminaMeter { private const float STAMINA_EMPTY = 0.1f; private const float STAMINA_EXHAUSTED = 0.3f; private const float METER_EMPTY = 0.29767f; private const float METER_FULL = 0.911f; private static readonly Color NORM_COLOR = new Color(1f, 0.4626f, 0f); private static readonly Color EX_COLOR = new Color(0.9f, 0.1f, 0f); private static PlayerControllerB player; private static float minStamina; private static bool exhausted; private static Image meterOverlay; private static readonly float OVERLAY_MAX = Mathf.Lerp(0.29767f, 0.911f, Mathf.InverseLerp(0.1f, 1f, 0.3f)); private static Gradient tzpGrad; private static readonly Color LIME = new Color(0.4f, 1f, 0f); private const float TZP_LIGHT_MIN = 0.1f; private const float TZP_LIGHT_MAX = 0.2f; private const float TZP_HEAVY_MIN = 0.65f; private const float TZP_HEAVY_MAX = 0.77f; private static CanvasRenderer meterAlpha; private static CanvasRenderer overlayAlpha; private static bool wasClimbing; private static Sprite origMeterImg; internal static Sprite altMeterImg; internal static void UpdateMeter(int playerMovementHinderedPrev) { //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { Init(); return; } minStamina = ((Plugin.configExhaustionIndicator.Value == ExhaustionIndicator.Empty) ? 0.3f : 0.1f); if ((Object)(object)origMeterImg != (Object)null) { if ((Object)(object)player.sprintMeterUI.sprite == (Object)(object)origMeterImg && minStamina == 0.1f && (Object)(object)altMeterImg != (Object)null) { player.sprintMeterUI.sprite = altMeterImg; } else if ((Object)(object)player.sprintMeterUI.sprite == (Object)(object)altMeterImg && minStamina == 0.3f) { player.sprintMeterUI.sprite = origMeterImg; } } float num = Mathf.InverseLerp(minStamina, 1f, player.sprintMeter); player.sprintMeterUI.fillAmount = Mathf.Lerp(0.29767f, 0.911f, num); if (player.isClimbingLadder) { wasClimbing = true; } else if (player.thisController.isGrounded) { wasClimbing = false; } bool flag = playerMovementHinderedPrev > 0 && !wasClimbing && !player.jetpackControls; bool flag2 = Plugin.configInhalantInfo.Value && player.drunkness > 0f && tzpGrad != null; bool flag3 = Plugin.configExhaustionIndicator.Value == ExhaustionIndicator.ChangeColor || (Plugin.configExhaustionIndicator.Value == ExhaustionIndicator.AlwaysShow && (flag || flag2)); if (exhausted) { if (!flag3 || player.isSprinting || (player.sprintMeter >= 0.3f && !flag)) { exhausted = false; } } else if (flag3 && (player.isExhausted || flag || (!player.isSprinting && player.sprintMeter < 0.3f))) { exhausted = true; ((Graphic)player.sprintMeterUI).color = EX_COLOR; } else if (flag2) { ((Graphic)player.sprintMeterUI).color = tzpGrad.Evaluate(player.drunkness); } else { ((Graphic)player.sprintMeterUI).color = NORM_COLOR; } if (!((Object)(object)meterOverlay != (Object)null)) { return; } if (Plugin.configExhaustionIndicator.Value == ExhaustionIndicator.AlwaysShow && !exhausted && !player.criticallyInjured && !flag2) { meterOverlay.fillAmount = Mathf.Min(player.sprintMeterUI.fillAmount, OVERLAY_MAX); if ((Object)(object)overlayAlpha != (Object)null) { overlayAlpha.SetAlpha(meterAlpha.GetAlpha()); } ((Behaviour)meterOverlay).enabled = ((Behaviour)player.sprintMeterUI).enabled; ((Component)meterOverlay).gameObject.SetActive(true); } else { ((Component)meterOverlay).gameObject.SetActive(false); } } private static void Init() { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_010c: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_014e: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) player = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)player != (Object)null) { if ((Object)(object)meterOverlay == (Object)null) { meterOverlay = ((Component)Object.Instantiate<Transform>(((Component)player.sprintMeterUI).transform, ((Component)player.sprintMeterUI).transform.parent)).GetComponent<Image>(); ((Graphic)meterOverlay).color = EX_COLOR; if ((Object)(object)altMeterImg != (Object)null) { meterOverlay.sprite = altMeterImg; } } if (Chainloader.PluginInfos.ContainsKey("ShyHUD") && (Object)(object)meterOverlay != (Object)null) { meterAlpha = ((Component)player.sprintMeterUI).GetComponent<CanvasRenderer>(); overlayAlpha = ((Component)meterOverlay).GetComponent<CanvasRenderer>(); } if ((Object)(object)origMeterImg == (Object)null) { origMeterImg = player.sprintMeterUI.sprite; } } if (tzpGrad == null) { tzpGrad = new Gradient(); tzpGrad.SetKeys((GradientColorKey[])(object)new GradientColorKey[6] { new GradientColorKey(NORM_COLOR, 0f), new GradientColorKey(Color.yellow, 0.1f), new GradientColorKey(Color.yellow, 0.2f), new GradientColorKey(LIME, 0.65f), new GradientColorKey(LIME, 0.77f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 1f) }); } } } internal enum ExhaustionIndicator { Empty, ChangeColor, AlwaysShow, DontShow } [BepInPlugin("butterystancakes.lethalcompany.accuratestaminadisplay", "Accurate Stamina Display", "2.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal const string PLUGIN_GUID = "butterystancakes.lethalcompany.accuratestaminadisplay"; internal const string PLUGIN_NAME = "Accurate Stamina Display"; internal const string PLUGIN_VERSION = "2.2.1"; internal static ConfigEntry<bool> configInhalantInfo; internal static ConfigEntry<ExhaustionIndicator> configExhaustionIndicator; private const string GUID_SHY_HUD = "ShyHUD"; private const string GUID_LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility"; private void Awake() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility")) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected"); LobbyCompatibility.Init(); } LoadConfig(); try { AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "accuratestaminadisplay")); NewStaminaMeter.altMeterImg = obj.LoadAsset<Sprite>("SprintMeter"); obj.Unload(false); } catch { ((BaseUnityPlugin)this).Logger.LogError((object)"Encountered some error loading asset bundle. Did you install the plugin correctly?"); return; } new Harmony("butterystancakes.lethalcompany.accuratestaminadisplay").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Accurate Stamina Display v2.2.1 loaded"); } private void LoadConfig() { configInhalantInfo = ((BaseUnityPlugin)this).Config.Bind<bool>("Extra", "InhalantInfo", false, "Adjusts the color of the stamina meter to reflect the amount of TZP inhaled. (Light = yellow, heavy = green, \"overdose\" = white)"); configExhaustionIndicator = ((BaseUnityPlugin)this).Config.Bind<ExhaustionIndicator>("Misc", "ExhaustionIndicator", ExhaustionIndicator.AlwaysShow, "How the stamina meter displays exhaustion. You become exhausted when stamina hits 0% or if you release the sprint key while stamina is 20% or lower.\n\n\"Empty\" will make the stamina bar display as empty for the last 20% of stamina, just like the original game.\n\"ChangeColor\" will turn the bar red when you are currently exhausted.\n\"AlwaysShow\" will always display the last 20% of the bar as red.\n\"DontShow\" will not display any special indicator for exhaustion."); if (configExhaustionIndicator.Value != ExhaustionIndicator.AlwaysShow) { return; } bool value = ((BaseUnityPlugin)this).Config.Bind<bool>("Extra", "AlwaysShowRedPortion", true, "Legacy setting, use \"ExhaustionIndicator\" instead").Value; bool value2 = ((BaseUnityPlugin)this).Config.Bind<bool>("Extra", "ExhaustedRed", true, "Legacy setting, use \"ExhaustionIndicator\" instead").Value; if (((BaseUnityPlugin)this).Config.Bind<bool>("Miscellaneous", "EmptyEarly", false, "Legacy setting, use \"ExhaustionIndicator\" instead").Value) { configExhaustionIndicator.Value = ExhaustionIndicator.Empty; } else if (value2) { if (value) { configExhaustionIndicator.Value = ExhaustionIndicator.AlwaysShow; } else { configExhaustionIndicator.Value = ExhaustionIndicator.ChangeColor; } } else { configExhaustionIndicator.Value = ExhaustionIndicator.DontShow; } ((BaseUnityPlugin)this).Config.Remove(((BaseUnityPlugin)this).Config["Extra", "AlwaysShowRedPortion"].Definition); ((BaseUnityPlugin)this).Config.Remove(((BaseUnityPlugin)this).Config["Extra", "ExhaustedRed"].Definition); ((BaseUnityPlugin)this).Config.Remove(((BaseUnityPlugin)this).Config["Miscellaneous", "EmptyEarly"].Definition); ((BaseUnityPlugin)this).Config.Save(); } } public static class PluginInfo { public const string PLUGIN_GUID = "AccurateStaminaDisplay"; public const string PLUGIN_NAME = "AccurateStaminaDisplay"; public const string PLUGIN_VERSION = "2.2.1"; } } namespace AccurateStaminaDisplay.Patches { [HarmonyPatch] internal class AccurateStaminaDisplayPatches { [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] [HarmonyPostfix] public static void PlayerPostLateUpdate(int ___movementHinderedPrev) { NewStaminaMeter.UpdateMeter(___movementHinderedPrev); } } }