using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("UltraHealthBars")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Ultrakill Health Bar Mod")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UltraHealthBars")]
[assembly: AssemblyTitle("UltraHealthBars")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[BepInPlugin("com.yourname.ultrahealthbars", "UltraHealthBars", "1.4.0")]
public class UltraHealthBarsPlugin : BaseUnityPlugin
{
public static ConfigEntry<float> BarScale;
public static ConfigEntry<float> BarHeightMult;
public static Dictionary<string, ConfigEntry<bool>> EnemyConfigEntries = new Dictionary<string, ConfigEntry<bool>>();
public static ConfigFile CustomConfig;
public static TMP_FontAsset UltraFont;
private void Awake()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
CustomConfig = ((BaseUnityPlugin)this).Config;
BarScale = ((BaseUnityPlugin)this).Config.Bind<float>("1. Visuals", "SizeMultiplier", 1f, "Global scale of the bars.");
BarHeightMult = ((BaseUnityPlugin)this).Config.Bind<float>("1. Visuals", "HeightOffset", 1f, "Vertical offset adjustment.");
Harmony val = new Harmony("com.yourname.ultrahealthbars");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"UltraHealthBars Final Loaded.");
}
public static bool IsEnemyEnabled(string enemyName)
{
string text = enemyName.Replace(" ", "");
if (EnemyConfigEntries.ContainsKey(text))
{
return EnemyConfigEntries[text].Value;
}
ConfigEntry<bool> val = CustomConfig.Bind<bool>("2. Enemies (Unlocked)", text, true, "Show health bar for " + enemyName);
EnemyConfigEntries.Add(text, val);
CustomConfig.Save();
return val.Value;
}
}
[HarmonyPatch(typeof(EnemyIdentifier), "Start")]
public class EnemySpawnPatch
{
private static void Postfix(EnemyIdentifier __instance)
{
if (!__instance.isBoss && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<BossHealthBar>()))
{
string text = ((object)(EnemyType)(ref __instance.enemyType)).ToString();
if (!text.Contains("Wicked") && UltraHealthBarsPlugin.IsEnemyEnabled(text) && (Object)(object)((Component)__instance).gameObject.GetComponent<HealthBarController>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<HealthBarController>();
}
}
}
}
public class HealthBarController : MonoBehaviour
{
private EnemyIdentifier eid;
private GameObject canvasObj;
private RectTransform fillRect;
private RectTransform ghostRect;
private TextMeshProUGUI hpText;
private TextMeshProUGUI nameText;
private float maxHealth;
private float targetFill = 1f;
private float ghostFill = 1f;
private float ghostTimer = 0f;
private float heightOffset = 2.5f;
private float baseWorldScale = 0.012f;
private void Start()
{
//IL_0047: 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_0050: Unknown result type (might be due to invalid IL or missing references)
eid = ((Component)this).GetComponent<EnemyIdentifier>();
if ((Object)(object)eid == (Object)null)
{
return;
}
maxHealth = eid.health;
Collider component = ((Component)this).GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
Bounds bounds = component.bounds;
float num = ((Bounds)(ref bounds)).extents.y * 2.2f;
heightOffset = (num + 0.5f) * UltraHealthBarsPlugin.BarHeightMult.Value;
}
if ((Object)(object)UltraHealthBarsPlugin.UltraFont == (Object)null)
{
UltraHealthBarsPlugin.UltraFont = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name.Contains("VCR")));
}
CreateHealthUI();
}
private void LateUpdate()
{
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)eid == (Object)null || eid.dead)
{
if ((Object)(object)canvasObj != (Object)null)
{
Object.Destroy((Object)(object)canvasObj);
}
return;
}
float num = eid.health / maxHealth;
targetFill = num;
if (targetFill < ghostFill)
{
ghostTimer -= Time.deltaTime;
if (ghostTimer <= 0f)
{
ghostFill = Mathf.Lerp(ghostFill, targetFill, Time.deltaTime * 5f);
}
}
else
{
ghostFill = targetFill;
ghostTimer = 0.5f;
}
if ((Object)(object)fillRect != (Object)null)
{
fillRect.anchorMax = new Vector2(targetFill, 1f);
}
if ((Object)(object)ghostRect != (Object)null)
{
ghostRect.anchorMax = new Vector2(ghostFill, 1f);
}
if ((Object)(object)hpText != (Object)null)
{
((TMP_Text)hpText).text = Mathf.CeilToInt(eid.health).ToString();
}
if ((Object)(object)canvasObj != (Object)null && (Object)(object)Camera.main != (Object)null)
{
canvasObj.transform.position = ((Component)this).transform.position + Vector3.up * heightOffset;
canvasObj.transform.rotation = ((Component)Camera.main).transform.rotation;
float num2 = (((Component)this).transform.lossyScale.x + ((Component)this).transform.lossyScale.y + ((Component)this).transform.lossyScale.z) / 3f;
if (num2 < 0.1f)
{
num2 = 1f;
}
float num3 = baseWorldScale * UltraHealthBarsPlugin.BarScale.Value / num2;
canvasObj.transform.localScale = Vector3.one * num3;
}
}
public void OnDamage()
{
ghostTimer = 0.5f;
}
private void CreateHealthUI()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: 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_018a: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: 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_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0304: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Expected O, but got Unknown
//IL_0388: Unknown result type (might be due to invalid IL or missing references)
//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
//IL_03de: Unknown result type (might be due to invalid IL or missing references)
//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
//IL_040b: Unknown result type (might be due to invalid IL or missing references)
canvasObj = new GameObject("UltraHealthCanvas");
canvasObj.transform.SetParent(((Component)this).transform);
canvasObj.layer = LayerMask.NameToLayer("Default");
Canvas val = canvasObj.AddComponent<Canvas>();
val.renderMode = (RenderMode)2;
val.sortingOrder = 50;
GameObject val2 = new GameObject("NameText");
val2.transform.SetParent(canvasObj.transform, false);
val2.layer = LayerMask.NameToLayer("Default");
nameText = val2.AddComponent<TextMeshProUGUI>();
((TMP_Text)nameText).alignment = (TextAlignmentOptions)1026;
((TMP_Text)nameText).fontSize = 32f;
((Graphic)nameText).color = Color.white;
((TMP_Text)nameText).fontStyle = (FontStyles)17;
string input = ((object)(EnemyType)(ref eid.enemyType)).ToString();
string text = Regex.Replace(input, "(\\B[A-Z])", " $1").ToUpper();
((TMP_Text)nameText).text = text;
if ((Object)(object)UltraHealthBarsPlugin.UltraFont != (Object)null)
{
((TMP_Text)nameText).font = UltraHealthBarsPlugin.UltraFont;
}
((TMP_Text)nameText).outlineWidth = 0.25f;
((TMP_Text)nameText).outlineColor = Color32.op_Implicit(Color.black);
RectTransform component = val2.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(400f, 50f);
component.anchoredPosition = new Vector2(0f, 42f);
GameObject val3 = CreateBlock(canvasObj, Color.black, new Vector2(304f, 34f));
GameObject parent = CreateBlock(val3, new Color(0.2f, 0f, 0f), new Vector2(300f, 30f));
GameObject val4 = CreateBlock(parent, new Color(0.5f, 0.5f, 0.5f), new Vector2(300f, 30f));
ghostRect = val4.GetComponent<RectTransform>();
ghostRect.pivot = new Vector2(0f, 0.5f);
ghostRect.anchorMin = Vector2.zero;
ghostRect.anchorMax = Vector2.one;
ghostRect.offsetMin = Vector2.zero;
ghostRect.offsetMax = Vector2.zero;
GameObject val5 = CreateBlock(val4, new Color(1f, 0f, 0f), new Vector2(300f, 30f));
fillRect = val5.GetComponent<RectTransform>();
fillRect.pivot = new Vector2(0f, 0.5f);
fillRect.anchorMin = new Vector2(0f, 0f);
fillRect.anchorMax = Vector2.one;
fillRect.offsetMin = Vector2.zero;
fillRect.offsetMax = Vector2.zero;
GameObject val6 = new GameObject("HPText");
val6.transform.SetParent(val3.transform, false);
val6.layer = LayerMask.NameToLayer("Default");
hpText = val6.AddComponent<TextMeshProUGUI>();
((TMP_Text)hpText).alignment = (TextAlignmentOptions)514;
((TMP_Text)hpText).fontSize = 24f;
((Graphic)hpText).color = Color.white;
((TMP_Text)hpText).fontStyle = (FontStyles)1;
if ((Object)(object)UltraHealthBarsPlugin.UltraFont != (Object)null)
{
((TMP_Text)hpText).font = UltraHealthBarsPlugin.UltraFont;
}
((TMP_Text)hpText).outlineWidth = 0.2f;
((TMP_Text)hpText).outlineColor = Color32.op_Implicit(Color.black);
RectTransform component2 = val6.GetComponent<RectTransform>();
component2.sizeDelta = new Vector2(300f, 30f);
component2.anchoredPosition = Vector2.zero;
}
private GameObject CreateBlock(GameObject parent, Color col, Vector2 size)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0038: 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)
GameObject val = new GameObject("Block");
val.transform.SetParent(parent.transform, false);
val.layer = LayerMask.NameToLayer("Default");
Image val2 = val.AddComponent<Image>();
((Graphic)val2).color = col;
((Graphic)val2).material = Canvas.GetDefaultCanvasMaterial();
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = size;
return val;
}
}