Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of WiresEnemyHUD v0.4.0
EnemyHudRework.dll
Decompiled 2 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; 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.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("EnemyHudRework")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EnemyHudRework")] [assembly: AssemblyTitle("EnemyHudRework")] [assembly: AssemblyVersion("1.0.0.0")] [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 EnemyHudRework { [BepInPlugin("kajetan.valheim.enemyhudrework", "Wire's Enemy HUD", "0.4.0")] public sealed class EnemyHudReworkPlugin : BaseUnityPlugin { public enum NameColorMode { Pastel, Normal, None } public enum HealthDisplayMode { CurrentHP, CurrentHPMaxHP, Percentage, None } public enum BossHealthTextPosition { Tracked, Centered } public enum BossNameColorMode { Pastel, Vanilla, White } private enum HudKind { Enemy, Boss, Player } private sealed class ConfigurationManagerAttributes { public int Order { get; set; } public Func<bool> ReadOnlyProvider { get; set; } public bool ReadOnly { get { if (ReadOnlyProvider != null) { return ReadOnlyProvider(); } return false; } } } private sealed class EnemyUiState { public Character Character; public BaseAI Ai; public GameObject Gui; public HudKind Kind; public bool IsDebug; public Graphic NameGraphic; public TMP_Text NameText; public RectTransform NameRect; public Vector2 NameOriginalPosition; public string OriginalNameText; public Color NormalNameColor; public GameObject HealthValueObject; public TMP_Text HealthValueText; public RectTransform HealthValueRect; public float HealthValueBaseFontSize; public GameObject AlertedIcon; public GameObject AwareIcon; public RectTransform HealthRect; public Vector2 HealthOriginalPosition; public Vector3 HealthOriginalScale; public float HealthOriginalHeight; public RectTransform HealthFastFill; public RectTransform HealthSlowFill; public RectTransform HealthFriendlyFill; public float HealthFastOriginalHeight; public float HealthSlowOriginalHeight; public float HealthFriendlyOriginalHeight; public GameObject StaggerRoot; public RectTransform StaggerRect; public GuiBar StaggerFast; public GuiBar StaggerBackground; public Image FlashTop; public Image FlashBottom; public Image FlashLeft; public Image FlashRight; public RectTransform Level2; public RectTransform Level3; public Vector2 Level2Original; public Vector2 Level3Original; public bool HasLevel2; public bool HasLevel3; public float HideTimer = 1f; public float LastStaggerPercentage; public bool WasStaggering; public float FlashStarted = -999f; public float FlashUntil = -999f; } private sealed class StaggerSyncState { public float LastSent = -1f; public float NextSendTime; } [HarmonyPatch(typeof(EnemyHud), "ShowHud")] private static class EnemyHudShowHudPatch { private static void Postfix(EnemyHud __instance, Character c, bool isMount) { if ((Object)(object)Instance != (Object)null) { Instance.SetupHud(__instance, c, isMount); } } } [HarmonyPatch(typeof(EnemyHud), "UpdateHuds")] private static class EnemyHudUpdateHudsPatch { private static void Postfix(EnemyHud __instance, Player player, Sadle sadle, float dt) { if ((Object)(object)Instance != (Object)null) { Instance.UpdateEnemyHuds(player, dt); } } } [HarmonyPatch(typeof(EnemyHud), "LateUpdate")] private static class EnemyHudLateUpdatePatch { private static void Postfix(EnemyHud __instance) { if ((Object)(object)Instance != (Object)null) { Instance.UpdateDebugHuds(__instance); } } } [HarmonyPatch(typeof(Character), "UpdateStagger")] private static class CharacterUpdateStaggerPatch { private static void Postfix(Character __instance) { if ((Object)(object)Instance != (Object)null) { Instance.SyncOwnedStagger(__instance); } } } public const string PluginGuid = "kajetan.valheim.enemyhudrework"; public const string PluginName = "Wire's Enemy HUD"; public const string PluginVersion = "0.4.0"; private const string StaggerZdoKey = "EnemyHudRework_Stagger"; private const float HealthHeightMultiplier = 2f; private const float PlayerLikeHideDelay = 1f; internal static EnemyHudReworkPlugin Instance; private Harmony _harmony; private ConfigEntry<NameColorMode> _nameColorMode; private ConfigEntry<bool> _uppercaseNames; private ConfigEntry<bool> _doubleEnemyHealthBar; private ConfigEntry<string> _enemyHealthDisplayMode; private ConfigEntry<string> _bossHealthDisplayMode; private ConfigEntry<BossHealthTextPosition> _bossHealthTextPosition; private ConfigEntry<BossNameColorMode> _bossNameColorMode; private ConfigEntry<bool> _doublePlayerHealthBar; private ConfigEntry<string> _playerHealthDisplayMode; private ConfigEntry<bool> _debugBossHealthBar; private ConfigEntry<bool> _debugSeeOwnHealthBar; private ConfigEntry<bool> _staggerBarEnabled; private ConfigEntry<string> _staggerColor; private ConfigEntry<float> _staggerVerticalOffset; private ConfigEntry<float> _starVerticalOffset; private ConfigEntry<bool> _hideForNonStaggerable; private ConfigEntry<bool> _syncStaggerForMultiplayer; private ConfigEntry<float> _syncInterval; private ConfigEntry<float> _syncMinimumDelta; private readonly Dictionary<Character, EnemyUiState> _states = new Dictionary<Character, EnemyUiState>(); private readonly Dictionary<int, StaggerSyncState> _syncStates = new Dictionary<int, StaggerSyncState>(); private GameObject _debugBossGui; private EnemyUiState _debugBossState; private static readonly FieldInfo EnemyHudHudsField = AccessTools.Field(typeof(EnemyHud), "m_huds"); private static readonly Type HudDataType = AccessTools.Inner(typeof(EnemyHud), "HudData"); private static readonly FieldInfo HudDataGuiField = ((HudDataType != null) ? AccessTools.Field(HudDataType, "m_gui") : null); private static readonly MethodInfo EnemyHudShowHudMethod = AccessTools.Method(typeof(EnemyHud), "ShowHud", (Type[])null, (Type[])null); private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Instance = this; BindConfig(); _harmony = new Harmony("kajetan.valheim.enemyhudrework"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Wire's Enemy HUD 0.4.0 loaded."); } private void OnDestroy() { DestroyDebugBossHud(); if (_harmony != null) { _harmony.UnpatchSelf(); } Instance = null; } private void BindConfig() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Expected O, but got Unknown _nameColorMode = ((BaseUnityPlugin)this).Config.Bind<NameColorMode>("Features", "NameAwarenessColors", NameColorMode.Pastel, "Pastel = softer readable state colors; Normal = vanilla indicator colors; None = vanilla awareness icons and normal name color."); _uppercaseNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "UppercaseEnemyNames", true, "Force normal enemy names to uppercase."); ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition("General", "Enabled")); ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition("Features", "HealthNumberMode")); ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition("Features", "ShowMaxHealth")); ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition("Features", "DoubleHealthBarThickness")); ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition("Features", "HealthDisplay")); _enemyHealthDisplayMode = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Health Bar", "Health display", "Current HP/Max HP", new ConfigDescription("Enemy health text.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[4] { "Current HP", "Current HP/Max HP", "Percentage", "None" }), Array.Empty<object>())); _doubleEnemyHealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemy Health Bar", "Double size", true, "Double the vertical thickness of normal enemy health bars."); _bossHealthDisplayMode = ((BaseUnityPlugin)this).Config.Bind<string>("Boss Health Bar", "Health display", "Current HP/Max HP", new ConfigDescription("Boss health text.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[4] { "Current HP", "Current HP/Max HP", "Percentage", "None" }), new object[1] { new ConfigurationManagerAttributes { Order = 300 } })); ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition("Boss Health Bar", "Double size")); _bossHealthTextPosition = ((BaseUnityPlugin)this).Config.Bind<BossHealthTextPosition>("Boss Health Bar", "Health counter position", BossHealthTextPosition.Tracked, new ConfigDescription("Tracked = right-aligned to the end of the current boss-health fill; Centered = fixed at the center of the boss bar.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 290, ReadOnlyProvider = () => _bossHealthDisplayMode != null && _bossHealthDisplayMode.Value == "None" } })); _bossNameColorMode = ((BaseUnityPlugin)this).Config.Bind<BossNameColorMode>("Boss Health Bar", "Boss name color", BossNameColorMode.Pastel, new ConfigDescription("Pastel = match the boss health-bar pink; Vanilla = vanilla saturated red; White = white.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 280 } })); _playerHealthDisplayMode = ((BaseUnityPlugin)this).Config.Bind<string>("Player Health Bar", "Health display", "Current HP/Max HP", new ConfigDescription("Multiplayer player health text.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[4] { "Current HP", "Current HP/Max HP", "Percentage", "None" }), Array.Empty<object>())); _doublePlayerHealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("Player Health Bar", "Double size", true, "Double the vertical thickness of multiplayer player health bars."); _staggerBarEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Stagger Bar", "Enabled", true, "Add a vanilla-styled enemy stagger bar."); _staggerColor = ((BaseUnityPlugin)this).Config.Bind<string>("Stagger Bar", "Color", "#E75D16", "Player-stagger orange."); _staggerVerticalOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Stagger Bar", "VerticalOffset", 8f, "Base spacing below the original health-bar center."); _starVerticalOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Stagger Bar", "StarVerticalOffset", 8f, "Base downward star offset while stagger UI is visible."); _hideForNonStaggerable = ((BaseUnityPlugin)this).Config.Bind<bool>("Stagger Bar", "HideForNonStaggerableEnemies", true, "Hide for creatures with no stagger threshold."); _syncStaggerForMultiplayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Multiplayer", "SyncStaggerPercentage", true, "Sync stagger through enemy ZDO. Install on server/host and clients."); _syncInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Multiplayer", "SyncIntervalSeconds", 0.1f, "Maximum sync frequency per owned enemy."); _syncMinimumDelta = ((BaseUnityPlugin)this).Config.Bind<float>("Multiplayer", "SyncMinimumDelta", 0.01f, "Minimum stagger change before another sync."); _debugBossHealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "(Debug) Player boss health bar", false, "Show the game's actual boss HUD prefab, driven by your current/max health, for UI testing."); _debugSeeOwnHealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "See your own nameplate", false, "Show your own real multiplayer player HUD above your character for UI testing."); } internal void SetupHud(EnemyHud enemyHud, Character character, bool isMount) { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemyHud == (Object)null || (Object)(object)character == (Object)null || isMount) { return; } GameObject hudGui = GetHudGui(enemyHud, character); if ((Object)(object)hudGui == (Object)null) { return; } if (_states.TryGetValue(character, out var value)) { if (value != null && (Object)(object)value.Gui == (Object)(object)hudGui) { return; } DestroyState(value); _states.Remove(character); } EnemyUiState enemyUiState = new EnemyUiState { Character = character, Ai = ((Component)character).GetComponent<BaseAI>(), Gui = hudGui, Kind = (character.IsBoss() ? HudKind.Boss : (character.IsPlayer() ? HudKind.Player : HudKind.Enemy)) }; Transform val = hudGui.transform.Find("Name"); if ((Object)(object)val != (Object)null) { enemyUiState.NameGraphic = ((Component)val).GetComponent<Graphic>(); enemyUiState.NameText = ((Component)val).GetComponent<TMP_Text>(); enemyUiState.NameRect = (RectTransform)(object)((val is RectTransform) ? val : null); if ((Object)(object)enemyUiState.NameRect != (Object)null) { enemyUiState.NameOriginalPosition = enemyUiState.NameRect.anchoredPosition; } if ((Object)(object)enemyUiState.NameText != (Object)null) { enemyUiState.OriginalNameText = enemyUiState.NameText.text; } if ((Object)(object)enemyUiState.NameGraphic != (Object)null) { enemyUiState.NormalNameColor = enemyUiState.NameGraphic.color; } } Transform val2 = hudGui.transform.Find("Alerted"); Transform val3 = hudGui.transform.Find("Aware"); enemyUiState.AlertedIcon = (((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : null); enemyUiState.AwareIcon = (((Object)(object)val3 != (Object)null) ? ((Component)val3).gameObject : null); Transform val4 = hudGui.transform.Find("Health"); if ((Object)(object)val4 != (Object)null) { enemyUiState.HealthRect = (RectTransform)(object)((val4 is RectTransform) ? val4 : null); if ((Object)(object)enemyUiState.HealthRect != (Object)null) { enemyUiState.HealthOriginalPosition = enemyUiState.HealthRect.anchoredPosition; enemyUiState.HealthOriginalScale = ((Transform)enemyUiState.HealthRect).localScale; Rect rect = enemyUiState.HealthRect.rect; enemyUiState.HealthOriginalHeight = ((Rect)(ref rect)).height; CaptureHealthFill(val4, "health_fast", out enemyUiState.HealthFastFill, out enemyUiState.HealthFastOriginalHeight); CaptureHealthFill(val4, "health_slow", out enemyUiState.HealthSlowFill, out enemyUiState.HealthSlowOriginalHeight); CaptureHealthFill(val4, "health_fast_friendly", out enemyUiState.HealthFriendlyFill, out enemyUiState.HealthFriendlyOriginalHeight); } } ref RectTransform level = ref enemyUiState.Level2; Transform obj = hudGui.transform.Find("level_2"); level = (RectTransform)(object)((obj is RectTransform) ? obj : null); ref RectTransform level2 = ref enemyUiState.Level3; Transform obj2 = hudGui.transform.Find("level_3"); level2 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); if ((Object)(object)enemyUiState.Level2 != (Object)null) { enemyUiState.HasLevel2 = true; enemyUiState.Level2Original = enemyUiState.Level2.anchoredPosition; } if ((Object)(object)enemyUiState.Level3 != (Object)null) { enemyUiState.HasLevel3 = true; enemyUiState.Level3Original = enemyUiState.Level3.anchoredPosition; } if (enemyUiState.Kind == HudKind.Enemy || enemyUiState.Kind == HudKind.Player) { CreateStaggerBar(enemyUiState); } CreateHealthValue(enemyUiState); ApplyHealthBarScale(enemyUiState); if (enemyUiState.Kind == HudKind.Enemy || enemyUiState.Kind == HudKind.Player) { ApplyStaggerPosition(enemyUiState); } if (enemyUiState.Kind == HudKind.Boss) { ApplyBossNameColor(enemyUiState); } UpdateHealthValue(enemyUiState); _states[character] = enemyUiState; } internal void UpdateEnemyHuds(Player localPlayer, float dt) { List<Character> list = null; foreach (KeyValuePair<Character, EnemyUiState> state in _states) { Character key = state.Key; EnemyUiState value = state.Value; if ((Object)(object)key == (Object)null || value == null || (Object)(object)value.Gui == (Object)null) { if (list == null) { list = new List<Character>(); } list.Add(key); continue; } bool isEnemy = (Object)(object)localPlayer == (Object)null || BaseAI.IsEnemy((Character)(object)localPlayer, key); ApplyHealthBarScale(value); if (value.Kind == HudKind.Enemy) { UpdateStatusName(value, isEnemy); } else if (value.Kind == HudKind.Boss) { ApplyBossNameColor(value); } if (value.Kind == HudKind.Enemy || value.Kind == HudKind.Player) { ApplyStaggerPosition(value); UpdateStaggerBar(value, isEnemy, dt); } UpdateHealthValue(value); } if (list == null) { return; } foreach (Character item in list) { if (_states.TryGetValue(item, out var value2)) { DestroyState(value2); } _states.Remove(item); } } private void UpdateStatusName(EnemyUiState state, bool isEnemy) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) if (state == null || state.Kind != HudKind.Enemy) { return; } if ((Object)(object)state.NameText != (Object)null) { string text = state.OriginalNameText ?? state.NameText.text ?? ""; state.NameText.text = (_uppercaseNames.Value ? text.ToUpperInvariant() : text); } if ((Object)(object)state.NameGraphic == (Object)null) { return; } if ((Object)(object)state.Ai == (Object)null || _nameColorMode.Value == NameColorMode.None) { state.NameGraphic.color = state.NormalNameColor; return; } if ((Object)(object)state.AlertedIcon != (Object)null) { state.AlertedIcon.SetActive(false); } if ((Object)(object)state.AwareIcon != (Object)null) { state.AwareIcon.SetActive(false); } bool flag = _nameColorMode.Value == NameColorMode.Pastel; Color color; Color color2; if (isEnemy) { color = Color32.op_Implicit(flag ? new Color32(byte.MaxValue, (byte)122, (byte)118, byte.MaxValue) : new Color32((byte)242, (byte)16, (byte)12, byte.MaxValue)); color2 = Color32.op_Implicit(flag ? new Color32(byte.MaxValue, (byte)229, (byte)128, byte.MaxValue) : new Color32((byte)254, (byte)219, (byte)0, byte.MaxValue)); } else { color = Color32.op_Implicit(flag ? new Color32((byte)131, (byte)229, (byte)167, byte.MaxValue) : new Color32((byte)24, (byte)201, (byte)98, byte.MaxValue)); color2 = Color32.op_Implicit(flag ? new Color32((byte)134, (byte)190, byte.MaxValue, byte.MaxValue) : new Color32((byte)30, (byte)134, byte.MaxValue, byte.MaxValue)); } if (state.Ai.IsAlerted()) { state.NameGraphic.color = color; } else if (state.Ai.HaveTarget()) { state.NameGraphic.color = color2; } else { state.NameGraphic.color = state.NormalNameColor; } } private void ApplyBossNameColor(EnemyUiState state) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_00af: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00e2: Unknown result type (might be due to invalid IL or missing references) if (state == null || state.Kind != HudKind.Boss || (Object)(object)state.NameGraphic == (Object)null) { return; } switch (_bossNameColorMode.Value) { case BossNameColorMode.White: state.NameGraphic.color = Color.white; return; case BossNameColorMode.Vanilla: state.NameGraphic.color = state.NormalNameColor; return; } Color color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)90, (byte)167, byte.MaxValue)); if ((Object)(object)state.HealthRect != (Object)null) { Transform val = ((Transform)state.HealthRect).Find("health_fast"); GuiBar val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<GuiBar>() : null); if ((Object)(object)val2 != (Object)null) { Color color2 = val2.GetColor(); if (!(color2.r > 0.95f) || !(color2.g > 0.95f) || !(color2.b > 0.95f)) { color = color2; } } } color.a = state.NormalNameColor.a; state.NameGraphic.color = color; } private void CreateHealthValue(EnemyUiState state) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if (state == null || (Object)(object)state.NameText == (Object)null || (Object)(object)state.NameText.transform.parent == (Object)null) { return; } TMP_Text val = state.NameText; EnemyHud instance = EnemyHud.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_baseHud != (Object)null) { Transform val2 = instance.m_baseHud.transform.Find("Name"); TMP_Text val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<TMP_Text>() : null); if ((Object)(object)val3 != (Object)null) { val = val3; } } GameObject val4 = Object.Instantiate<GameObject>(((Component)val).gameObject, state.NameText.transform.parent, false); ((Object)val4).name = "HealthValue"; state.HealthValueObject = val4; state.HealthValueText = val4.GetComponent<TMP_Text>(); ref RectTransform healthValueRect = ref state.HealthValueRect; Transform transform = val4.transform; healthValueRect = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)state.HealthValueText != (Object)null) { state.HealthValueText.text = ""; ((Graphic)state.HealthValueText).color = Color.white; state.HealthValueText.alignment = (TextAlignmentOptions)514; ((Graphic)state.HealthValueText).raycastTarget = false; state.HealthValueBaseFontSize = state.HealthValueText.fontSize; } val4.SetActive(false); } private string GetHealthDisplayMode(EnemyUiState state) { if (state == null) { return "Current HP/Max HP"; } return state.Kind switch { HudKind.Boss => _bossHealthDisplayMode.Value, HudKind.Player => _playerHealthDisplayMode.Value, _ => _enemyHealthDisplayMode.Value, }; } private bool IsDoubleHealthBar(EnemyUiState state) { if (state == null) { return false; } return state.Kind switch { HudKind.Boss => false, HudKind.Player => _doublePlayerHealthBar.Value, _ => _doubleEnemyHealthBar.Value, }; } private void UpdateHealthValue(EnemyUiState state) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_02dd: 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_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) if (state == null || (Object)(object)state.HealthValueObject == (Object)null || (Object)(object)state.HealthValueText == (Object)null || (Object)(object)state.HealthValueRect == (Object)null || (!state.IsDebug && (Object)(object)state.Character == (Object)null)) { return; } string healthDisplayMode = GetHealthDisplayMode(state); bool flag = state.Kind == HudKind.Player && !_doublePlayerHealthBar.Value; if (healthDisplayMode == "None" || flag) { state.HealthValueObject.SetActive(false); if ((Object)(object)state.NameRect != (Object)null) { state.NameRect.anchoredPosition = state.NameOriginalPosition; } return; } float num = (((Object)(object)state.Character != (Object)null) ? Mathf.Max(0f, state.Character.GetHealth()) : 0f); float num2 = (((Object)(object)state.Character != (Object)null) ? Mathf.Max(1f, state.Character.GetMaxHealth()) : 1f); if (healthDisplayMode == "Percentage") { state.HealthValueText.text = Mathf.Clamp(Mathf.RoundToInt(num / num2 * 100f), 0, 100) + "%"; } else { int num3 = Mathf.CeilToInt(num); int num4 = Mathf.CeilToInt(num2); state.HealthValueText.text = ((healthDisplayMode == "Current HP/Max HP") ? (num3 + "/" + num4) : num3.ToString()); } state.HealthValueObject.SetActive(true); ((Graphic)state.HealthValueText).color = Color.white; if (state.Kind == HudKind.Boss && (Object)(object)state.HealthRect != (Object)null) { UpdateBossHealthValueLayout(state, Mathf.Clamp01(num / num2)); } else if (IsDoubleHealthBar(state) && (Object)(object)state.HealthRect != (Object)null) { if ((Object)(object)state.NameRect != (Object)null) { state.NameRect.anchoredPosition = state.NameOriginalPosition; } state.HealthValueRect.anchorMin = state.HealthRect.anchorMin; state.HealthValueRect.anchorMax = state.HealthRect.anchorMax; state.HealthValueRect.pivot = state.HealthRect.pivot; state.HealthValueRect.anchoredPosition = state.HealthRect.anchoredPosition; state.HealthValueRect.sizeDelta = state.HealthRect.sizeDelta; ((Transform)state.HealthValueRect).localScale = Vector3.one; state.HealthValueText.fontSize = state.HealthValueBaseFontSize * 0.648f; state.HealthValueText.alignment = (TextAlignmentOptions)514; } else if ((Object)(object)state.NameRect != (Object)null) { state.HealthValueRect.anchorMin = state.NameRect.anchorMin; state.HealthValueRect.anchorMax = state.NameRect.anchorMax; state.HealthValueRect.pivot = state.NameRect.pivot; state.HealthValueRect.sizeDelta = state.NameRect.sizeDelta; ((Transform)state.HealthValueRect).localScale = Vector3.one; state.HealthValueText.fontSize = state.HealthValueBaseFontSize * 0.738f; state.HealthValueText.alignment = (TextAlignmentOptions)514; float num5 = 5f; float num6 = (((Object)(object)state.NameText != (Object)null) ? state.NameText.preferredWidth : 0f); float preferredWidth = state.HealthValueText.preferredWidth; state.NameRect.anchoredPosition = state.NameOriginalPosition + Vector2.left * ((preferredWidth + num5) * 0.5f); state.HealthValueRect.anchoredPosition = state.NameOriginalPosition + Vector2.right * ((num6 + num5) * 0.5f); } } private void UpdateBossHealthValueLayout(EnemyUiState state, float healthPercentage) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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) if (state == null || (Object)(object)state.HealthRect == (Object)null || (Object)(object)state.HealthValueRect == (Object)null || (Object)(object)state.HealthValueText == (Object)null) { return; } if ((Object)(object)state.NameRect != (Object)null) { state.NameRect.anchoredPosition = state.NameOriginalPosition; } ((Transform)state.HealthValueRect).localScale = Vector3.one; state.HealthValueText.fontSize = state.HealthValueBaseFontSize * 0.738f; float num = Mathf.Max(80f, state.HealthValueText.preferredWidth + 12f); float num2 = Mathf.Max(state.HealthValueText.preferredHeight, state.HealthValueText.fontSize * 1.2f); state.HealthValueRect.sizeDelta = new Vector2(num, num2); Rect rect = state.HealthRect.rect; bool flag = _bossHealthTextPosition.Value == BossHealthTextPosition.Tracked; float num3 = ((Rect)(ref rect)).center.x; if (flag) { if ((Object)(object)state.HealthFastFill != (Object)null) { Rect rect2 = state.HealthFastFill.rect; Vector3 val = ((Transform)state.HealthFastFill).TransformPoint(new Vector3(((Rect)(ref rect2)).xMax, ((Rect)(ref rect2)).center.y, 0f)); num3 = ((Transform)state.HealthRect).InverseTransformPoint(val).x; } else { num3 = Mathf.Lerp(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).xMax, Mathf.Clamp01(healthPercentage)); } } float num4 = ((Rect)(ref rect)).yMin - num2 * 0.55f - 2f; state.HealthValueRect.pivot = (flag ? new Vector2(1f, 0.5f) : new Vector2(0.5f, 0.5f)); state.HealthValueText.alignment = (TextAlignmentOptions)(flag ? 516 : 514); Vector3 position = ((Transform)state.HealthRect).TransformPoint(new Vector3(num3, num4, 0f)); ((Transform)state.HealthValueRect).position = position; } private static void CaptureHealthFill(Transform healthRoot, string childName, out RectTransform fill, out float originalHeight) { //IL_0052: 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) fill = null; originalHeight = 0f; if (!((Object)(object)healthRoot == (Object)null)) { Transform val = healthRoot.Find(childName); GuiBar val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<GuiBar>() : null); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.m_bar == (Object)null)) { fill = val2.m_bar; Rect rect = fill.rect; originalHeight = ((Rect)(ref rect)).height; } } } private float GetHealthFillBaseHeight(EnemyUiState state) { if (state == null) { return 0f; } if (state.HealthFastOriginalHeight > 0f) { return state.HealthFastOriginalHeight; } if (state.HealthSlowOriginalHeight > 0f) { return state.HealthSlowOriginalHeight; } if (state.HealthFriendlyOriginalHeight > 0f) { return state.HealthFriendlyOriginalHeight; } return Mathf.Max(0f, state.HealthOriginalHeight * 0.5f); } private static void SetFillHeight(RectTransform fill, float originalHeight, float multiplier) { if (!((Object)(object)fill == (Object)null) && !(originalHeight <= 0f)) { fill.SetSizeWithCurrentAnchors((Axis)1, originalHeight * multiplier); } } private void ApplyHealthBarScale(EnemyUiState state) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (state != null && !((Object)(object)state.HealthRect == (Object)null)) { float multiplier = (IsDoubleHealthBar(state) ? 2f : 1f); float num = (IsDoubleHealthBar(state) ? (GetHealthFillBaseHeight(state) * 1f) : 0f); ((Transform)state.HealthRect).localScale = state.HealthOriginalScale; state.HealthRect.SetSizeWithCurrentAnchors((Axis)1, state.HealthOriginalHeight + num); SetFillHeight(state.HealthFastFill, state.HealthFastOriginalHeight, multiplier); SetFillHeight(state.HealthSlowFill, state.HealthSlowOriginalHeight, multiplier); SetFillHeight(state.HealthFriendlyFill, state.HealthFriendlyOriginalHeight, multiplier); float extraHealthHeight = GetExtraHealthHeight(state); state.HealthRect.anchoredPosition = state.HealthOriginalPosition + Vector2.down * (extraHealthHeight * 0.5f); } } private float GetExtraHealthHeight(EnemyUiState state) { if (state == null || (Object)(object)state.HealthRect == (Object)null || !IsDoubleHealthBar(state)) { return 0f; } return Mathf.Abs(GetHealthFillBaseHeight(state) * 1f * state.HealthOriginalScale.y); } private void CreateStaggerBar(EnemyUiState state) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if (state == null || (Object)(object)state.Gui == (Object)null || (Object)(object)state.HealthRect == (Object)null) { return; } GameObject val = Object.Instantiate<GameObject>(((Component)state.HealthRect).gameObject, ((Transform)state.HealthRect).parent, false); ((Object)val).name = "Stagger"; state.StaggerRoot = val; ref RectTransform staggerRect = ref state.StaggerRect; Transform transform = val.transform; staggerRect = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)state.StaggerRect != (Object)null) { ((Transform)state.StaggerRect).localScale = state.HealthOriginalScale; } Transform val2 = val.transform.Find("health_fast"); Transform val3 = val.transform.Find("health_slow"); Transform val4 = val.transform.Find("health_fast_friendly"); if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(false); } if ((Object)(object)val2 != (Object)null) { state.StaggerFast = ((Component)val2).GetComponent<GuiBar>(); if ((Object)(object)state.StaggerFast != (Object)null) { state.StaggerFast.SetColor(ParseColor(_staggerColor.Value, Color32.op_Implicit(new Color32((byte)231, (byte)93, (byte)22, byte.MaxValue)))); CopyPlayerStaggerBarBehavior(state.StaggerFast); state.StaggerFast.SetValue(0f); } } if ((Object)(object)val3 != (Object)null) { state.StaggerBackground = ((Component)val3).GetComponent<GuiBar>(); if ((Object)(object)state.StaggerBackground != (Object)null) { ((Component)state.StaggerBackground).gameObject.SetActive(false); } } Graphic[] componentsInChildren = val.GetComponentsInChildren<Graphic>(true); foreach (Graphic val5 in componentsInChildren) { if (!((Object)(object)val5 == (Object)null) && (!((Object)(object)state.StaggerFast != (Object)null) || !((Component)val5).transform.IsChildOf(((Component)state.StaggerFast).transform)) && (!((Object)(object)state.StaggerBackground != (Object)null) || !((Component)val5).transform.IsChildOf(((Component)state.StaggerBackground).transform)) && !(val5 is Image)) { ((Component)val5).gameObject.SetActive(false); } } CreateFlashBorder(state); val.SetActive(false); } private static void CopyPlayerStaggerBarBehavior(GuiBar target) { if (!((Object)(object)target == (Object)null)) { Hud instance = Hud.instance; GuiBar val = (((Object)(object)instance != (Object)null) ? instance.m_staggerProgress : null); if ((Object)(object)val == (Object)null) { target.m_smoothDrain = false; target.m_smoothFill = false; target.m_changeDelay = 0f; } else { target.m_smoothDrain = val.m_smoothDrain; target.m_smoothFill = val.m_smoothFill; target.m_smoothSpeed = val.m_smoothSpeed; target.m_changeDelay = val.m_changeDelay; } } } private void ApplyStaggerPosition(EnemyUiState state) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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 (state != null && !((Object)(object)state.StaggerRect == (Object)null)) { state.StaggerRect.anchoredPosition = state.HealthOriginalPosition + Vector2.down * (_staggerVerticalOffset.Value + GetExtraHealthHeight(state)); } } private void UpdateStaggerBar(EnemyUiState state, bool isEnemy, float dt) { if (state == null || (Object)(object)state.Character == (Object)null) { return; } bool flag = state.Kind == HudKind.Player || (state.Kind == HudKind.Enemy && isEnemy); if (!_staggerBarEnabled.Value || (Object)(object)state.StaggerRoot == (Object)null || !flag) { SetStaggerLayoutActive(state, active: false); return; } bool flag2 = state.Character.m_staggerDamageFactor > 0f; if (_hideForNonStaggerable.Value && !flag2) { SetStaggerLayoutActive(state, active: false); return; } float num = Mathf.Clamp01(GetDisplayStaggerPercentage(state.Character)); if (num > 0f) { state.HideTimer = 0f; } else { state.HideTimer += dt; } bool active = num > 0f || state.HideTimer < 1f; SetStaggerLayoutActive(state, active); if ((Object)(object)state.StaggerFast != (Object)null) { state.StaggerFast.SetValue(num); } bool flag3 = state.Character.IsStaggering(); bool num2 = num >= 0.999f && state.LastStaggerPercentage < 0.999f; bool flag4 = flag3 && !state.WasStaggering; if (num2 || flag4) { StartFlash(state); } UpdateFlash(state); state.LastStaggerPercentage = num; state.WasStaggering = flag3; } private void SetStaggerLayoutActive(EnemyUiState state, bool active) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (state != null) { if ((Object)(object)state.StaggerRoot != (Object)null) { state.StaggerRoot.SetActive(active); } float num = (active ? (0f - (Mathf.Abs(_starVerticalOffset.Value) + GetExtraHealthHeight(state))) : 0f); if (state.HasLevel2 && (Object)(object)state.Level2 != (Object)null) { state.Level2.anchoredPosition = state.Level2Original + new Vector2(0f, num); } if (state.HasLevel3 && (Object)(object)state.Level3 != (Object)null) { state.Level3.anchoredPosition = state.Level3Original + new Vector2(0f, num); } } } private void CreateFlashBorder(EnemyUiState state) { //IL_002f: 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_004d: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0123: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) if (state != null && !((Object)(object)state.StaggerRoot == (Object)null)) { Transform transform = state.StaggerRoot.transform; state.FlashTop = CreateBorderPiece(transform, "FlashTop", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 1f), new Vector2(2f, 2f)); state.FlashBottom = CreateBorderPiece(transform, "FlashBottom", new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, -1f), new Vector2(2f, 2f)); state.FlashLeft = CreateBorderPiece(transform, "FlashLeft", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(0f, 0.5f), new Vector2(-1f, 0f), new Vector2(2f, 2f)); state.FlashRight = CreateBorderPiece(transform, "FlashRight", new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(1f, 0.5f), new Vector2(1f, 0f), new Vector2(2f, 2f)); SetFlashAlpha(state, 0f); } } private static Image CreateBorderPiece(Transform parent, string name, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 anchoredPosition, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001b: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = anchorMin; obj.anchorMax = anchorMax; obj.pivot = pivot; obj.anchoredPosition = anchoredPosition; obj.sizeDelta = sizeDelta; Image obj2 = val.AddComponent<Image>(); ((Graphic)obj2).raycastTarget = false; ((Graphic)obj2).color = new Color(1f, 1f, 1f, 0f); val.transform.SetAsLastSibling(); return obj2; } private void StartFlash(EnemyUiState state) { if (state != null) { float playerStaggerFlashDuration = GetPlayerStaggerFlashDuration(); state.FlashStarted = Time.time; state.FlashUntil = Time.time + playerStaggerFlashDuration; } } private static void UpdateFlash(EnemyUiState state) { if (state != null) { float num = state.FlashUntil - state.FlashStarted; if (num <= 0f || Time.time >= state.FlashUntil) { SetFlashAlpha(state, 0f); return; } float num2 = Mathf.Clamp01((Time.time - state.FlashStarted) / num); SetFlashAlpha(state, Mathf.Sin((float)Math.PI * num2)); } } private static void SetFlashAlpha(EnemyUiState state, float alpha) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0082: Unknown result type (might be due to invalid IL or missing references) if (state != null) { Color color = default(Color); ((Color)(ref color))..ctor(1f, 1f, 1f, Mathf.Clamp01(alpha)); if ((Object)(object)state.FlashTop != (Object)null) { ((Graphic)state.FlashTop).color = color; } if ((Object)(object)state.FlashBottom != (Object)null) { ((Graphic)state.FlashBottom).color = color; } if ((Object)(object)state.FlashLeft != (Object)null) { ((Graphic)state.FlashLeft).color = color; } if ((Object)(object)state.FlashRight != (Object)null) { ((Graphic)state.FlashRight).color = color; } } } private static float GetPlayerStaggerFlashDuration() { Hud instance = Hud.instance; Animator val = (((Object)(object)instance != (Object)null) ? instance.m_staggerAnimator : null); if ((Object)(object)val != (Object)null && (Object)(object)val.runtimeAnimatorController != (Object)null) { AnimationClip[] animationClips = val.runtimeAnimatorController.animationClips; if (animationClips != null) { AnimationClip[] array = animationClips; foreach (AnimationClip val2 in array) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name.IndexOf("flash", StringComparison.OrdinalIgnoreCase) >= 0 && val2.length > 0.01f) { return val2.length; } } } } return 0.3f; } private float GetDisplayStaggerPercentage(Character character) { if ((Object)(object)character == (Object)null) { return 0f; } if (!_syncStaggerForMultiplayer.Value) { return character.GetStaggerPercentage(); } ZNetView component = ((Component)character).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid() || component.IsOwner()) { return character.GetStaggerPercentage(); } ZDO zDO = component.GetZDO(); if (zDO == null) { return character.GetStaggerPercentage(); } return Mathf.Clamp01(zDO.GetFloat("EnemyHudRework_Stagger", character.GetStaggerPercentage())); } internal void SyncOwnedStagger(Character character) { if (!_syncStaggerForMultiplayer.Value || (Object)(object)character == (Object)null) { return; } ZNetView component = ((Component)character).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid() || !component.IsOwner()) { return; } ZDO zDO = component.GetZDO(); if (zDO == null) { return; } int instanceID = ((Object)character).GetInstanceID(); if (!_syncStates.TryGetValue(instanceID, out var value)) { value = new StaggerSyncState(); _syncStates[instanceID] = value; } float time = Time.time; if (!(time < value.NextSendTime)) { float num = Mathf.Clamp01(character.GetStaggerPercentage()); float num2 = Mathf.Abs(num - value.LastSent); bool flag = (num <= 0.0001f && value.LastSent > 0.0001f) || (num >= 0.9999f && value.LastSent < 0.9999f); if (value.LastSent < 0f || num2 >= Mathf.Max(0.0001f, _syncMinimumDelta.Value) || flag) { zDO.Set("EnemyHudRework_Stagger", num); value.LastSent = num; } value.NextSendTime = time + Mathf.Max(0.02f, _syncInterval.Value); } } internal void UpdateDebugHuds(EnemyHud enemyHud) { if ((Object)(object)enemyHud == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; EnemyUiState value2; if (_debugSeeOwnHealthBar.Value && (Object)(object)localPlayer != (Object)null) { if (EnemyHudShowHudMethod != null) { EnemyHudShowHudMethod.Invoke(enemyHud, new object[2] { localPlayer, false }); } SetupHud(enemyHud, (Character)(object)localPlayer, isMount: false); if (_states.TryGetValue((Character)(object)localPlayer, out var value) && value != null && (Object)(object)value.Gui != (Object)null) { value.Gui.SetActive(true); ApplyHealthBarScale(value); UpdateHealthValue(value); } } else if ((Object)(object)localPlayer != (Object)null && _states.TryGetValue((Character)(object)localPlayer, out value2) && value2 != null && value2.Kind == HudKind.Player) { enemyHud.RemoveCharacterHud((Character)(object)localPlayer); DestroyState(value2); _states.Remove((Character)(object)localPlayer); } UpdateDebugBossHud(enemyHud); } private void UpdateDebugBossHud(EnemyHud enemyHud) { Player localPlayer = Player.m_localPlayer; if (!_debugBossHealthBar.Value || (Object)(object)localPlayer == (Object)null) { DestroyDebugBossHud(); return; } if ((Object)(object)_debugBossGui == (Object)null || _debugBossState == null) { CreateDebugBossHud(enemyHud, localPlayer); } if (!((Object)(object)_debugBossGui == (Object)null) && _debugBossState != null) { _debugBossState.Character = (Character)(object)localPlayer; _debugBossGui.SetActive(true); if ((Object)(object)_debugBossState.NameText != (Object)null) { _debugBossState.NameText.text = "EVIL " + localPlayer.GetPlayerName().ToUpperInvariant() + " ALTER EGO"; } ApplyBossNameColor(_debugBossState); float healthPercentage = ((Character)localPlayer).GetHealthPercentage(); Transform val = _debugBossGui.transform.Find("Health/health_fast"); Transform val2 = _debugBossGui.transform.Find("Health/health_slow"); GuiBar val3 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<GuiBar>() : null); GuiBar val4 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<GuiBar>() : null); if ((Object)(object)val3 != (Object)null) { val3.SetValue(healthPercentage); } if ((Object)(object)val4 != (Object)null) { val4.SetValue(healthPercentage); } ApplyHealthBarScale(_debugBossState); UpdateHealthValue(_debugBossState); } } private void CreateDebugBossHud(EnemyHud enemyHud, Player localPlayer) { //IL_00e0: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_0148: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemyHud == (Object)null || (Object)(object)enemyHud.m_baseHudBoss == (Object)null || (Object)(object)enemyHud.m_hudRoot == (Object)null) { return; } _debugBossGui = Object.Instantiate<GameObject>(enemyHud.m_baseHudBoss, enemyHud.m_hudRoot.transform); ((Object)_debugBossGui).name = "EnemyHudRework_DebugBoss"; _debugBossGui.SetActive(true); EnemyUiState enemyUiState = new EnemyUiState { Character = (Character)(object)localPlayer, Gui = _debugBossGui, Kind = HudKind.Boss, IsDebug = true }; Transform val = _debugBossGui.transform.Find("Name"); if ((Object)(object)val != (Object)null) { enemyUiState.NameGraphic = ((Component)val).GetComponent<Graphic>(); enemyUiState.NameText = ((Component)val).GetComponent<TMP_Text>(); enemyUiState.NameRect = (RectTransform)(object)((val is RectTransform) ? val : null); if ((Object)(object)enemyUiState.NameRect != (Object)null) { enemyUiState.NameOriginalPosition = enemyUiState.NameRect.anchoredPosition; } if ((Object)(object)enemyUiState.NameText != (Object)null) { enemyUiState.OriginalNameText = enemyUiState.NameText.text; enemyUiState.NameText.text = "EVIL " + localPlayer.GetPlayerName().ToUpperInvariant() + " ALTER EGO"; } if ((Object)(object)enemyUiState.NameGraphic != (Object)null) { enemyUiState.NormalNameColor = enemyUiState.NameGraphic.color; } } Transform val2 = _debugBossGui.transform.Find("Health"); if ((Object)(object)val2 != (Object)null) { enemyUiState.HealthRect = (RectTransform)(object)((val2 is RectTransform) ? val2 : null); if ((Object)(object)enemyUiState.HealthRect != (Object)null) { enemyUiState.HealthOriginalPosition = enemyUiState.HealthRect.anchoredPosition; enemyUiState.HealthOriginalScale = ((Transform)enemyUiState.HealthRect).localScale; Rect rect = enemyUiState.HealthRect.rect; enemyUiState.HealthOriginalHeight = ((Rect)(ref rect)).height; CaptureHealthFill(val2, "health_fast", out enemyUiState.HealthFastFill, out enemyUiState.HealthFastOriginalHeight); CaptureHealthFill(val2, "health_slow", out enemyUiState.HealthSlowFill, out enemyUiState.HealthSlowOriginalHeight); CaptureHealthFill(val2, "health_fast_friendly", out enemyUiState.HealthFriendlyFill, out enemyUiState.HealthFriendlyOriginalHeight); } } CreateHealthValue(enemyUiState); _debugBossState = enemyUiState; ApplyHealthBarScale(enemyUiState); ApplyBossNameColor(enemyUiState); UpdateHealthValue(enemyUiState); } private void DestroyDebugBossHud() { if (_debugBossState != null) { if ((Object)(object)_debugBossState.HealthValueObject != (Object)null) { Object.Destroy((Object)(object)_debugBossState.HealthValueObject); } _debugBossState = null; } if ((Object)(object)_debugBossGui != (Object)null) { Object.Destroy((Object)(object)_debugBossGui); _debugBossGui = null; } } private GameObject GetHudGui(EnemyHud enemyHud, Character character) { if (EnemyHudHudsField == null || HudDataGuiField == null || (Object)(object)enemyHud == (Object)null || (Object)(object)character == (Object)null) { return null; } if (!(EnemyHudHudsField.GetValue(enemyHud) is IDictionary dictionary) || !dictionary.Contains(character)) { return null; } object obj = dictionary[character]; if (obj == null) { return null; } object? value = HudDataGuiField.GetValue(obj); return (GameObject)((value is GameObject) ? value : null); } private static Color ParseColor(string value, Color fallback) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); if (!string.IsNullOrEmpty(value) && ColorUtility.TryParseHtmlString(value, ref result)) { return result; } return fallback; } private void DestroyState(EnemyUiState state) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (state != null) { if ((Object)(object)state.HealthRect != (Object)null) { ((Transform)state.HealthRect).localScale = state.HealthOriginalScale; state.HealthRect.SetSizeWithCurrentAnchors((Axis)1, state.HealthOriginalHeight); SetFillHeight(state.HealthFastFill, state.HealthFastOriginalHeight, 1f); SetFillHeight(state.HealthSlowFill, state.HealthSlowOriginalHeight, 1f); SetFillHeight(state.HealthFriendlyFill, state.HealthFriendlyOriginalHeight, 1f); state.HealthRect.anchoredPosition = state.HealthOriginalPosition; } if ((Object)(object)state.StaggerRoot != (Object)null) { Object.Destroy((Object)(object)state.StaggerRoot); } if ((Object)(object)state.HealthValueObject != (Object)null) { Object.Destroy((Object)(object)state.HealthValueObject); } } } } }