using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BossHealthDisplay;
using HarmonyLib;
using MelonLoader;
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: MelonInfo(typeof(BossHealthDisplayMod), "BossHealthDisplay", "1.0.0", "rf5860", null)]
[assembly: MelonGame("Alvios", "Vellum")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace BossHealthDisplay;
public class BossHealthDisplayMod : MelonMod
{
internal static TextMeshProUGUI healthText;
internal static TextMeshProUGUI shieldText;
internal static GameObject healthTextObject;
internal static GameObject shieldTextObject;
public override void OnInitializeMelon()
{
((MelonBase)this).LoggerInstance.Msg("Boss Health Display mod loaded!");
}
internal static AIControl GetBoss(BossHealthbar __instance)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
FieldInfo fieldInfo = AccessTools.Field(typeof(BossHealthbar), "boss");
return (AIControl)fieldInfo.GetValue(__instance);
}
}
[HarmonyPatch(typeof(BossHealthbar), "Setup")]
public class BossHealthbar_Setup_Patch
{
private static void Postfix(BossHealthbar __instance, EntityControl entity)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: 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_017d: Expected O, but got Unknown
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)BossHealthDisplayMod.healthTextObject == (Object)null)
{
BossHealthDisplayMod.healthTextObject = new GameObject("HealthText");
BossHealthDisplayMod.healthTextObject.transform.SetParent(((Component)__instance.HealthbarMain).transform.parent, false);
BossHealthDisplayMod.healthText = BossHealthDisplayMod.healthTextObject.AddComponent<TextMeshProUGUI>();
((TMP_Text)BossHealthDisplayMod.healthText).text = "";
((TMP_Text)BossHealthDisplayMod.healthText).fontSize = 20f;
((Graphic)BossHealthDisplayMod.healthText).color = new Color(0.9f, 0.5f, 0.3f);
((TMP_Text)BossHealthDisplayMod.healthText).alignment = (TextAlignmentOptions)514;
((TMP_Text)BossHealthDisplayMod.healthText).fontStyle = (FontStyles)1;
((TMP_Text)BossHealthDisplayMod.healthText).outlineWidth = 0.3f;
((TMP_Text)BossHealthDisplayMod.healthText).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);
RectTransform component = BossHealthDisplayMod.healthTextObject.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.5f, 0.5f);
component.anchorMax = new Vector2(0.5f, 0.5f);
component.anchoredPosition = new Vector2(0f, 0f);
component.sizeDelta = new Vector2(200f, 30f);
BossHealthDisplayMod.healthTextObject.transform.SetAsLastSibling();
}
if ((Object)(object)BossHealthDisplayMod.shieldTextObject == (Object)null && (Object)(object)__instance.ShieldBar != (Object)null)
{
BossHealthDisplayMod.shieldTextObject = new GameObject("ShieldText");
BossHealthDisplayMod.shieldTextObject.transform.SetParent(((Component)__instance.ShieldBar).transform.parent, false);
BossHealthDisplayMod.shieldText = BossHealthDisplayMod.shieldTextObject.AddComponent<TextMeshProUGUI>();
((TMP_Text)BossHealthDisplayMod.shieldText).text = "";
((TMP_Text)BossHealthDisplayMod.shieldText).fontSize = 18f;
((Graphic)BossHealthDisplayMod.shieldText).color = new Color(0.5f, 0.8f, 1f);
((TMP_Text)BossHealthDisplayMod.shieldText).alignment = (TextAlignmentOptions)514;
((TMP_Text)BossHealthDisplayMod.shieldText).fontStyle = (FontStyles)1;
((TMP_Text)BossHealthDisplayMod.shieldText).outlineWidth = 0.3f;
((TMP_Text)BossHealthDisplayMod.shieldText).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);
RectTransform component2 = BossHealthDisplayMod.shieldTextObject.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0.5f, 0.5f);
component2.anchorMax = new Vector2(0.5f, 0.5f);
component2.anchoredPosition = new Vector2(0f, 0f);
component2.sizeDelta = new Vector2(200f, 30f);
BossHealthDisplayMod.shieldTextObject.transform.SetAsLastSibling();
}
}
}
[HarmonyPatch(typeof(BossHealthbar), "UpdateHealthbar")]
public class BossHealthbar_UpdateHealthbar_Patch
{
private static void Postfix(BossHealthbar __instance)
{
if (!((Object)(object)BossHealthDisplayMod.healthText == (Object)null))
{
AIControl boss = BossHealthDisplayMod.GetBoss(__instance);
if (!((Object)(object)boss == (Object)null) && !((Object)(object)((EntityControl)boss).health == (Object)null))
{
int health = ((EntityControl)boss).health.health;
int maxHealth = ((EntityControl)boss).health.MaxHealth;
((TMP_Text)BossHealthDisplayMod.healthText).text = $"{health:N0} / {maxHealth:N0}";
}
}
}
}
[HarmonyPatch(typeof(BossHealthbar), "UpdateShields")]
public class BossHealthbar_UpdateShields_Patch
{
private static void Postfix(BossHealthbar __instance)
{
if ((Object)(object)BossHealthDisplayMod.shieldText == (Object)null)
{
return;
}
AIControl boss = BossHealthDisplayMod.GetBoss(__instance);
if (boss != null)
{
EntityHealth health = ((EntityControl)boss).health;
if (((health != null) ? new int?(health.MaxShield) : null) > 0)
{
int num = Mathf.CeilToInt(((EntityControl)boss).health.shield);
int maxShield = ((EntityControl)boss).health.MaxShield;
((TMP_Text)BossHealthDisplayMod.shieldText).text = $"{num:N0} / {maxShield:N0}";
return;
}
}
if ((Object)(object)BossHealthDisplayMod.shieldText != (Object)null)
{
((TMP_Text)BossHealthDisplayMod.shieldText).text = "";
}
}
}