using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using P1.GameSystem;
using P1.GameSystem.Actor;
using P1.GameSystem.Actor.Status;
using P2.GameSystem;
using P2.GameSystem.Actor;
using P2.GameSystem.Actor.Status;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")]
[assembly: AssemblyCompany("BossHPBar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+73c4cf55b838cef54680f799182a6d8818bcf1cf")]
[assembly: AssemblyProduct("BossHPBar")]
[assembly: AssemblyTitle("BossHPBar")]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI (e.g., Code Suggestions, Refactoring, Documentation Generation).")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "Google")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace BossHPBar;
[BepInPlugin("com.haziksx.bosshpbar", "BossHPBar", "0.3.0")]
public class BossHealthPlugin : BasePlugin
{
public static ManualLogSource PluginLogger;
public override void Load()
{
PluginLogger = ((BasePlugin)this).Log;
ClassInjector.RegisterTypeInIl2Cpp<BossHealthUIController>();
Harmony.CreateAndPatchAll(typeof(BossHealthPatches), (string)null);
PluginLogger.LogInfo((object)"[BossHPBar] Plugin succesfully loaded (Patapon 1 & 2).");
}
}
public static class BossHealthPatches
{
public static nint ActiveBossPointer = global::System.IntPtr.Zero;
public static string ActiveBossName = "BOSS";
public static float LastUpdateTime = 0f;
public static Func<ValueTuple<int, int>> GetHpValues = null;
private static bool _uiInitialized = false;
private static readonly Dictionary<string, string> BossIds;
private static void EnsureUIExists()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
if (_uiInitialized)
{
return;
}
try
{
GameObject val = new GameObject("BossHealthUIManager");
Object.DontDestroyOnLoad((Object)val);
val.AddComponent<BossHealthUIController>();
_uiInitialized = true;
}
catch (global::System.Exception ex)
{
ManualLogSource pluginLogger = BossHealthPlugin.PluginLogger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[UI INITIALIZATION ERROR] ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<global::System.Exception>(ex);
}
pluginLogger.LogError(val2);
}
}
[HarmonyPatch(typeof(ActorObj), "createActorStatus")]
[HarmonyPostfix]
public static void PostSpawnBossHookP2(string pArcResourceNode, ActorObj __instance)
{
//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_002f: Unknown result type (might be due to invalid IL or missing references)
EnsureUIExists();
if (string.IsNullOrEmpty(pArcResourceNode))
{
return;
}
Enumerator<string, string> enumerator = BossIds.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
KeyValuePair<string, string> current = enumerator.Current;
if (!pArcResourceNode.Contains(current.Key))
{
continue;
}
ActiveBossName = current.Value;
ActiveBossPointer = ((Il2CppObjectBase)__instance).Pointer;
LastUpdateTime = Time.time;
GetHpValues = delegate
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_0081: Unknown result type (might be due to invalid IL or missing references)
if (__instance == null || ((Il2CppObjectBase)__instance).Pointer == global::System.IntPtr.Zero || ((Il2CppObjectBase)__instance).WasCollected)
{
return new ValueTuple<int, int>(0, 0);
}
ActorStatusObj pActorStatus_ = __instance.pActorStatus_;
if (pActorStatus_ == null || ((Il2CppObjectBase)pActorStatus_).Pointer == global::System.IntPtr.Zero || ((Il2CppObjectBase)pActorStatus_).WasCollected)
{
return new ValueTuple<int, int>(0, 0);
}
GameStatus val = ((Il2CppObjectBase)pActorStatus_).TryCast<GameStatus>();
return (val == null || ((Il2CppObjectBase)val).WasCollected) ? new ValueTuple<int, int>(0, 0) : new ValueTuple<int, int>(val.getHitPoint(), val.getMaxHitPoint());
};
break;
}
}
finally
{
((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
}
[HarmonyPatch(typeof(ActorObj), "update")]
[HarmonyPostfix]
public static void PostActorUpdateHookP2(ActorObj __instance)
{
EnsureUIExists();
if (ActiveBossPointer != (nint)global::System.IntPtr.Zero && ((Il2CppObjectBase)__instance).Pointer == (global::System.IntPtr)ActiveBossPointer)
{
LastUpdateTime = Time.time;
}
}
[HarmonyPatch(typeof(ActorObj), "createActorStatus")]
[HarmonyPostfix]
public static void PostSpawnBossHookP1(string pArcResourceNode, ActorObj __instance)
{
//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_002f: Unknown result type (might be due to invalid IL or missing references)
EnsureUIExists();
if (string.IsNullOrEmpty(pArcResourceNode))
{
return;
}
Enumerator<string, string> enumerator = BossIds.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
KeyValuePair<string, string> current = enumerator.Current;
if (!pArcResourceNode.Contains(current.Key))
{
continue;
}
ActiveBossName = current.Value;
ActiveBossPointer = ((Il2CppObjectBase)__instance).Pointer;
LastUpdateTime = Time.time;
GetHpValues = delegate
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_0081: Unknown result type (might be due to invalid IL or missing references)
if (__instance == null || ((Il2CppObjectBase)__instance).Pointer == global::System.IntPtr.Zero || ((Il2CppObjectBase)__instance).WasCollected)
{
return new ValueTuple<int, int>(0, 0);
}
ActorStatusObj pActorStatus_ = __instance.pActorStatus_;
if (pActorStatus_ == null || ((Il2CppObjectBase)pActorStatus_).Pointer == global::System.IntPtr.Zero || ((Il2CppObjectBase)pActorStatus_).WasCollected)
{
return new ValueTuple<int, int>(0, 0);
}
GameStatus val = ((Il2CppObjectBase)pActorStatus_).TryCast<GameStatus>();
return (val == null || ((Il2CppObjectBase)val).WasCollected) ? new ValueTuple<int, int>(0, 0) : new ValueTuple<int, int>(val.getHitPoint(), val.getMaxHitPoint());
};
break;
}
}
finally
{
((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
}
[HarmonyPatch(typeof(ActorObj), "update")]
[HarmonyPostfix]
public static void PostActorUpdateHookP1(ActorObj __instance)
{
EnsureUIExists();
if (ActiveBossPointer != (nint)global::System.IntPtr.Zero && ((Il2CppObjectBase)__instance).Pointer == (global::System.IntPtr)ActiveBossPointer)
{
LastUpdateTime = Time.time;
}
}
static BossHealthPatches()
{
Dictionary<string, string> obj = new Dictionary<string, string>();
obj.Add("unit101_01_01", "Dodonga");
obj.Add("unit108_01_01", "Majidonga");
obj.Add("unit111_01_01", "Ciokina");
obj.Add("unit112_01_01", "Cioking");
obj.Add("unit113_01_01", "Shookle");
obj.Add("unit114_01_01", "Shooshookle");
obj.Add("unit115_01_01", "Gaeen");
obj.Add("unit116_01_01", "Dogaeen");
obj.Add("unit120_01_01", "Zaknel");
obj.Add("unit121_01_01", "Dokaknel");
obj.Add("unit122_01_01", "Goruru");
obj.Add("unit123_01_01", "Garuru");
obj.Add("unit126_01_01", "Manboth");
obj.Add("unit127_01_01", "Manboroth");
obj.Add("unit128_01_01", "Centura");
obj.Add("unit129_01_01", "Darantula");
obj.Add("unit132_01_01", "Gorl");
obj.Add("unit133_01_01", "Kharma");
obj.Add("unit201_01_01", "Dodonga");
obj.Add("unit208_01_01", "Majidonga");
obj.Add("unit242_01_01", "Kacchindonga");
obj.Add("unit211_01_01", "Ciokina");
obj.Add("unit212_01_01", "Cioking");
obj.Add("unit213_01_01", "Shookle");
obj.Add("unit214_01_01", "Shooshookle");
obj.Add("unit215_01_01", "Gaeen");
obj.Add("unit216_01_01", "Dogaeen");
obj.Add("unit220_01_01", "Zaknel");
obj.Add("unit221_01_01", "Dokaknel");
obj.Add("unit222_01_01", "Goruru");
obj.Add("unit223_01_01", "Garuru");
obj.Add("unit224_01_01", "Mochichichi");
obj.Add("unit225_01_01", "Fenicchi");
obj.Add("unit226_01_01", "Manboth");
obj.Add("unit227_01_01", "Manboroth");
obj.Add("unit228_01_01", "Centura");
obj.Add("unit229_01_01", "Darantula");
obj.Add("unit230_01_01", "Kanogias");
obj.Add("unit231_01_01", "Ganodias");
obj.Add("unit232_01_01", "Dettankarmen");
obj.Add("unit233_01_01", "Zuttankarmen");
BossIds = obj;
}
}
public class BossHealthUIController : MonoBehaviour
{
private float _animatedHp = -1f;
private nint _lastBossPointer = global::System.IntPtr.Zero;
public BossHealthUIController(nint handle)
: base((global::System.IntPtr)handle)
{
}
public void OnGUI()
{
//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
//IL_04cb: Expected O, but got Unknown
//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0521: Unknown result type (might be due to invalid IL or missing references)
//IL_0543: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: Unknown result type (might be due to invalid IL or missing references)
//IL_0439: Unknown result type (might be due to invalid IL or missing references)
//IL_0445: Unknown result type (might be due to invalid IL or missing references)
//IL_044f: Unknown result type (might be due to invalid IL or missing references)
//IL_0468: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Unknown result type (might be due to invalid IL or missing references)
//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
nint activeBossPointer = BossHealthPatches.ActiveBossPointer;
if (activeBossPointer == (nint)global::System.IntPtr.Zero || BossHealthPatches.GetHpValues == null)
{
return;
}
if (Time.time - BossHealthPatches.LastUpdateTime > 0.5f)
{
BossHealthPatches.ActiveBossPointer = global::System.IntPtr.Zero;
BossHealthPatches.GetHpValues = null;
return;
}
ValueTuple<int, int> val = BossHealthPatches.GetHpValues.Invoke();
int item = val.Item1;
int item2 = val.Item2;
if (item <= 0 || item2 <= 1)
{
BossHealthPatches.ActiveBossPointer = global::System.IntPtr.Zero;
BossHealthPatches.GetHpValues = null;
return;
}
if (_lastBossPointer != activeBossPointer)
{
_animatedHp = item;
_lastBossPointer = activeBossPointer;
}
_animatedHp = Mathf.Lerp(_animatedHp, (float)item, Time.deltaTime * 6f);
Color backgroundColor = GUI.backgroundColor;
Color contentColor = GUI.contentColor;
Color color = GUI.color;
Texture2D background = GUI.skin.box.normal.background;
TextAnchor alignment = GUI.skin.label.alignment;
int fontSize = GUI.skin.label.fontSize;
FontStyle fontStyle = GUI.skin.label.fontStyle;
try
{
float num = (float)Screen.height / 1080f;
float num2 = 700f * num;
float num3 = 32f * num;
float num4 = 3f * num;
float num5 = ((float)Screen.width - num2) / 2f;
float num6 = 55f * num;
GUI.skin.box.normal.background = Texture2D.whiteTexture;
GUI.backgroundColor = Color.white;
GUI.Box(new Rect(num5 - num4, num6 - num4, num2 + num4 * 2f, num3 + num4 * 2f), "");
GUI.backgroundColor = new Color(0.12f, 0.12f, 0.12f, 0.9f);
GUI.Box(new Rect(num5, num6, num2, num3), "");
float num7 = Mathf.Clamp01(_animatedHp / (float)item2);
if (num7 > 0f)
{
Color val2 = default(Color);
((Color)(ref val2))..ctor(1f, 0.25f, 0.2f, 1f);
Color val3 = default(Color);
((Color)(ref val3))..ctor(0.35f, 0f, 0f, 1f);
float num8 = num2 * num7;
int num9 = 80;
float num10 = num2 / (float)num9;
for (int i = 0; i < num9; i++)
{
float num11 = num5 + (float)i * num10;
if (num11 >= num5 + num8)
{
break;
}
float num12 = num10;
if (num11 + num10 > num5 + num8)
{
num12 = num5 + num8 - num11;
}
float num13 = Mathf.Abs((float)i / (float)(num9 - 1) - 0.5f) * 2f;
GUI.backgroundColor = Color.Lerp(val2, val3, num13);
GUI.Box(new Rect(num11, num6, num12, num3), "");
}
}
string text = BossHealthPatches.ActiveBossName.ToUpper();
string text2 = $"{item} / {item2}";
int num14 = Mathf.RoundToInt((float)item / (float)item2 * 100f);
string text3 = $"{num14}%";
float num15 = 2f * num;
float num16 = 15f * num;
Rect val4 = default(Rect);
((Rect)(ref val4))..ctor(num5 + num16, num6, num2, num3);
Rect val5 = default(Rect);
((Rect)(ref val5))..ctor(num5, num6, num2, num3);
Rect val6 = default(Rect);
((Rect)(ref val6))..ctor(num5, num6, num2 - num16, num3);
GUI.skin.label.fontStyle = (FontStyle)1;
GUI.skin.label.fontSize = (int)(20f * num);
GUI.skin.label.alignment = (TextAnchor)3;
GUI.contentColor = Color.black;
GUI.Label(new Rect(((Rect)(ref val4)).x + num15, ((Rect)(ref val4)).y + num15, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text);
GUI.contentColor = new Color(1f, 0.85f, 0f);
GUI.Label(val4, text);
GUI.skin.label.alignment = (TextAnchor)5;
GUI.contentColor = Color.black;
GUI.Label(new Rect(((Rect)(ref val6)).x + num15, ((Rect)(ref val6)).y + num15, ((Rect)(ref val6)).width, ((Rect)(ref val6)).height), text3);
GUI.contentColor = Color.white;
GUI.Label(val6, text3);
GUI.skin.label.alignment = (TextAnchor)4;
GUI.contentColor = Color.black;
GUI.Label(new Rect(((Rect)(ref val5)).x + num15, ((Rect)(ref val5)).y + num15, ((Rect)(ref val5)).width, ((Rect)(ref val5)).height), text2);
GUI.contentColor = Color.white;
GUI.Label(val5, text2);
}
catch (global::System.Exception ex)
{
ManualLogSource pluginLogger = BossHealthPlugin.PluginLogger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val7 = new BepInExErrorLogInterpolatedStringHandler(14, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("[ONGUI ERROR] ");
((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<global::System.Exception>(ex);
}
pluginLogger.LogError(val7);
}
finally
{
GUI.backgroundColor = backgroundColor;
GUI.contentColor = contentColor;
GUI.color = color;
GUI.skin.box.normal.background = background;
GUI.skin.label.alignment = alignment;
GUI.skin.label.fontSize = fontSize;
GUI.skin.label.fontStyle = fontStyle;
}
}
}