using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("AnotherEnemyHealthBars")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.3.0")] [assembly: AssemblyInformationalVersion("1.1.3+67a17c07d83219143096295278d9339c836bb50d")] [assembly: AssemblyProduct("AnotherEnemyHealthBars")] [assembly: AssemblyTitle("AnotherEnemyHealthBars")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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; } } } namespace AnotherEnemyHealthBars { internal sealed class HealthBarView : MonoBehaviour { private EnemyHealth health; private Enemy enemy; private GameObject root; private Canvas canvas; private RectTransform canvasRect; private Image fill; private Image frame; private TextMeshProUGUI label; private float hideAt; private float headOffset = 1.6f; private float nextHeadProbe; private float smoothedFill = 1f; private int predictedMaxHealth = -1; private int predictedCurrentHealth = -1; private const float BaseScale = 0.0065f; private static Sprite whiteSprite; private static Sprite White() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)whiteSprite == (Object)null) { Texture2D whiteTexture = Texture2D.whiteTexture; whiteSprite = Sprite.Create(whiteTexture, new Rect(0f, 0f, (float)((Texture)whiteTexture).width, (float)((Texture)whiteTexture).height), new Vector2(0.5f, 0.5f), 100f); } return whiteSprite; } private void Awake() { health = ((Component)this).GetComponent(); if ((Object)(object)health != (Object)null) { enemy = health.enemy; } } internal void Reveal() { hideAt = Time.time + Mathf.Max(0.5f, Plugin.DisplaySeconds.Value); } internal void ObserveDamage(int amount) { if (amount > 0) { int num = ReadActualMaxHealth(); int num2 = ReadActualCurrentHealth(num); if (predictedMaxHealth < 1) { predictedMaxHealth = num; } else if (num > 0) { predictedMaxHealth = Mathf.Max(predictedMaxHealth, num); } if (predictedCurrentHealth < 0) { predictedCurrentHealth = num2; } else if (num2 >= 0 && num2 < predictedCurrentHealth) { predictedCurrentHealth = num2; } if (predictedCurrentHealth < 0) { predictedCurrentHealth = num2; } predictedCurrentHealth = Mathf.Clamp(predictedCurrentHealth - amount, 0, Mathf.Max(1, predictedMaxHealth)); smoothedFill = Mathf.Min(smoothedFill, (float)predictedCurrentHealth / (float)Mathf.Max(1, predictedMaxHealth)); } } internal void PopDamage(int amount) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) DamagePopup.Spawn(BarAnchor().position + Vector3.up * (headOffset + 0.2f), amount); } private Transform BarAnchor() { if ((Object)(object)enemy == (Object)null && (Object)(object)health != (Object)null) { enemy = health.enemy; } if ((Object)(object)enemy != (Object)null) { if ((Object)(object)enemy.CenterTransform != (Object)null) { return enemy.CenterTransform; } if (enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null) { return ((Component)enemy.Rigidbody).transform; } } return ((Component)this).transform; } private bool Grabbed() { if ((Object)(object)enemy != (Object)null && enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null) { return enemy.Rigidbody.grabbed; } return false; } private void Build() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00bb: 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_011e: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) root = new GameObject("AEHB_HealthBar"); root.transform.SetParent(((Component)this).transform, false); canvas = root.AddComponent(); canvas.renderMode = (RenderMode)2; canvasRect = ((Component)canvas).GetComponent(); canvasRect.sizeDelta = new Vector2(220f, 30f); ((Transform)canvasRect).localScale = Vector3.one * 0.0065f; frame = NewImage((Transform)(object)canvasRect, Palette.Background); Stretch(((Graphic)frame).rectTransform, 0f); fill = NewImage((Transform)(object)canvasRect, Palette.BarHigh); Stretch(((Graphic)fill).rectTransform, 3f); fill.type = (Type)3; fill.fillMethod = (FillMethod)0; fill.fillOrigin = 0; fill.fillAmount = 1f; GameObject val = new GameObject("Text"); val.transform.SetParent((Transform)(object)canvasRect, false); label = val.AddComponent(); ((TMP_Text)label).alignment = (TextAlignmentOptions)514; ((TMP_Text)label).enableAutoSizing = false; ((TMP_Text)label).fontSize = 14f; ((Graphic)label).color = Color.white; Stretch(((TMP_Text)label).rectTransform, 0f); } private static Image NewImage(Transform parent, Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Img"); val.transform.SetParent(parent, false); Image obj = val.AddComponent(); obj.sprite = White(); ((Graphic)obj).color = color; ((Graphic)obj).raycastTarget = false; return obj; } private static void Stretch(RectTransform rt, float inset) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = new Vector2(inset, inset); rt.offsetMax = new Vector2(0f - inset, 0f - inset); } private void ProbeHeadOffset(Transform anchor) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!(Time.time < nextHeadProbe)) { nextHeadProbe = Time.time + 0.5f; if (TryGetTop(((Object)(object)enemy != (Object)null && (Object)(object)enemy.EnemyParent != (Object)null) ? ((Component)enemy.EnemyParent).transform : (((Object)(object)health != (Object)null && (Object)(object)((Component)health).transform.parent != (Object)null) ? ((Component)health).transform.parent : ((Component)this).transform), out var topY)) { headOffset = Mathf.Clamp(topY - anchor.position.y + 0.15f, 0.3f, 18f); } } } private static bool TryGetTop(Transform node, out float topY) { //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_0043: Unknown result type (might be due to invalid IL or missing references) topY = 0f; bool flag = false; Renderer[] componentsInChildren = ((Component)node).GetComponentsInChildren(false); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !(((object)val).GetType().Name == "ParticleSystemRenderer")) { Bounds bounds = val.bounds; float y = ((Bounds)(ref bounds)).max.y; if (!flag || y > topY) { topY = y; flag = true; } } } return flag; } private void LateUpdate() { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: 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_0256: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: 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_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)health == (Object)null) { if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)root); } Object.Destroy((Object)(object)this); return; } bool flag = Plugin.ShowOnGrab.Value && Grabbed(); if (!(Plugin.AlwaysVisible.Value || flag) && !(Time.time < hideAt)) { if ((Object)(object)root != (Object)null && root.activeSelf) { root.SetActive(false); } return; } if ((Object)(object)root == (Object)null) { Build(); } if (!root.activeSelf) { root.SetActive(true); } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } Transform val = BarAnchor(); ProbeHeadOffset(val); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.position.x, val.position.y + headOffset + Plugin.HeightOffset.Value, val.position.z); root.transform.position = val2; root.transform.rotation = ((Component)main).transform.rotation; ((Transform)canvasRect).localScale = Vector3.one * (0.0065f * Mathf.Max(0.05f, Plugin.BarScale.Value)); int num = ReadActualMaxHealth(); int num2 = ReadActualCurrentHealth(num); if (predictedMaxHealth > 0) { num = Mathf.Max(num, predictedMaxHealth); } if (predictedCurrentHealth >= 0) { num2 = Mathf.Min(num2, predictedCurrentHealth); if (actualCurrentLooksStale(num2, num)) { num2 = predictedCurrentHealth; } } predictedMaxHealth = num; predictedCurrentHealth = num2; float num3 = (float)num2 / (float)num; smoothedFill = Mathf.Lerp(smoothedFill, num3, Time.deltaTime * 12f); fill.fillAmount = smoothedFill; float num4 = Mathf.Clamp01(1f - Vector3.Distance(((Component)main).transform.position, val2) / Mathf.Max(1f, Plugin.FadeDistance.Value)); if (Plugin.RequireLineOfSight.Value && !HasLineOfSight(((Component)main).transform.position, val.position)) { num4 = 0f; } if (!Plugin.AlwaysVisible.Value && !flag) { float num5 = hideAt - Time.time; if (num5 < 0.5f) { num4 *= Mathf.Clamp01(num5 / 0.5f); } } Color color = Color.Lerp(Palette.BarLow, Palette.BarHigh, num3); color.a *= num4; ((Graphic)fill).color = color; Color background = Palette.Background; background.a *= num4; ((Graphic)frame).color = background; ((TMP_Text)label).text = num2 + " / " + num; Color text = Palette.Text; text.a *= num4; ((Graphic)label).color = text; } private int ReadActualMaxHealth() { return Mathf.Max(1, (!((Object)(object)health != (Object)null)) ? 1 : health.health); } private int ReadActualCurrentHealth(int max) { return Mathf.Clamp(((Object)(object)health != (Object)null) ? health.healthCurrent : max, 0, max); } private bool actualCurrentLooksStale(int actualCurrent, int max) { if (actualCurrent >= max && predictedCurrentHealth >= 0) { return predictedCurrentHealth < max; } return false; } private bool HasLineOfSight(Vector3 from, Vector3 to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) Vector3 val = to - from; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.01f) { return true; } Vector3 val2 = val / magnitude; Vector3 val3 = from + val2 * 0.05f; float num = Mathf.Max(0f, magnitude - 0.05f); RaycastHit[] array = Physics.RaycastAll(val3, val2, num, -5, (QueryTriggerInteraction)1); if (array.Length == 0) { return true; } Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); Transform val4 = (((Object)(object)PlayerAvatar.instance != (Object)null) ? ((Component)PlayerAvatar.instance).transform.root : null); Transform val5 = ((Component)this).transform.root; RaycastHit[] array2 = array; for (int num2 = 0; num2 < array2.Length; num2++) { RaycastHit val6 = array2[num2]; if ((Object)(object)((RaycastHit)(ref val6)).collider == (Object)null) { continue; } Transform val7 = ((Component)((RaycastHit)(ref val6)).collider).transform.root; if (!((Object)(object)val4 != (Object)null) || !((Object)(object)val7 == (Object)(object)val4)) { if ((Object)(object)val7 == (Object)(object)val5) { return true; } return false; } } return true; } private void OnDestroy() { if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)root); } } } internal sealed class DamagePopup : MonoBehaviour { private TextMeshProUGUI text; private float age; private const float Life = 1.15f; private Vector3 start; internal static void Spawn(Vector3 worldPos, int amount) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) new GameObject("AEHB_Damage").AddComponent().Setup(worldPos, amount); } private void Setup(Vector3 worldPos, int amount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) start = worldPos + Random.insideUnitSphere * 0.25f; Canvas obj = ((Component)this).gameObject.AddComponent(); obj.renderMode = (RenderMode)2; RectTransform component = ((Component)obj).GetComponent(); component.sizeDelta = new Vector2(140f, 70f); ((Transform)component).localScale = Vector3.one * (0.01f * Mathf.Max(0.05f, Plugin.DamageNumberScale.Value)); GameObject val = new GameObject("Text"); val.transform.SetParent((Transform)(object)component, false); text = val.AddComponent(); ((TMP_Text)text).alignment = (TextAlignmentOptions)514; ((TMP_Text)text).enableAutoSizing = false; ((TMP_Text)text).fontStyle = (FontStyles)1; RectTransform rectTransform = ((TMP_Text)text).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; ((TMP_Text)text).text = "-" + amount; if (amount >= 50) { ((Graphic)text).color = Palette.DmgLarge; ((TMP_Text)text).fontSize = 44f; } else if (amount >= 20) { ((Graphic)text).color = Palette.DmgMedium; ((TMP_Text)text).fontSize = 36f; } else { ((Graphic)text).color = Palette.DmgSmall; ((TMP_Text)text).fontSize = 28f; } ((Component)this).transform.position = start; } private void LateUpdate() { //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_004b: 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) //IL_0075: Unknown result type (might be due to invalid IL or missing references) age += Time.deltaTime; float num = age / 1.15f; if (num >= 1f) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } ((Component)this).transform.position = start + Vector3.up * (num * 1.1f); Camera main = Camera.main; if ((Object)(object)main != (Object)null) { ((Component)this).transform.rotation = ((Component)main).transform.rotation; } if ((Object)(object)text != (Object)null) { ((TMP_Text)text).alpha = 1f - num * num; } } } [BepInPlugin("com.riggola.anotherenemyhealthbars", "AnotherEnemyHealthBars", "1.1.3")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.riggola.anotherenemyhealthbars"; public const string Name = "AnotherEnemyHealthBars"; public const string Version = "1.1.3"; internal static ManualLogSource Log; internal static ConfigEntry HeightOffset; internal static ConfigEntry DisplaySeconds; internal static ConfigEntry FadeDistance; internal static ConfigEntry ShowOnGrab; internal static ConfigEntry ShowDamageNumbers; internal static ConfigEntry AlwaysVisible; internal static ConfigEntry RequireLineOfSight; internal static ConfigEntry BarScale; internal static ConfigEntry DamageNumberScale; internal static ConfigEntry BarColorHigh; internal static ConfigEntry BarColorLow; internal static ConfigEntry BarBackground; internal static ConfigEntry TextColor; internal static ConfigEntry DamageColorSmall; internal static ConfigEntry DamageColorMedium; internal static ConfigEntry DamageColorLarge; private void Awake() { //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_02a1: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; HeightOffset = ((BaseUnityPlugin)this).Config.Bind("Bar", "HeightOffset", 0.6f, "Extra height (meters) added above the auto-detected top of the enemy."); DisplaySeconds = ((BaseUnityPlugin)this).Config.Bind("Bar", "DisplaySeconds", 8f, "How long the bar stays visible after the enemy was last hit or grabbed."); FadeDistance = ((BaseUnityPlugin)this).Config.Bind("Bar", "FadeDistance", 40f, "Distance (meters) at which the bar fully fades out."); ShowOnGrab = ((BaseUnityPlugin)this).Config.Bind("Bar", "ShowOnGrab", true, "Also show the bar while you are grabbing the enemy."); AlwaysVisible = ((BaseUnityPlugin)this).Config.Bind("Bar", "AlwaysVisible", false, "Keep every enemy's bar visible at all times (ignores DisplaySeconds)."); RequireLineOfSight = ((BaseUnityPlugin)this).Config.Bind("Bar", "RequireLineOfSight", true, "Hide the bar when a wall or solid object blocks direct view to the enemy."); ShowDamageNumbers = ((BaseUnityPlugin)this).Config.Bind("Damage Numbers", "Enabled", true, "Show floating damage numbers when an enemy is hit."); BarScale = ((BaseUnityPlugin)this).Config.Bind("Size", "BarScale", 1f, new ConfigDescription("Overall size multiplier for the health bar (and its text). 1 = default.", (AcceptableValueBase)(object)new AcceptableValueRange(0.25f, 5f), Array.Empty())); DamageNumberScale = ((BaseUnityPlugin)this).Config.Bind("Size", "DamageNumberScale", 1f, new ConfigDescription("Size multiplier for the floating damage numbers. 1 = default.", (AcceptableValueBase)(object)new AcceptableValueRange(0.25f, 5f), Array.Empty())); BarColorHigh = ((BaseUnityPlugin)this).Config.Bind("Colors", "BarColorHigh", "#33D933", "Bar color at full health. Hex #RRGGBB or #RRGGBBAA."); BarColorLow = ((BaseUnityPlugin)this).Config.Bind("Colors", "BarColorLow", "#D91A1A", "Bar color at (near) zero health. The fill blends between this and BarColorHigh. Hex #RRGGBB or #RRGGBBAA."); BarBackground = ((BaseUnityPlugin)this).Config.Bind("Colors", "BarBackground", "#000000A6", "Bar background / frame color. The alpha channel sets its transparency. Hex #RRGGBB or #RRGGBBAA."); TextColor = ((BaseUnityPlugin)this).Config.Bind("Colors", "TextColor", "#FFFFFF", "Color of the \"current / max\" text on the bar. Hex #RRGGBB or #RRGGBBAA."); DamageColorSmall = ((BaseUnityPlugin)this).Config.Bind("Damage Numbers", "ColorSmall", "#FF8C26", "Color of small hits (damage < 20). Hex #RRGGBB or #RRGGBBAA."); DamageColorMedium = ((BaseUnityPlugin)this).Config.Bind("Damage Numbers", "ColorMedium", "#FFCC33", "Color of medium hits (damage 20-49). Hex #RRGGBB or #RRGGBBAA."); DamageColorLarge = ((BaseUnityPlugin)this).Config.Bind("Damage Numbers", "ColorLarge", "#FF4033", "Color of large hits (damage >= 50). Hex #RRGGBB or #RRGGBBAA."); Palette.Refresh(); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { Palette.Refresh(); }; new Harmony("com.riggola.anotherenemyhealthbars").PatchAll(typeof(Hooks)); Log.LogInfo((object)"AnotherEnemyHealthBars 1.1.3 loaded."); } } internal static class Palette { internal static Color BarHigh = new Color(0.2f, 0.85f, 0.2f); internal static Color BarLow = new Color(0.85f, 0.1f, 0.1f); internal static Color Background = new Color(0f, 0f, 0f, 0.65f); internal static Color Text = Color.white; internal static Color DmgSmall = new Color(1f, 0.55f, 0.15f); internal static Color DmgMedium = new Color(1f, 0.8f, 0.2f); internal static Color DmgLarge = new Color(1f, 0.25f, 0.2f); internal static void Refresh() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) BarHigh = Parse(Plugin.BarColorHigh.Value, BarHigh); BarLow = Parse(Plugin.BarColorLow.Value, BarLow); Background = Parse(Plugin.BarBackground.Value, Background); Text = Parse(Plugin.TextColor.Value, Text); DmgSmall = Parse(Plugin.DamageColorSmall.Value, DmgSmall); DmgMedium = Parse(Plugin.DamageColorMedium.Value, DmgMedium); DmgLarge = Parse(Plugin.DamageColorLarge.Value, DmgLarge); } private static Color Parse(string hex, Color fallback) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); if (!ColorUtility.TryParseHtmlString(hex, ref result)) { return fallback; } return result; } } [HarmonyPatch] internal static class Hooks { [HarmonyPatch(typeof(EnemyHealth), "Awake")] [HarmonyPostfix] private static void Attach(EnemyHealth __instance) { if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } [HarmonyPatch(typeof(EnemyHealth), "HurtRPC")] [HarmonyPostfix] private static void OnHurt(EnemyHealth __instance, int _damage) { if (_damage > 0 && !((Object)(object)__instance == (Object)null)) { HealthBarView healthBarView = ((Component)__instance).GetComponent(); if ((Object)(object)healthBarView == (Object)null) { healthBarView = ((Component)__instance).gameObject.AddComponent(); } healthBarView.ObserveDamage(_damage); healthBarView.Reveal(); if (Plugin.ShowDamageNumbers.Value) { healthBarView.PopDamage(_damage); } } } [HarmonyPatch(typeof(EnemyHealth), "Death")] [HarmonyPostfix] private static void OnDeath(EnemyHealth __instance) { HealthBarView component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }