using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using FishNet.Object;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HPDisplayMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HPDisplayMod")]
[assembly: AssemblyTitle("HPDisplayMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HowToFish_HPMod;
[BepInPlugin("com.stas.howtofish.hpdisplay", "HP Display Mod", "1.1.0")]
public class HPDisplayPlugin : BaseUnityPlugin
{
public static TMP_FontAsset GameFont;
private readonly Harmony harmony = new Harmony("com.stas.howtofish.hpdisplay");
private void Awake()
{
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"HP Display Mod v1.1.0 (Optimized) успешно загружен!");
}
}
[HarmonyPatch(typeof(FishingUI), "Awake")]
public class FontStealerPatch
{
private static void Postfix(FishingUI __instance, TextMeshProUGUI ____baitDiffText)
{
if ((Object)(object)HPDisplayPlugin.GameFont == (Object)null && (Object)(object)____baitDiffText != (Object)null)
{
HPDisplayPlugin.GameFont = ((TMP_Text)____baitDiffText).font;
}
}
}
[HarmonyPatch(typeof(BossUI), "UpdateBossHp")]
public class BossHPPatch
{
private static void Postfix(BossUI __instance, int curHp, RectTransform ____bossHpToRotate)
{
//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)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_008a: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)____bossHpToRotate == (Object)null)
{
return;
}
Transform val = ((Transform)____bossHpToRotate).Find("BossExactHPText");
TextMeshProUGUI val3;
if ((Object)(object)val == (Object)null)
{
GameObject val2 = new GameObject("BossExactHPText");
val2.transform.SetParent((Transform)(object)____bossHpToRotate, false);
val3 = val2.AddComponent<TextMeshProUGUI>();
((TMP_Text)val3).fontSize = 24f;
((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
((Graphic)val3).color = Color.white;
if ((Object)(object)HPDisplayPlugin.GameFont != (Object)null)
{
((TMP_Text)val3).font = HPDisplayPlugin.GameFont;
}
RectTransform component = val2.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0f, 0f);
component.anchorMax = new Vector2(1f, 1f);
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
val2.transform.SetAsLastSibling();
}
else
{
val3 = ((Component)val).GetComponent<TextMeshProUGUI>();
}
((TMP_Text)val3).text = $"{curHp} / {BossManager.BossMaxHp}";
}
}
[HarmonyPatch(typeof(Creature), "Awake")]
public class CreatureSpawnPatch
{
private static void Postfix(Creature __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if ((int)__instance.BossType == 0 && (Object)(object)((Component)__instance).gameObject.GetComponent<CreatureHPOverlay>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<CreatureHPOverlay>();
}
}
}
public class CreatureHPOverlay : MonoBehaviour
{
private Creature creature;
private GameObject textObj;
private TextMeshPro textMesh;
private int lastHp = -999;
private void Start()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
creature = ((Component)this).GetComponent<Creature>();
textObj = new GameObject($"FishHPText_{((NetworkBehaviour)creature).ObjectId}");
textMesh = textObj.AddComponent<TextMeshPro>();
((TMP_Text)textMesh).fontSize = 5f;
((TMP_Text)textMesh).alignment = (TextAlignmentOptions)514;
((Graphic)textMesh).color = Color.green;
ApplyFontIfAvailable();
}
private void LateUpdate()
{
//IL_00a7: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)creature == (Object)null || (Object)(object)textObj == (Object)null)
{
return;
}
ApplyFontIfAvailable();
if (creature.Hp != lastHp)
{
lastHp = creature.Hp;
if (lastHp <= 0)
{
((Behaviour)textMesh).enabled = false;
}
else
{
((Behaviour)textMesh).enabled = true;
((TMP_Text)textMesh).text = $"{lastHp} HP";
}
}
if (lastHp > 0)
{
textObj.transform.position = ((Component)this).transform.position + Vector3.up * 1.5f;
Camera curCamera = GameInfo.CurCamera;
if ((Object)(object)curCamera != (Object)null)
{
textObj.transform.LookAt(textObj.transform.position + ((Component)curCamera).transform.rotation * Vector3.forward, ((Component)curCamera).transform.rotation * Vector3.up);
}
}
}
private void OnDestroy()
{
if ((Object)(object)textObj != (Object)null)
{
Object.Destroy((Object)(object)textObj);
}
}
private void ApplyFontIfAvailable()
{
if ((Object)(object)textMesh != (Object)null && (Object)(object)((TMP_Text)textMesh).font == (Object)null && (Object)(object)HPDisplayPlugin.GameFont != (Object)null)
{
((TMP_Text)textMesh).font = HPDisplayPlugin.GameFont;
}
}
}