using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; 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: AssemblyTitle("EnemyHealthDisplay")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("EnemyHealthDisplay")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("f8ebc37d-38cb-4b45-ad1c-f37b96ef8349")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("com.zerok.enemyhealthdisplay", "Enemy Health Display", "103.0.0")] public class Class1 : BaseUnityPlugin { private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("com.zerok.enemyhealthdisplay"); val.PatchAll(); } } public class EnemyHealthLabel : MonoBehaviour { public EnemyHealth health; public Enemy enemy; public TMP_FontAsset repoFont; private TextMeshPro textMesh; private Image barBackground; private Image barFill; private int maxHealthCached; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00d8: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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) GameObject val = new GameObject("HP_UI"); val.transform.SetParent(((Component)this).transform); GameObject val2 = new GameObject("HPText"); val2.transform.SetParent(val.transform); textMesh = val2.AddComponent(); ((TMP_Text)textMesh).fontSize = 10f; ((TMP_Text)textMesh).alignment = (TextAlignmentOptions)514; ((Graphic)textMesh).color = new Color(1f, 0.6f, 0.1f); if ((Object)(object)repoFont != (Object)null) { ((TMP_Text)textMesh).font = repoFont; } textMesh.transform.localScale = Vector3.one * 0.15f; GameObject val3 = new GameObject("BarBG"); val3.transform.SetParent(val.transform); barBackground = val3.AddComponent(); ((Graphic)barBackground).color = new Color(0f, 0f, 0f, 0.75f); RectTransform component = val3.GetComponent(); component.sizeDelta = new Vector2(3f, 0.25f); GameObject val4 = new GameObject("BarFill"); val4.transform.SetParent(val3.transform); barFill = val4.AddComponent(); ((Graphic)barFill).color = new Color(1f, 0.55f, 0f); RectTransform component2 = val4.GetComponent(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; } private void LateUpdate() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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) if ((Object)(object)health == (Object)null || (Object)(object)enemy == (Object)null) { return; } Transform centerTransform = enemy.CenterTransform; if (!((Object)(object)centerTransform == (Object)null)) { ((Component)this).transform.position = centerTransform.position + Vector3.up * 1.5f; if ((Object)(object)Camera.main != (Object)null) { ((Component)this).transform.forward = ((Component)Camera.main).transform.forward; } int @int = GetInt("healthCurrent"); int int2 = GetInt("health"); if (maxHealthCached == 0) { maxHealthCached = ((int2 > 0) ? int2 : @int); } ((TMP_Text)textMesh).text = $"{@int} / {maxHealthCached}"; float num = ((maxHealthCached > 0) ? ((float)@int / (float)maxHealthCached) : 0f); ((Component)barFill).transform.localScale = new Vector3(num, 1f, 1f); } } private int GetInt(string field) { FieldInfo field2 = typeof(EnemyHealth).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic); return (field2 != null) ? ((int)field2.GetValue(health)) : 0; } } public class DamagePopup : MonoBehaviour { private TextMeshPro textMesh; private float lifeTime = 1.2f; private Vector3 velocity; public void Setup(int damage) { //IL_0078: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) textMesh = ((Component)this).gameObject.GetComponent(); if ((Object)(object)textMesh == (Object)null) { textMesh = ((Component)this).gameObject.AddComponent(); } ((TMP_Text)textMesh).text = "-" + damage; ((TMP_Text)textMesh).fontSize = 2.5f; ((TMP_Text)textMesh).alignment = (TextAlignmentOptions)514; ((Graphic)textMesh).color = Color.red; ((TMP_Text)textMesh).enableCulling = false; ((TMP_Text)textMesh).richText = true; textMesh.transform.localScale = Vector3.one * 0.1f; velocity = new Vector3(Random.Range(-0.15f, 0.15f), 2.2f, 0f); } private void Awake() { textMesh = ((Component)this).GetComponent(); if ((Object)(object)textMesh != (Object)null) { textMesh.renderer.sortingOrder = 999; } } private void Update() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)this).transform; transform.position += velocity * Time.deltaTime; velocity.y -= 3.5f * Time.deltaTime; if ((Object)(object)Camera.main != (Object)null) { ((Component)this).transform.rotation = Quaternion.LookRotation(((Component)Camera.main).transform.forward); } lifeTime -= Time.deltaTime; if (lifeTime <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } [HarmonyPatch(typeof(EnemyHealth), "Hurt")] public class EnemyDamageDebugPatch { private static Dictionary hpBefore = new Dictionary(); private static int GetCurrentHP(EnemyHealth hp) { if ((Object)(object)hp == (Object)null) { return 0; } FieldInfo field = typeof(EnemyHealth).GetField("healthCurrent", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { return 0; } object value = field.GetValue(hp); if (value == null) { return 0; } return (int)value; } private static void Prefix(EnemyHealth __instance, int _damage, Vector3 _hurtDirection) { int currentHP = GetCurrentHP(__instance); hpBefore[__instance] = currentHP; Debug.Log((object)""); } private static void Postfix(EnemyHealth __instance, int _damage, Vector3 _hurtDirection) { if (hpBefore.ContainsKey(__instance)) { int num = hpBefore[__instance]; int currentHP = GetCurrentHP(__instance); int num2 = num - currentHP; hpBefore.Remove(__instance); } } } [HarmonyPatch(typeof(EnemyHealth))] public static class EnemyDamagePopupPatch { private static Dictionary hpBefore = new Dictionary(); private static float lastTime; private static Enemy lastEnemy; [HarmonyPatch("Hurt")] [HarmonyPrefix] private static void Prefix(EnemyHealth __instance) { hpBefore[__instance] = GetHP(__instance); } [HarmonyPatch("Hurt")] [HarmonyPostfix] private static void Postfix(EnemyHealth __instance) { Handle(__instance); } private static void Handle(EnemyHealth __instance) { if ((Object)(object)__instance == (Object)null) { return; } Enemy component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || !hpBefore.TryGetValue(__instance, out var value)) { return; } int hP = GetHP(__instance); int num = value - hP; hpBefore.Remove(__instance); if (num > 0) { float time = Time.time; if ((Object)(object)component == (Object)(object)lastEnemy && time - lastTime < 0.08f) { Spawn(component, num); return; } lastEnemy = component; lastTime = time; Spawn(component, num); } } private static int GetHP(EnemyHealth h) { FieldInfo field = typeof(EnemyHealth).GetField("healthCurrent", BindingFlags.Instance | BindingFlags.NonPublic); return (field != null) ? ((int)field.GetValue(h)) : 0; } private static void Spawn(Enemy enemy, int dmg) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0089: 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_002b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)enemy != (Object)null && (Object)(object)enemy.CenterTransform != (Object)null) ? enemy.CenterTransform.position : ((Component)enemy).transform.position); val += Vector3.up * 1.5f; GameObject val2 = new GameObject("DamagePopup"); TextMeshPro val3 = val2.AddComponent(); ((TMP_Text)val3).text = $"-{dmg}"; ((TMP_Text)val3).fontSize = 4f; ((TMP_Text)val3).alignment = (TextAlignmentOptions)514; ((Graphic)val3).color = Color.red; val2.transform.position = val; val2.AddComponent(); } } [HarmonyPatch(typeof(Enemy), "Awake")] public class EnemyPatch { private static void Postfix(Enemy __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("EnemyHealthLabel"); EnemyHealthLabel enemyHealthLabel = val.AddComponent(); enemyHealthLabel.enemy = __instance; enemyHealthLabel.health = ((Component)__instance).GetComponent(); val.transform.SetParent(((Component)__instance).transform); } } public class PopupMover : MonoBehaviour { private Vector3 velocity; private float life = 1.2f; private TextMeshPro text; private void Start() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) text = ((Component)this).GetComponent(); velocity = new Vector3(Random.Range(-0.2f, 0.2f), 2f, 0f); } private void Update() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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) Transform transform = ((Component)this).transform; transform.position += velocity * Time.deltaTime; velocity.y -= 3f * Time.deltaTime; if ((Object)(object)Camera.main != (Object)null) { ((Component)this).transform.forward = ((Component)Camera.main).transform.forward; } life -= Time.deltaTime; if ((Object)(object)text != (Object)null) { float num = Mathf.Clamp01(life); ((Graphic)text).color = new Color(((Graphic)text).color.r, ((Graphic)text).color.g, ((Graphic)text).color.b, num); } if (life <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } public class TestRunner : MonoBehaviour { private float timer; private void Update() { timer += Time.deltaTime; if (!(timer < 2f)) { timer = 0f; EnemyHealth[] array = Object.FindObjectsOfType(true); EnemyHealth[] array2 = array; foreach (EnemyHealth val in array2) { } } } }