private static void UpdateHP(ref EnemyHud __instance, Player player, float dt) { if (!Main.customEnemyHud.Value) { return; } Character character = null; foreach (KeyValuePair <Character, EnemyHud.HudData> keyValuePair in __instance.m_huds) { EnemyHud.HudData value = keyValuePair.Value; if (!value.m_character || !__instance.TestShow(value.m_character)) { if (character == null) { character = value.m_character; Object.Destroy(value.m_gui); } } else { if (value.m_character.IsPlayer()) { // Currently no edits to player } else if (value.m_character.IsBoss()) { if (!Main.hideEnemyHPText.Value) { Utils.FindChild(value.m_name.transform.parent, _bossHPPrefix).GetComponent <Text>().text = $"<size={_bossHPFontSize}>{Mathf.CeilToInt(value.m_character.GetHealth())} / {value.m_character.GetMaxHealth():0}</size>"; } } else { value.m_alerted.gameObject.SetActive(false); value.m_aware.gameObject.SetActive(false); bool aware = value.m_character.GetBaseAI().HaveTarget(); bool alerted = value.m_character.GetBaseAI().IsAlerted(); value.m_name.color = (aware || alerted) ? (alerted ? Color.red : Color.yellow) : Color.white; if (!Main.hideEnemyHPText.Value) { Utils.FindChild(value.m_name.transform.parent, _hpPrefix).GetComponent <Text>().text = $"<size={_hpFontSize}>{Mathf.CeilToInt(value.m_character.GetHealth())}/{value.m_character.GetMaxHealth():0}</size>"; } if (Main.enemyLvlStyle.Value == 1) { value.m_level2.gameObject.SetActive(false); value.m_level3.gameObject.SetActive(false); } } } } if (character != null) { __instance.m_huds.Remove(character); } }
private static void Prefix(ref EnemyHud __instance) { if (Settings.isDefaultDifficulty) { return; } if (Settings.maxMobLevel.Value > 7 && !flag) { starOffset = 10; MoveOriginalLevel3(__instance.m_baseHud); flag = true; } }
private static void TineyeHuds(ref EnemyHud __instance, Player player, float dt) { if (!(bool)player || !(bool)__instance) { return; } if (player.GetSEMan().HaveStatusEffect("Tineye")) { if (__instance.m_hoverShowDuration != float.MaxValue) { __instance.m_hoverShowDuration = float.MaxValue; Debug.Log($"Modified Hover Show Duration: {__instance.m_hoverShowDuration}"); } } else if (__instance.m_hoverShowDuration == float.MaxValue) { __instance.m_hoverShowDuration = 60f; Debug.Log($"Hover Show Duration: {__instance.m_hoverShowDuration}"); } }
private static void PatchName(ref EnemyHud __instance, ref Character c) { if (!Main.customEnemyHud.Value) { return; } EnemyHud.HudData hudData; if (__instance.m_huds.TryGetValue(c, out _)) { return; } GameObject original; if (c.IsPlayer()) { original = __instance.m_baseHudPlayer; } else if (c.IsBoss()) { original = __instance.m_baseHudBoss; } else { original = __instance.m_baseHud; } hudData = new EnemyHud.HudData { m_character = c, m_ai = c.GetComponent <BaseAI>(), m_gui = Object.Instantiate(original, __instance.m_hudRoot.transform) }; hudData.m_gui.SetActive(true); hudData.m_healthRoot = hudData.m_gui.transform.Find("Health").gameObject; hudData.m_healthFast = hudData.m_healthRoot.transform.Find("health_fast").GetComponent <GuiBar>(); hudData.m_healthSlow = hudData.m_healthRoot.transform.Find("health_slow").GetComponent <GuiBar>(); hudData.m_level2 = (hudData.m_gui.transform.Find("level_2") as RectTransform); hudData.m_level3 = (hudData.m_gui.transform.Find("level_3") as RectTransform); hudData.m_alerted = (hudData.m_gui.transform.Find("Alerted") as RectTransform); hudData.m_aware = (hudData.m_gui.transform.Find("Aware") as RectTransform); hudData.m_name = hudData.m_gui.transform.Find("Name").GetComponent <Text>(); hudData.m_name.text = Localization.instance.Localize(c.GetHoverName()); if (c.IsPlayer()) { // Currently no edits to player } else if (c.IsBoss()) { if (!Main.hideEnemyHPText.Value) { // Edits to Boss HP Bar Text hpText = Object.Instantiate(hudData.m_name, hudData.m_name.transform.parent); hpText.name = _bossHPPrefix; hpText.rectTransform.anchoredPosition = new Vector2(hpText.rectTransform.anchoredPosition.x, 0.0f); // orig.y = 21f hpText.text = $"<size={_bossHPFontSize}>{hudData.m_character.GetHealth():0} / {hudData.m_character.GetMaxHealth():0}</size>"; hpText.color = Color.white; Object.Destroy(hpText.GetComponent <Outline>()); } } else { hudData.m_name.fontSize = Main.enemyHudTextSize.Value; if (Main.enemyLvlStyle.Value != 0) { hudData.m_name.text = hudData.m_name.text.Insert(0, $"<size={Main.enemyHudTextSize.Value - 2}><color=white>Lv.{c.m_level} </color></size> "); } if (!Main.hideEnemyHPText.Value) { Text hpText = Object.Instantiate(hudData.m_name, hudData.m_name.transform.parent); hpText.name = _hpPrefix; hpText.rectTransform.anchoredPosition = new Vector2(hpText.rectTransform.anchoredPosition.x, 7.0f); // orig.y = 21f hpText.text = $"<size={_hpFontSize}>{hudData.m_character.GetHealth():0}/{hudData.m_character.GetMaxHealth():0}</size>"; hpText.color = Color.white; Object.Destroy(hpText.GetComponent <Outline>()); } // Resize and position everything RectTransform hpRoot = (hudData.m_healthRoot.transform as RectTransform); Vector2 biggerBar = new Vector2(hpRoot.sizeDelta.x, hpRoot.sizeDelta.y * 3f); hpRoot.sizeDelta = biggerBar; hudData.m_alerted.gameObject.SetActive(false); hudData.m_aware.gameObject.SetActive(false); hudData.m_healthFast.m_bar.sizeDelta = new Vector2(hudData.m_healthFast.m_width, hpRoot.sizeDelta.y); hudData.m_healthSlow.m_bar.sizeDelta = new Vector2(hudData.m_healthSlow.m_width, hpRoot.sizeDelta.y); if (Main.enemyLvlStyle.Value == 1) { hudData.m_level2.gameObject.SetActive(false); hudData.m_level3.gameObject.SetActive(false); } } __instance.m_huds.Add(c, hudData); }
private static void PatchDefaults(ref EnemyHud __instance) { float limiter = Mathf.Min(Mathf.Abs(Main.maxShowDistance.Value), maxDrawDistance); __instance.m_maxShowDistance *= limiter; }
public static void PreAwake(EnemyHud __instance) { __instance.m_baseHud = new GameObject(); __instance.m_baseHudBoss = new GameObject(); __instance.m_baseHudPlayer = new GameObject(); }