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 Treys Health Text v1.3.3
TreysHealthText.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TreysHealthText")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Displays Player Health as a Number")] [assembly: AssemblyFileVersion("1.3.3.0")] [assembly: AssemblyInformationalVersion("1.3.3")] [assembly: AssemblyProduct("TreysHealthText")] [assembly: AssemblyTitle("TreysHealthText")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.3.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 HealthText { [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] public static class RoundManager_LoadNewLevel_Patch { private static void Postfix(RoundManager __instance) { } } } namespace TreysHealthText { [HarmonyPatch(typeof(HUDManager), "Awake")] public static class HUDManager_Awake_Patch { private static void Postfix(HUDManager __instance) { Plugin.PluginLogger.LogInfo((object)"HUDManager Patch Ran"); PlayerControllerB val = Object.FindObjectOfType<PlayerControllerB>(); if ((Object)(object)val != (Object)null) { int health = val.health; HUDManager.Instance.UpdateHealthUI(health, Plugin.HideSystemsOnline.Value); Plugin.PluginLogger.LogInfo((object)"UpdatedHealth"); } else { Plugin.PluginLogger.LogError((object)"PlayerControllerB not found."); } } } [HarmonyPatch(typeof(HUDManager), "UpdateHealthUI")] public static class HUDManager_UpdateHealthUI_Patch { public static TextMeshProUGUI healthText; private static void Postfix(HUDManager __instance, int health) { Plugin.PluginLogger.LogInfo((object)"UpdateHealthUI Patch Ran"); if ((Object)(object)healthText == (Object)null) { CreateHealthText(__instance, 100, health); } string value = Plugin.HpTextPosition.Value; bool value2 = Plugin.UnderlineTopLine.Value; UpdateHealthText(health, rainbow: false); } private static void UpdateHealthText(int health, bool rainbow) { string value = Plugin.HpTextPosition.Value; bool value2 = Plugin.UnderlineTopLine.Value; string value3 = Plugin.HPLabelName.Value; if (rainbow) { Plugin.PluginLogger.LogInfo((object)"Updated Text Color"); } string text; string text2; if (value.Equals("Above")) { text = value3; text2 = health.ToString(); } else if (value.Equals("Below")) { text = health.ToString(); text2 = value3; } else if (value.Equals("Right")) { text = health + value3; text2 = ""; } else { text = value3 + health; text2 = ""; } if (value2) { text = "<u>" + text + "</u>"; } ((TMP_Text)healthText).text = text + "\n" + text2; } private static void CreateHealthText(HUDManager hudManager, int initialHealth, int health) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_021f: 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_0124: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/TopLeftCorner"); if ((Object)(object)val == (Object)null) { Plugin.PluginLogger.LogError((object)"'TopLeftCorner' not found."); return; } GameObject val2 = new GameObject("PlayerHealthText"); val2.transform.SetParent(val.transform, false); healthText = val2.AddComponent<TextMeshProUGUI>(); if ((Object)(object)hudManager.weightCounter != (Object)null) { TextMeshProUGUI weightCounter = hudManager.weightCounter; ((TMP_Text)healthText).font = ((TMP_Text)weightCounter).font; ((TMP_Text)healthText).fontSize = ((TMP_Text)weightCounter).fontSize; ((Graphic)healthText).color = ParseColor(Plugin.TextColor.Value); ((TMP_Text)healthText).alignment = (TextAlignmentOptions)514; ((TMP_Text)healthText).enableAutoSizing = ((TMP_Text)weightCounter).enableAutoSizing; ((TMP_Text)healthText).fontSizeMin = ((TMP_Text)weightCounter).fontSizeMin; ((TMP_Text)healthText).fontSizeMax = ((TMP_Text)weightCounter).fontSizeMax; if ((Object)(object)((TMP_Text)weightCounter).fontMaterial != (Object)null) { ((TMP_Text)healthText).fontSharedMaterial = new Material(((TMP_Text)weightCounter).fontMaterial); } if ((Object)(object)((TMP_Text)weightCounter).transform.parent != (Object)null) { RectTransform component = ((Component)((TMP_Text)weightCounter).transform.parent).GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { RectTransform component2 = ((Component)healthText).GetComponent<RectTransform>(); ((Transform)component2).localRotation = ((Transform)component).localRotation; } } } else { ((TMP_Text)healthText).fontSize = 24f; ((Graphic)healthText).color = Color.red; ((TMP_Text)healthText).alignment = (TextAlignmentOptions)514; } RectTransform component3 = val2.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 1f); component3.anchorMax = new Vector2(0f, 1f); component3.pivot = new Vector2(0f, 1f); int value = Plugin.XOffset.Value; int value2 = Plugin.YOffset.Value; component3.anchoredPosition = new Vector2((float)(-53 + value), (float)(-95 + value2)); UpdateHealthText(health, rainbow: false); } private static Color ParseColor(string rgb) { //IL_0026: 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_0082: 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_007e: 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_0075: Unknown result type (might be due to invalid IL or missing references) string[] array = rgb.Split(new string[1] { ", " }, StringSplitOptions.RemoveEmptyEntries); if (array.Length != 3) { return Color.white; } if (float.TryParse(array[0], out var result) && float.TryParse(array[1], out var result2) && float.TryParse(array[2], out var result3)) { return new Color(result / 255f, result2 / 255f, result3 / 255f); } return Color.white; } } [HarmonyPatch(typeof(HUDManager), "Update")] public static class HUDManager_Update_Patch { private static float hue; private static void Postfix(HUDManager __instance) { //IL_0068: 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_006f: 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) if (Plugin.RainbowText.Value) { TextMeshProUGUI healthText = HUDManager_UpdateHealthUI_Patch.healthText; if ((Object)(object)healthText == (Object)null) { Plugin.PluginLogger.LogWarning((object)"healthText is null in Update patch"); return; } hue = (hue + Time.deltaTime * Plugin.RainbowSpeed.Value) % 1f; Color val2 = (((Graphic)healthText).color = Color.HSVToRGB(hue, 1f, 1f)); Plugin.PluginLogger.LogInfo((object)$"Updated color: {val2}"); } } } [BepInPlugin("TreysHealthText", "TreysHealthText", "1.3.3")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource PluginLogger; internal static ConfigEntry<bool> HideSystemsOnline; internal static ConfigEntry<string> HpTextPosition; internal static ConfigEntry<bool> UnderlineTopLine; internal static ConfigEntry<string> HPLabelName; internal static ConfigEntry<string> TextColor; internal static ConfigEntry<int> XOffset; internal static ConfigEntry<int> YOffset; internal static ConfigEntry<bool> RainbowText; internal static ConfigEntry<float> RainbowSpeed; private void Awake() { //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown PluginLogger = ((BaseUnityPlugin)this).Logger; HideSystemsOnline = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HideSystemsOnline", false, "Does Systems Online text pop up when joining lobbies? (Bug turned into a feature :D)"); HpTextPosition = ((BaseUnityPlugin)this).Config.Bind<string>("General", "HpTextPosition", "Right", "Choose to display the 'HP' text above, below, left, or right of the number. Options: Above, Below, Left, Right"); UnderlineTopLine = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UnderlineTopLine", false, "Set to true to underline the top line of the health text. Options: true, false"); HPLabelName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "HPLabelName", "HP", "Set to whatever label you want for the display, leave blank if you don't want a label."); TextColor = ((BaseUnityPlugin)this).Config.Bind<string>("General", "TextColor", "243.015, 100.47, 0", "Color of the text in RGB format (e.g., '255,0,0' for red)."); XOffset = ((BaseUnityPlugin)this).Config.Bind<int>("Position", "XOffset", 0, "Horizontal offset for the health text position."); YOffset = ((BaseUnityPlugin)this).Config.Bind<int>("Position", "YOffset", 0, "Vertical offset for the health text position."); RainbowText = ((BaseUnityPlugin)this).Config.Bind<bool>("Funny", "RainbowText", false, "Set the true if you want a laggy rainbow nightmare. Options: true, false"); RainbowSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Funny", "RainbowSpeed", 0.3f, "Changes speed at which the rainbow color cycles :D (Input as a float)"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TreysHealthText is loaded!"); Harmony val = new Harmony("TreysHealthText"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patches applied."); } } public static class PluginInfo { public const string PLUGIN_GUID = "TreysHealthText"; public const string PLUGIN_NAME = "TreysHealthText"; public const string PLUGIN_VERSION = "1.3.3"; } }