using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using HarmonyLib;
using HealthDisplay;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSLZ.Marrow;
using Il2CppTMPro;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(HealthDisplayMod), "Health Display", "1.0.0", "habibis_v", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("HealthDisplay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HealthDisplay")]
[assembly: AssemblyTitle("HealthDisplay")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace HealthDisplay
{
public class HealthDisplayMod : MelonMod
{
private static GameObject? _hudRoot;
private static TextMeshPro? _hudText;
private static bool _built;
public static bool Enabled { get; private set; }
public override void OnInitializeMelon()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("com.habibis_v.healthdisplay").PatchAll();
Hooking.OnUIRigCreated += BuildMenu;
((MelonBase)this).LoggerInstance.Msg("Health Display loaded.");
}
private static void BuildMenu()
{
//IL_0018: 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_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: 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)
if (_built)
{
return;
}
_built = true;
Page val = Page.Root.CreatePage("Health Display", Color.red, 0, true);
val.CreateBool("Show Health", Color.red, false, (Action<bool>)delegate(bool v)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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_0051: 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_0068: Expected O, but got Unknown
Enabled = v;
if (v)
{
SpawnHUD();
}
else
{
DestroyHUD();
}
Notifier.Send(new Notification
{
Title = NotificationText.op_Implicit("Health Display"),
Message = NotificationText.op_Implicit(v ? "HUD Enabled" : "HUD Disabled"),
Type = (NotificationType)((!v) ? 1 : 3),
ShowTitleOnPopup = true,
PopupLength = 1.5f
});
});
val.CreateFunction("────────────────", Color.blue, (Action)delegate
{
});
val.CreateFunction("Add me on discord", Color.blue, (Action)delegate
{
});
val.CreateFunction("if you need help!", Color.blue, (Action)delegate
{
});
val.CreateFunction("Discord: habibis_v", Color.blue, (Action)delegate
{
});
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
_hudRoot = null;
_hudText = null;
if (Enabled)
{
SpawnHUD();
}
}
public static void SpawnHUD()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_0090: 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)
if (!((Object)(object)_hudRoot != (Object)null) && !((Object)(object)Camera.main == (Object)null))
{
_hudRoot = new GameObject("HealthDisplayHUD");
_hudRoot.transform.SetParent(((Component)Camera.main).transform, false);
_hudRoot.transform.localPosition = new Vector3(0f, -0.18f, 0.6f);
_hudRoot.transform.localRotation = Quaternion.identity;
_hudRoot.transform.localScale = Vector3.one * 0.0018f;
_hudText = _hudRoot.AddComponent<TextMeshPro>();
((TMP_Text)_hudText).alignment = (TextAlignmentOptions)514;
((TMP_Text)_hudText).fontSize = 100f;
((TMP_Text)_hudText).fontStyle = (FontStyles)1;
((Graphic)_hudText).color = Color.green;
((TMP_Text)_hudText).text = "♥ ---";
Object.DontDestroyOnLoad((Object)(object)_hudRoot);
RefreshText();
}
}
public static void DestroyHUD()
{
if (!((Object)(object)_hudRoot == (Object)null))
{
Object.Destroy((Object)(object)_hudRoot);
_hudRoot = null;
_hudText = null;
}
}
public static void RefreshText()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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)
if (Enabled && !((Object)(object)_hudText == (Object)null))
{
Player_Health playerHealth = GetPlayerHealth();
if ((Object)(object)playerHealth == (Object)null)
{
((TMP_Text)_hudText).text = "♥ ---";
((Graphic)_hudText).color = Color.white;
return;
}
float num = Mathf.Max(((Health)playerHealth).curr_Health, 0f);
float num2 = ((((Health)playerHealth).max_Health > 0f) ? ((Health)playerHealth).max_Health : 100f);
float num3 = num / num2;
Color color = ((num3 > 0.5f) ? Color.Lerp(Color.yellow, Color.green, (num3 - 0.5f) * 2f) : Color.Lerp(Color.red, Color.yellow, num3 * 2f));
((Graphic)_hudText).color = color;
((TMP_Text)_hudText).text = $"♥ {Mathf.CeilToInt(num)} / {Mathf.CeilToInt(num2)}";
}
}
public static Player_Health? GetPlayerHealth()
{
RigManager rigManager = Player.RigManager;
if ((Object)(object)rigManager == (Object)null || (Object)(object)rigManager.health == (Object)null)
{
return null;
}
return ((Il2CppObjectBase)rigManager.health).TryCast<Player_Health>();
}
public override void OnUpdate()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
if (!Enabled)
{
return;
}
if ((Object)(object)_hudRoot == (Object)null)
{
if ((Object)(object)Camera.main != (Object)null)
{
SpawnHUD();
}
return;
}
if ((Object)(object)Camera.main != (Object)null && (Object)(object)_hudRoot.transform.parent != (Object)(object)((Component)Camera.main).transform)
{
_hudRoot.transform.SetParent(((Component)Camera.main).transform, false);
_hudRoot.transform.localPosition = new Vector3(0f, -0.18f, 0.6f);
_hudRoot.transform.localRotation = Quaternion.identity;
_hudRoot.transform.localScale = Vector3.one * 0.0018f;
}
RefreshText();
}
}
}
namespace HealthDisplay.Patches
{
[HarmonyPatch(typeof(Player_Health), "UpdateHealth")]
public static class UpdateHealthPatch
{
private static void Postfix()
{
HealthDisplayMod.RefreshText();
}
}
[HarmonyPatch(typeof(Player_Health), "SetFullHealth")]
public static class SetFullHealthPatch
{
private static void Postfix()
{
HealthDisplayMod.RefreshText();
}
}
[HarmonyPatch(typeof(Player_Health), "TAKEDAMAGE")]
public static class TakeDamagePatch
{
private static void Postfix()
{
HealthDisplayMod.RefreshText();
}
}
}