private static void Awake(ref Hud __instance) { if (Main.showCharacterXP.Value && _bar == null) { _bar = XPBar.Awake(__instance); } if (useCustomHud) { // Try to support QuickSlots Compatibility.QuickSlotsHotkeyBar.Unanchor(__instance); // Load custom elements, before getting positions. if (Main.useCustomHealthBar.Value) { CustomElements.HealthBar.Create(); } if (Main.useCustomStaminaBar.Value) { CustomElements.StaminaBar.Create(); } if (Main.useCustomFoodBar.Value) { CustomElements.FoodBar.Create(); } CustomHud.Load(__instance); CustomHud.PositionTemplates(); } }
public static void Create() { try { // Hide original healthBar Hud.instance.transform.Find("hudroot").Find("healthpanel").gameObject.SetActive(false); healthBarRoot = UnityEngine.Object.Instantiate(Hud.instance.m_healthBarRoot, Hud.instance.transform.Find("hudroot")); healthBarRoot.gameObject.name = objectName; // Rotate this to 90 int rot = 90 - (Main.healthBarRotation.Value / 90 % 4 * 90); healthBarRoot.localEulerAngles = new Vector3(0, 0, rot); healthBarFast = healthBarRoot.Find("fast").GetComponent <GuiBar>(); healthBarSlow = healthBarRoot.Find("slow").GetComponent <GuiBar>(); healthBarRoot.Find("fast").Find("bar").Find("HealthText").gameObject.SetActive(false); healthText = UnityEngine.Object.Instantiate(healthBarRoot.Find("fast").Find("bar").Find("HealthText").GetComponent <Text>(), healthBarRoot); healthText.GetComponent <RectTransform>().localEulerAngles = new Vector3(0, 0, -rot); healthText.GetComponent <RectTransform>().localScale = new Vector3(0.65f, 0.65f, 1f); healthText.gameObject.SetActive(true); // Resize to a more "slim" rectangle - authors preference healthBarRoot.Find("border").GetComponent <RectTransform>().localScale = new Vector3(1f, 0.65f, 1f); healthBarRoot.Find("bkg").GetComponent <RectTransform>().localScale = new Vector3(1f, 0.65f, 1f); healthBarFast.GetComponent <RectTransform>().localScale = new Vector3(1f, 0.65f, 1f); healthBarSlow.GetComponent <RectTransform>().localScale = new Vector3(1f, 0.65f, 1f); } catch (Exception e) { Debug.LogError($"HealthBar.Create() {e.Message}"); } }
private static bool Prefix(GuiBar __instance) { // I have no idea why this bar is set to zero initially if (__instance.name == "durability" && __instance.m_bar.sizeDelta.x != 54) { __instance.m_bar.sizeDelta = new Vector2(54, 0); } return(true); }
private static void InitializeXPBar(ref Hud __instance) { if (!Main.showCharacterXP.Value) { return; } if (_bar == null) { _bar = Patches.XPBar.Awake(__instance); } }
private static bool Prefix(GuiBar __instance) { // I have no idea why this bar is set to zero initially // ReSharper disable once CompareOfFloatsByEqualityOperator if (__instance.name == "durability" && __instance.m_bar.sizeDelta.x != 54) { __instance.m_bar.sizeDelta = new Vector2(54, 0); } return(true); }
public static void Create() { try { // Hide original staminaBar Hud.instance.transform.Find("hudroot").Find("staminapanel").gameObject.SetActive(false); staminaBarRoot = UnityEngine.Object.Instantiate(Hud.instance.m_healthBarRoot, Hud.instance.transform.Find("hudroot")); staminaBarRoot.gameObject.name = objectName; int rot = 90 - (Main.staminaBarRotation.Value / 90 % 4 * 90); staminaBarRoot.localEulerAngles = new Vector3(0, 0, rot); staminaBarFast = staminaBarRoot.Find("fast").GetComponent <GuiBar>(); staminaBarSlow = staminaBarRoot.Find("slow").GetComponent <GuiBar>(); staminaBarRoot.Find("fast").Find("bar").Find("HealthText").gameObject.SetActive(false); staminaText = UnityEngine.Object.Instantiate(staminaBarRoot.Find("fast").Find("bar").Find("HealthText").GetComponent <Text>(), staminaBarRoot); staminaText.GetComponent <RectTransform>().localEulerAngles = new Vector3(0, 0, -rot); staminaText.GetComponent <RectTransform>().localScale = new Vector3(0.65f, 0.65f, 1f); staminaText.gameObject.SetActive(true); staminaBarRoot.Find("border").GetComponent <RectTransform>().localScale = new Vector3(1f, 0.65f, 1f); staminaBarRoot.Find("bkg").GetComponent <RectTransform>().localScale = new Vector3(1f, 0.65f, 1f); staminaBarFast.GetComponent <RectTransform>().localScale = new Vector3(1f, 0.65f, 1f); staminaBarSlow.GetComponent <RectTransform>().localScale = new Vector3(1f, 0.65f, 1f); staminaBarFast.m_originalColor = Hud.instance.m_staminaBar2Fast.m_bar.GetComponent <Image>().color; staminaBarFast.ResetColor(); staminaBarSlow.m_originalColor = Hud.instance.m_staminaBar2Slow.m_bar.GetComponent <Image>().color; staminaBarSlow.ResetColor(); staminaBarFast.m_smoothDrain = Hud.instance.m_staminaBar2Fast.m_smoothDrain; staminaBarFast.m_changeDelay = Hud.instance.m_staminaBar2Fast.m_changeDelay; staminaBarFast.m_smoothSpeed = Hud.instance.m_staminaBar2Fast.m_smoothSpeed; } catch (Exception e) { Debug.LogError($"StaminaBar.Create() {e.Message}"); } }
public static GuiBar Awake(Hud __instance) { Transform hudroot = Utils.FindChild(__instance.gameObject.transform, "hudroot"); GuiBar xp_bar = UnityEngine.Object.Instantiate(Hud.instance.m_stealthBar, hudroot, true); xp_bar.m_barImage = Hud.instance.m_stealthBar.m_bar.GetComponent <Image>(); xp_bar.m_smoothFill = smoothFill; xp_bar.m_smoothDrain = smoothDrain; xp_bar.m_smoothSpeed = smoothSpeed; xp_bar.Awake(); xp_bar.name = "BU_XP_BAR"; xp_bar.m_originalColor = barColor; xp_bar.ResetColor(); xp_bar.SetMaxValue(maxValue); xp_bar.SetValue(0f); RectTransform xpRect = (xp_bar.transform as RectTransform); xpRect.anchorMin = Vector2.zero; xpRect.anchorMax = new Vector2(1f, 0f); xpRect.anchoredPosition = Vector2.zero; xpRect.offsetMin = Vector2.zero; xpRect.offsetMax = Vector2.zero; xpRect.sizeDelta = new Vector2(0f, 5f); xp_bar.m_bar.anchorMin = Vector2.zero; xp_bar.m_bar.anchorMax = new Vector2(1f, 0.5f); xp_bar.m_bar.offsetMin = Vector2.zero; xp_bar.m_bar.offsetMax = Vector2.zero; xp_bar.m_bar.sizeDelta = new Vector2(xpRect.rect.width, 5f); // Render the XP Bar xp_bar.gameObject.SetActive(true); _xp_bar = xp_bar; return(xp_bar); }
// Make sure the HUD is always pointing to our copies of the // crosshair elements. private void UpdateHudReferences() { var hud = Hud.instance; if (hud == null) { LogDebug("NULL Hud"); } if (_crosshairClone != null) { Image crosshairImage = _crosshairClone.GetComponent <Image>(); if (crosshairImage != null) { hud.m_crosshair = crosshairImage; } else { LogDebug("Null CrosshairClone Image"); } } else { LogDebug("Null Crosshair Clone"); } if (_crosshairBowClone != null) { Image crosshairBowImage = _crosshairBowClone.GetComponent <Image>(); if (crosshairBowImage != null) { hud.m_crosshairBow = crosshairBowImage; } else { LogDebug("Null CrosshairBow Clone Image"); } } else { LogDebug("Null CrosshairBow Clone"); } if (_hoverNameClone != null) { Text hoverText = _hoverNameClone.GetComponent <Text>(); if (hoverText != null) { hud.m_hoverName = hoverText; } else { LogDebug("Null HoverText Text"); } } else { LogDebug("Null HoverName clone"); } if (_pieceHealthRoot != null) { RectTransform pieceHealthRootRect = _pieceHealthRoot.GetComponent <RectTransform>(); if (pieceHealthRootRect != null) { hud.m_pieceHealthRoot = pieceHealthRootRect; } else { LogDebug("Null Piece Health Root RectTransform"); } } else { LogDebug("Piece health root is null"); } if (_sneakAlertClone != null) { hud.m_targetedAlert = _sneakAlertClone; } else { LogDebug("Sneak Alert Clone is null"); } if (_sneakDetectedClone != null) { hud.m_targeted = _sneakDetectedClone; } else { LogDebug("Sneak Detected Clone is null"); } if (_sneakHiddenClone != null) { hud.m_hidden = _sneakHiddenClone; } else { LogDebug("Sneak hidden clone is null"); } if (_stealthBarClone != null) { GuiBar stealthGuiBar = _stealthBarClone.GetComponent <GuiBar>(); if (stealthGuiBar != null) { hud.m_stealthBar = stealthGuiBar; } else { LogDebug("Stealth GUI Bar is null"); } } else { LogDebug("Stealth Bar clone is null"); } if (_pieceHealthBar != null) { GuiBar pieceHealthGuiBar = _pieceHealthBar.GetComponent <GuiBar>(); if (pieceHealthGuiBar != null) { hud.m_pieceHealthBar = pieceHealthGuiBar; } else { LogDebug("PieceHealthBar GUI bar is null"); } } else { LogDebug("PieceHealthBar is null."); } }