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 HUD Update v0.2.0
plugins/HUD-Update/HUD-Update.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("HUD Update")] [assembly: AssemblyDescription("Nordic HUD for Valheim: guardian power, food diamonds, health and stamina.")] [assembly: AssemblyCompany("Crevitka")] [assembly: AssemblyProduct("HUD Update")] [assembly: AssemblyCopyright("Copyright (c) 2026 Crevitka, MIT License")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyVersion("0.2.0.0")] namespace UIReforge; public enum HudStyle { Bars, Chevron, Yggdrasil } public enum ExtraSlotsLayoutMode { Auto, Off } public enum BarScaleMode { Percent, Absolute } public enum FoodIconColorMode { Off, Tint, Glow, TintAndGlow } [BepInPlugin("crevitka.hudupdate", "HUD Update", "0.2.0")] public class HudUpdatePlugin : BaseUnityPlugin { private Harmony _harmony; internal static ConfigEntry<HudStyle> Style; internal static ConfigEntry<FoodIconColorMode> FoodColor; internal static ConfigEntry<bool> UseVanillaFoodIcons; internal static ConfigEntry<float> FoodGlowStrength; internal static ConfigEntry<BarScaleMode> BarScale; internal static ConfigEntry<float> HealthBarMax; internal static ConfigEntry<float> StaminaBarMax; internal static ConfigEntry<float> DiamondOpacity; internal static ConfigEntry<float> BarBackgroundOpacity; internal static ConfigEntry<float> HudScale; internal static ConfigEntry<float> YggGlow; internal static ConfigEntry<bool> ChevronStamina; internal static ConfigEntry<ExtraSlotsLayoutMode> ExtraSlotsLayout; private DateTime _configStamp; private float _nextConfigCheck; private string _iconStamp; private void Awake() { //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Expected O, but got Unknown try { Style = ((BaseUnityPlugin)this).Config.Bind<HudStyle>("General", "HudStyle", HudStyle.Bars, "Bars - guardian, food diamonds and straight health/stamina bars.\nChevron - guardian, 2x2 food grid and a red health chevron; stamina stays vanilla.\nYggdrasil - food diamonds stacked in a branch frame above the guardian, bars to the right; room for a 4th meal (OneMoreMeal) and ExtraSlots panels around the bars.\nCan be changed while the game runs: save this file and the HUD rebuilds."); Style.SettingChanged += delegate { HudState.RequestRebuild(); }; UseVanillaFoodIcons = ((BaseUnityPlugin)this).Config.Bind<bool>("Food", "UseVanillaFoodIcons", false, "Use the original item icons for food, including ExtraSlots food slots, instead of HUD Update replacements. Also preserves icons supplied by other food mods. Guardian emblems are unaffected."); UseVanillaFoodIcons.SettingChanged += delegate { HudState.RequestRebuild(); }; FoodColor = ((BaseUnityPlugin)this).Config.Bind<FoodIconColorMode>("Food", "FoodIconColor", FoodIconColorMode.Off, "Colour food icons by the stat they raise most: health = red, stamina = yellow, eitr = blue, balanced = white.\nOff - plain icons. Tint - the icon itself is coloured (only the mod's white icons, vanilla icons stay as is).\nGlow - a soft coloured glow around the icon. TintAndGlow - both."); FoodGlowStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Food", "FoodGlowStrength", 0.7f, new ConfigDescription("Glow opacity, 0 - invisible, 1 - strongest.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); BarScale = ((BaseUnityPlugin)this).Config.Bind<BarScaleMode>("Bars", "BarScale", BarScaleMode.Percent, "How much of the health / stamina bar is coloured.\nPercent - current value / your current maximum: a full bar means full health, whatever you have eaten.\nAbsolute - current value / HealthBarMax (StaminaBarMax): the bar grows as you eat, like the vanilla bar gets longer. A faint band shows what is missing up to your current maximum."); HealthBarMax = ((BaseUnityPlugin)this).Config.Bind<float>("Bars", "HealthBarMax", 200f, new ConfigDescription("Health that fills the whole bar with BarScale = Absolute (higher values are shown as a full bar).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(25f, 1000f), Array.Empty<object>())); StaminaBarMax = ((BaseUnityPlugin)this).Config.Bind<float>("Bars", "StaminaBarMax", 200f, new ConfigDescription("Stamina that fills the whole bar with BarScale = Absolute.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(25f, 1000f), Array.Empty<object>())); DiamondOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Bars", "DiamondOpacity", 0.93f, new ConfigDescription("Opacity of the dark guardian and food diamonds in the Bars and Yggdrasil styles. 0.72 matches the Chevron food cells; lower is more see-through.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); DiamondOpacity.SettingChanged += delegate { HudState.RequestRebuild(); }; BarBackgroundOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Bars", "BarBackgroundOpacity", 0.75f, new ConfigDescription("Opacity of the health and stamina backgrounds, including the value plates, in Bars and Yggdrasil. 0 = transparent, 1 = opaque. Does not change coloured fills or text.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); BarBackgroundOpacity.SettingChanged += delegate { HudState.RequestRebuild(); }; HudScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HudScale", 1f, new ConfigDescription("Size of the whole HUD block, 1 = as designed. Panels of ExtraSlots follow it in the Yggdrasil style.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())); HudScale.SettingChanged += delegate { HudState.RequestRebuild(); }; ChevronStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("Chevron", "StaminaInChevron", false, "Show stamina as a yellow strip along the inner edge of the health chevron instead of the vanilla stamina bar."); ChevronStamina.SettingChanged += delegate { HudState.RequestRebuild(); }; YggGlow = ((BaseUnityPlugin)this).Config.Bind<float>("Yggdrasil", "GlowStrength", 0.25f, new ConfigDescription("Blue glow around the branches, 0 - none, 1 - as in the mockup.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); YggGlow.SettingChanged += delegate { HudState.ApplyYggGlow(); }; ExtraSlotsLayout = ((BaseUnityPlugin)this).Config.Bind<ExtraSlotsLayoutMode>("Compatibility", "ExtraSlotsLayout", ExtraSlotsLayoutMode.Auto, "ExtraSlots (shudnal) panels.\nAuto - ammo and food slots next to the health/stamina block, quick slots under the hotbar, all drawn in the HUD's white outline look (every style).\nOff - leave them as ExtraSlots places and draws them."); ExtraSlotsLayout.SettingChanged += delegate { ExtraSlotsSkin.RestoreAll(); }; _configStamp = SafeStamp(); try { Directory.CreateDirectory(HudState.IconFolders[0]); } catch { } _harmony = new Harmony("crevitka.hudupdate"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"UIReforge loaded"); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"UIReforge init failed: {arg}"); } } private DateTime SafeStamp() { try { return File.GetLastWriteTimeUtc(((BaseUnityPlugin)this).Config.ConfigFilePath); } catch { return DateTime.MinValue; } } private void Update() { if (Time.unscaledTime < _nextConfigCheck) { return; } _nextConfigCheck = Time.unscaledTime + 1f; string text = HudState.IconFolderStamp(); if (_iconStamp == null) { _iconStamp = text; } else if (text != _iconStamp) { _iconStamp = text; HudState.ReloadIcons(); } DateTime dateTime = SafeStamp(); if (dateTime == _configStamp) { return; } _configStamp = dateTime; try { ((BaseUnityPlugin)this).Config.Reload(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Config reload failed: " + ex.Message)); } } private void OnDestroy() { try { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"UIReforge unpatch failed: {arg}"); } } } internal static class HudState { internal class FoodSlotUI { public GameObject Root; public Image Icon; public TextMeshProUGUI Timer; public TextMeshProUGUI[] TimerShadow; public Image VanillaIcon; public Image Glow; } internal class BuffUI { public GameObject Root; public Image Icon; public TextMeshProUGUI Timer; } internal enum FoodStat { Neutral, Health, Stamina, Eitr } internal static TextMeshProUGUI GuardianName; private static float nextInitAttempt; internal static HudStyle ActiveStyle = HudStyle.Bars; private static readonly List<GameObject> HiddenVanillaStamina = new List<GameObject>(); internal static Image[] ChevronFast; internal static Image[] ChevronSlow; internal static Image[] ChevronStaminaFast; internal static Image[] ChevronStaminaSlow; private static int guardianUpdateFrame = -1; internal static bool Initialized; internal static GameObject Panel; internal static Image HpFastImage; internal static Image HpSlowImage; internal static Image HpCapacityImage; internal static Image StaminaCapacityImage; internal static TextMeshProUGUI HpText; internal static float HpFastValue = -1f; internal static float HpSlowValue = -1f; internal static Image StaminaFastImage; internal static Image StaminaSlowImage; internal static TextMeshProUGUI StaminaText; internal static float StaminaFastValue = -1f; internal static float StaminaSlowValue = -1f; internal static FoodSlotUI[] Slots = new FoodSlotUI[3]; internal const int MaxFoodSlots = 4; internal static BuffUI Buff; internal static Sprite DefaultFoodIcon; private static Sprite SolidBarSprite; internal static AssetBundle HudBundle; internal static AssetBundle FoodIconsBundle; private static readonly Dictionary<string, Sprite> EmbeddedFoodIcons = new Dictionary<string, Sprite>(); private static bool embeddedIconsLoaded; internal static readonly Dictionary<string, Sprite> FoodIconOverrides = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase); internal static GameObject VanillaGuardianRoot; internal static Image VanillaGuardianIcon; internal static Image VanillaGuardianTimeBar; internal static TextMeshProUGUI VanillaGuardianTimeText; internal static Text VanillaGuardianLegacyTimeText; internal static TextMeshProUGUI VanillaGuardianNameText; internal static Text VanillaGuardianLegacyNameText; internal const float TimerYOffset = -28f; internal const float BarTextRightOffset = -10f; internal static readonly string[] IconFolders = new string[2] { Path.Combine(Path.Combine(Paths.ConfigPath, "HUD-Update"), "Icons"), Path.Combine(Path.GetDirectoryName(typeof(HudUpdatePlugin).Assembly.Location) ?? Paths.PluginPath, "Icons") }; private static readonly HashSet<string> NonFoodIcons = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "HealthIcon", "StaminaIcon", "chevron_shape", "chevron_outline", "Eikthyr", "TheElder", "Bonemass" }; private static readonly List<Object> LoadedIconObjects = new List<Object>(); internal static readonly Color PanelDark = new Color(0.105f, 0.105f, 0.085f, 0.93f); internal static readonly Color HpColor = new Color(0.66f, 0.12f, 0.12f, 1f); internal static readonly Color HpTrailColor = new Color(0.93f, 0.78f, 0.72f, 1f); internal static readonly Color StaminaColor = new Color(0.84f, 0.65f, 0.43f, 1f); internal static readonly Color StaminaTrailColor = new Color(0.97f, 0.9f, 0.78f, 1f); private const float HpBarY = 122f; private const float StaminaBarY = 88f; private static float BarLeft = 238f; private static float BarWidth = 266f; private static float BarHeight = 27f; private static float PlateWidth = 34f; private static Color BarTrackColor; private static Color BarPlateColor; private const float FoodTimerRim = 1f; private static readonly Color FoodTimerRimColor = new Color(0f, 0f, 0f, 0.85f); internal static readonly Color YggTrack = new Color(0f, 0f, 0f, 0.9f); internal static readonly Color YggHp = new Color(0.678f, 0.086f, 0.086f, 1f); internal static readonly Color YggStamina = new Color(0.835f, 0.635f, 0.369f, 1f); internal static readonly float[] YggFoodY = new float[4] { 145.61f, 215.61f, 284.61f, 355.18f }; internal const float YggFoodX = 97.86f; internal static readonly Vector2 YggAmmoStart = new Vector2(285.5f, 115.5f); internal static readonly Vector2 YggFoodBarStart = new Vector2(455.5f, 52.5f); internal const float YggSlotSize = 45f; internal const float YggAmmoPitch = 52f; internal const float YggFoodPitch = 55f; internal static Image[] YggGlowImages; internal static readonly Color ChevronRed = new Color(0.678f, 0.086f, 0.086f, 1f); internal static readonly Color ChevronTrail = new Color(0.95f, 0.8f, 0.72f, 1f); internal static readonly Color ChevronTrack = new Color(0.07f, 0.05f, 0.04f, 0.55f); internal static readonly Color ChevronOutline = new Color(0f, 0f, 0f, 1f); internal static readonly Color ChevronCell = new Color(0f, 0f, 0f, 0.72f); internal static readonly Color FoodBackplate = new Color(0.66f, 0.64f, 0.3f, 0.55f); private const float ChevX0 = -79.71f; private const float ChevX1 = 118.96f; private const float ChevY0 = -87.96f; private const float ChevY1 = 117.38f; private const float ChevCorner = 14f; private const float ChevBand = 44f; private static readonly Vector2[] ChevPath = (Vector2[])(object)new Vector2[5] { new Vector2(-85.04f, 86.71f), new Vector2(-25.04f, 86.71f), new Vector2(-1.04f, 108.04f), new Vector2(107.89f, 0.31f), new Vector2(16.29f, -95.96f) }; private const float ChevStaminaMargin = 16f; private static Sprite solidSprite; private static readonly Dictionary<string, Sprite> cutSprites = new Dictionary<string, Sprite>(); private static readonly Dictionary<string, string> GuardianEmblems = new Dictionary<string, string>(StringComparer.Ordinal) { { "GP_Eikthyr", "Eikthyr" }, { "GP_TheElder", "TheElder" }, { "GP_Bonemass", "Bonemass" } }; private static readonly Dictionary<Sprite, Sprite> GlowSprites = new Dictionary<Sprite, Sprite>(); private static Sprite radialGlow; private const float GlowScale = 1.7f; private static readonly Dictionary<string, string> FoodGlyphByPrefab = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Raspberry", "raspberry" }, { "Blueberries", "berries" }, { "Cloudberry", "berries" }, { "Vineberry", "berries" }, { "Mushroom", "mushroom" }, { "MushroomYellow", "mushroom" }, { "MushroomBlue", "mushroom" }, { "MushroomJotunPuffs", "mushroom" }, { "MushroomMagecap", "mushroom" }, { "MushroomSmokePuff", "mushroom" }, { "MagicallyStuffedShroom", "mushroom" }, { "Carrot", "carrot" }, { "Turnip", "turnip" }, { "Onion", "onion" }, { "Honey", "honey" }, { "RoyalJelly", "honey" }, { "CookedMeat", "steak" }, { "CookedDeerMeat", "steak" }, { "CookedWolfMeat", "steak" }, { "CookedLoxMeat", "steak" }, { "SerpentMeatCooked", "steak" }, { "CookedBugMeat", "steak" }, { "CookedAsksvinMeat", "steak" }, { "CookedVoltureMeat", "steak" }, { "CookedBoneMawSerpentMeat", "steak" }, { "MeatPlatter", "steak" }, { "NeckTailGrilled", "drumstick" }, { "CookedChickenMeat", "drumstick" }, { "CookedHareMeat", "drumstick" }, { "HoneyGlazedChicken", "drumstick" }, { "FishCooked", "fish" }, { "FishWraps", "fish" }, { "FishAndBread", "fish" }, { "CookedEgg", "egg" }, { "MushroomOmelette", "omelette" }, { "BoarJerky", "jerky" }, { "WolfJerky", "jerky" }, { "WolfMeatSkewer", "skewer" }, { "CarrotSoup", "stew" }, { "DeerStew", "stew" }, { "TurnipStew", "stew" }, { "SerpentStew", "stew" }, { "BlackSoup", "stew" }, { "MinceMeatSauce", "stew" }, { "YggdrasilPorridge", "stew" }, { "SizzlingBerryBroth", "stew" }, { "FierySvinstew", "stew" }, { "MashedMeat", "stew" }, { "ScorchingMedley", "stew" }, { "QueensJam", "jam" }, { "SpicyMarmalade", "jam" }, { "ShocklateSmoothie", "drink" }, { "SparklingShroomshake", "drink" }, { "Bread", "bread" }, { "LoxPie", "pie" }, { "PiquantPie", "pie" }, { "RoastedCrustPie", "pie" }, { "MisthareSupreme", "pie" }, { "Salad", "salad" }, { "MarinatedGreens", "salad" }, { "Eyescream", "icecream" }, { "Fiddleheadfern", "fern" }, { "SeekerAspic", "aspic" }, { "BloodPudding", "aspic" }, { "FeastMeadows", "feast" }, { "FeastBlackforest", "feast" }, { "FeastSwamps", "feast" }, { "FeastMountains", "feast" }, { "FeastOceans", "feast" }, { "FeastPlains", "feast" }, { "FeastMistlands", "feast" }, { "FeastAshlands", "feast" }, { "FeastDeepNorth", "feast" }, { "Poteitr", "potato" }, { "BakedPoteitr", "potato" }, { "MeatballsMashedPoteitr", "potato" }, { "Pancakes", "pancake" }, { "OvenPancake", "pancake" }, { "VikingCupcake", "cupcake" }, { "Kale", "kale" }, { "KaleChips", "kale" }, { "Oat", "grain" }, { "GlowWorm", "worm" }, { "OatMilk", "drink" }, { "Lingondricka", "drink" }, { "OatmealLingonberryJam", "stew" }, { "MooseKebab", "skewer" }, { "PulledBear", "steak" }, { "CookedSealBlubber", "steak" }, { "CookedMooseMeat", "steak" }, { "CookedBjornMeat", "steak" }, { "SmokedMooseMeat", "steak" }, { "SmokedFish", "fish" }, { "FishSoup", "stew" }, { "SealSoup", "stew" } }; private static readonly string[][] FoodGlyphKeywords = new string[45][] { new string[2] { "feast", "feast" }, new string[2] { "pancake", "pancake" }, new string[2] { "cupcake", "cupcake" }, new string[2] { "kebab", "skewer" }, new string[2] { "milk", "drink" }, new string[2] { "soup", "stew" }, new string[2] { "broth", "stew" }, new string[2] { "porridge", "stew" }, new string[2] { "sauce", "stew" }, new string[2] { "medley", "stew" }, new string[2] { "pie", "pie" }, new string[2] { "supreme", "pie" }, new string[2] { "jam", "jam" }, new string[2] { "marmalade", "jam" }, new string[2] { "smoothie", "drink" }, new string[2] { "shake", "drink" }, new string[2] { "mead", "drink" }, new string[2] { "jerky", "jerky" }, new string[2] { "skewer", "skewer" }, new string[2] { "bread", "bread" }, new string[2] { "salad", "salad" }, new string[2] { "greens", "salad" }, new string[2] { "omelette", "omelette" }, new string[2] { "egg", "egg" }, new string[2] { "aspic", "aspic" }, new string[2] { "pudding", "aspic" }, new string[2] { "fish", "fish" }, new string[2] { "chicken", "drumstick" }, new string[2] { "hare", "drumstick" }, new string[2] { "necktail", "drumstick" }, new string[2] { "meat", "steak" }, new string[2] { "raspberr", "raspberry" }, new string[2] { "berr", "berries" }, new string[2] { "shroom", "mushroom" }, new string[2] { "carrot", "carrot" }, new string[2] { "turnip", "turnip" }, new string[2] { "onion", "onion" }, new string[2] { "honey", "honey" }, new string[2] { "jelly", "honey" }, new string[2] { "fern", "fern" }, new string[2] { "cream", "icecream" }, new string[2] { "poteitr", "potato" }, new string[2] { "potato", "potato" }, new string[2] { "kale", "kale" }, new string[2] { "worm", "worm" } }; internal static bool ChevronStaminaOn { get { if (HudUpdatePlugin.ChevronStamina != null) { return HudUpdatePlugin.ChevronStamina.Value; } return false; } } internal static HudStyle CurrentStyle { get { if (HudUpdatePlugin.Style == null) { return HudStyle.Bars; } return HudUpdatePlugin.Style.Value; } } internal static void RequestRebuild() { Reset(); nextInitAttempt = 0f; } internal static void Reset() { Initialized = false; guardianUpdateFrame = -1; foreach (GameObject item in HiddenVanillaStamina) { if ((Object)(object)item != (Object)null) { item.SetActive(true); } } HiddenVanillaStamina.Clear(); ChevronFast = null; ChevronSlow = null; ChevronStaminaFast = null; ChevronStaminaSlow = null; if ((Object)(object)Panel != (Object)null) { Object.Destroy((Object)(object)Panel); } Panel = null; GuardianName = null; HpFastImage = null; HpCapacityImage = null; StaminaCapacityImage = null; HpSlowImage = null; HpText = null; HpFastValue = -1f; HpSlowValue = -1f; StaminaFastImage = null; StaminaSlowImage = null; StaminaText = null; StaminaFastValue = -1f; StaminaSlowValue = -1f; for (int i = 0; i < Slots.Length; i++) { Slots[i] = null; } Buff = null; VanillaGuardianRoot = null; VanillaGuardianIcon = null; VanillaGuardianTimeBar = null; VanillaGuardianTimeText = null; VanillaGuardianLegacyTimeText = null; VanillaGuardianNameText = null; VanillaGuardianLegacyNameText = null; } internal static void EnsureInit(Hud hud) { //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) if (Initialized) { bool flag = ActiveStyle != CurrentStyle || (Object)(object)Panel == (Object)null || Buff == null || (Object)(object)hud == (Object)null || (Object)(object)hud.m_rootObject == (Object)null; if (!flag && (Object)(object)Panel != (Object)null) { try { if ((Object)(object)Panel.transform.parent != (Object)(object)hud.m_rootObject.transform) { flag = true; } } catch { flag = true; } } if (flag) { Reset(); } } if (Initialized || (Object)(object)hud == (Object)null || (Object)(object)hud.m_rootObject == (Object)null || Time.unscaledTime < nextInitAttempt) { return; } nextInitAttempt = Time.unscaledTime + 5f; try { if ((Object)(object)HudBundle == (Object)null) { HudBundle = LoadHudBundle(); } if ((Object)(object)HudBundle == (Object)null) { Debug.LogError((object)"[UIReforge] Failed to load the HUD bundle (embedded and prefabs/hudPrefab)"); return; } GameObject val = HudBundle.LoadAsset<GameObject>("healthpanel"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"[UIReforge] Failed to load prefab 'healthpanel' from bundle"); return; } DefaultFoodIcon = HudBundle.LoadAsset<Sprite>("default-food-icon"); LoadFoodIconsBundle(); TmpFontFix.ApplyFontsToPrefab(val); Panel = Object.Instantiate<GameObject>(val, hud.m_rootObject.transform); ((Object)Panel).name = "CustomHealthPanel"; TmpFontFix.FixFontsOnInstance(Panel); MonoBehaviour[] componentsInChildren = Panel.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren) { if (((object)val2).GetType().Name == "GuiBar") { ((Behaviour)val2).enabled = false; } } int num = ((hud.m_foodIcons != null) ? Mathf.Clamp(hud.m_foodIcons.Length, 3, 4) : 3); if (Slots.Length != num) { Slots = new FoodSlotUI[num]; } FindReferences(Panel); if ((Object)(object)HpFastImage == (Object)null || (Object)(object)StaminaFastImage == (Object)null || (Object)(object)HpText == (Object)null || (Object)(object)StaminaText == (Object)null || Buff == null || (Object)(object)Buff.Icon == (Object)null || (Object)(object)Buff.Timer == (Object)null || Slots.Any((FoodSlotUI slot) => slot == null || (Object)(object)slot.Icon == (Object)null || (Object)(object)slot.Timer == (Object)null)) { throw new InvalidDataException("HUD prefab is missing required bars, labels or food slots"); } ActiveStyle = CurrentStyle; if (ActiveStyle == HudStyle.Chevron) { ApplyChevronLayout(); } else if (ActiveStyle == HudStyle.Yggdrasil) { ApplyYggdrasilLayout(); } else { ApplyReferenceLayout(); } float num2 = ((HudUpdatePlugin.HudScale != null) ? HudUpdatePlugin.HudScale.Value : 1f); Panel.transform.localScale = Vector3.one * num2; CaptureVanillaGuardian(hud); HideVanillaGuardianVisuals(); if ((Object)(object)hud.m_healthPanel != (Object)null) { ((Component)hud.m_healthPanel).gameObject.SetActive(false); } if (ActiveStyle != HudStyle.Chevron || ChevronStaminaOn) { HideVanillaStamina(hud); } Initialized = true; Debug.Log((object)("[UIReforge] Custom HUD initialized 0.2.0, style " + ActiveStyle.ToString() + ", food slots " + Slots.Length)); } catch (Exception ex) { Reset(); Debug.LogError((object)("[UIReforge] Init error: " + ex)); } } private static AssetBundle LoadHudBundle() { try { using Stream stream = typeof(HudUpdatePlugin).Assembly.GetManifestResourceStream("UIReforge.Bundles.hudPrefab"); if (stream != null) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); AssetBundle val = AssetBundle.LoadFromMemory(memoryStream.ToArray()); if ((Object)(object)val != (Object)null) { return val; } } } catch (Exception ex) { Debug.LogWarning((object)("[UIReforge] Embedded HUD bundle failed: " + ex.Message)); } string text = FindPluginFile("prefabs", "hudPrefab"); if (!File.Exists(text)) { return null; } return AssetBundle.LoadFromFile(text); } private static string FindPluginFile(string folder, string file) { string text = Path.Combine(Path.GetDirectoryName(typeof(HudUpdatePlugin).Assembly.Location) ?? Paths.PluginPath, folder, file); if (!File.Exists(text)) { return Path.Combine(Paths.PluginPath, folder, file); } return text; } internal static void LoadFoodIconsBundle() { try { FoodIconOverrides.Clear(); string text = FindPluginFile("prefabs", "food_icons"); if (!File.Exists(text)) { return; } if ((Object)(object)FoodIconsBundle == (Object)null) { FoodIconsBundle = AssetBundle.LoadFromFile(text); } if ((Object)(object)FoodIconsBundle == (Object)null) { Debug.LogError((object)"[UIReforge] Failed to load food_icons bundle"); return; } Sprite[] array = FoodIconsBundle.LoadAllAssets<Sprite>(); foreach (Sprite val in array) { if ((Object)(object)val != (Object)null) { FoodIconOverrides[((Object)val).name] = val; } } Debug.Log((object)$"[UIReforge] Loaded food icon overrides: {FoodIconOverrides.Count}"); } catch (Exception ex) { Debug.LogError((object)("[UIReforge] LoadFoodIconsBundle error: " + ex)); } finally { LoadEmbeddedFoodIcons(); } } private static void LoadEmbeddedFoodIcons() { if (!embeddedIconsLoaded) { embeddedIconsLoaded = true; Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); Assembly assembly = typeof(HudUpdatePlugin).Assembly; foreach (string item in from n in assembly.GetManifestResourceNames() where n.StartsWith("UIReforge.Icons.", StringComparison.Ordinal) && n.EndsWith(".png", StringComparison.OrdinalIgnoreCase) select n) { dictionary[item.Substring("UIReforge.Icons.".Length, item.Length - "UIReforge.Icons.".Length - 4)] = null; } for (int num = IconFolders.Length - 1; num >= 0; num--) { try { if (Directory.Exists(IconFolders[num])) { string[] files = Directory.GetFiles(IconFolders[num], "*.png"); foreach (string text in files) { dictionary[Path.GetFileNameWithoutExtension(text)] = text; } } } catch (Exception ex) { Debug.LogWarning((object)("[UIReforge] Could not read " + IconFolders[num] + ": " + ex.Message)); } } int num3 = 0; foreach (KeyValuePair<string, string> item2 in dictionary) { string key = item2.Key; Sprite val = null; if (item2.Value != null) { try { val = CreateIconSprite(key, File.ReadAllBytes(item2.Value)); num3++; } catch (Exception ex2) { Debug.LogWarning((object)("[UIReforge] Icon " + item2.Value + " skipped: " + ex2.Message)); } } if ((Object)(object)val == (Object)null) { using Stream stream = assembly.GetManifestResourceStream("UIReforge.Icons." + key + ".png"); if (stream == null) { continue; } using (MemoryStream memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); try { val = CreateIconSprite(key, memoryStream.ToArray()); } catch (Exception ex3) { Debug.LogWarning((object)("[UIReforge] Could not load embedded icon " + key + ": " + ex3.Message)); } } goto IL_022a; } goto IL_022a; IL_022a: if ((Object)(object)val != (Object)null) { EmbeddedFoodIcons[key] = val; } } Debug.Log((object)("[UIReforge] Icons: " + EmbeddedFoodIcons.Count + " (" + num3 + " from Icons folders)")); } foreach (KeyValuePair<string, Sprite> embeddedFoodIcon in EmbeddedFoodIcons) { FoodIconOverrides[embeddedFoodIcon.Key] = embeddedFoodIcon.Value; } } private static Sprite CreateIconSprite(string key, byte[] png) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) bool flag = key.StartsWith("ygg_", StringComparison.OrdinalIgnoreCase); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, flag); try { if (!ImageConversion.LoadImage(val, png, false)) { throw new InvalidDataException("not a valid PNG"); } ((Object)val).name = key; ((Texture)val).wrapMode = (TextureWrapMode)1; Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); ((Object)val2).name = key; if (!flag && !NonFoodIcons.Contains(key) && !key.StartsWith("GP_", StringComparison.OrdinalIgnoreCase)) { Sprite val3 = BuildGlowSprite(val, key); GlowSprites[val2] = val3; LoadedIconObjects.Add((Object)(object)val3); LoadedIconObjects.Add((Object)(object)val3.texture); } val.Apply(false, true); Object.DontDestroyOnLoad((Object)(object)val); Object.DontDestroyOnLoad((Object)(object)val2); LoadedIconObjects.Add((Object)(object)val2); LoadedIconObjects.Add((Object)(object)val); return val2; } catch { Object.Destroy((Object)(object)val); throw; } } internal static void ReloadIcons() { RequestRebuild(); foreach (Object loadedIconObject in LoadedIconObjects) { if (loadedIconObject != (Object)null) { Object.Destroy(loadedIconObject); } } LoadedIconObjects.Clear(); GlowSprites.Clear(); EmbeddedFoodIcons.Clear(); FoodIconOverrides.Clear(); embeddedIconsLoaded = false; Debug.Log((object)"[UIReforge] Icons folder changed, reloading icons"); } internal static string IconFolderStamp() { StringBuilder stringBuilder = new StringBuilder(); string[] iconFolders = IconFolders; foreach (string path in iconFolders) { try { if (Directory.Exists(path)) { string[] files = Directory.GetFiles(path, "*.png"); foreach (string text in files) { stringBuilder.Append(text).Append(File.GetLastWriteTimeUtc(text).Ticks).Append(';'); } } } catch { } } return stringBuilder.ToString(); } internal static void FindReferences(GameObject root) { //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Expected O, but got Unknown //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Expected O, but got Unknown //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) FindBarGroup(root.transform.Find("Health"), out HpFastImage, out HpSlowImage, out HpText); FindBarGroup(root.transform.Find("Stamina"), out StaminaFastImage, out StaminaSlowImage, out StaminaText); Transform val = root.transform.Find("Buff"); if ((Object)(object)val != (Object)null) { BuffUI obj = new BuffUI { Root = ((Component)val).gameObject }; Transform obj2 = val.Find("buffIcon"); obj.Icon = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null); Transform obj3 = val.Find("time"); obj.Timer = ((obj3 != null) ? ((Component)obj3).GetComponent<TextMeshProUGUI>() : null); Buff = obj; if ((Object)(object)Buff.Root != (Object)null) { Buff.Root.SetActive(false); } if ((Object)(object)Buff.Icon != (Object)null) { ((Graphic)Buff.Icon).color = Color.white; Buff.Icon.preserveAspect = true; ((Graphic)Buff.Icon).raycastTarget = false; } if ((Object)(object)Buff.Timer != (Object)null) { SetupDiamondTimerText(Buff.Timer); ((TMP_Text)Buff.Timer).transform.SetAsLastSibling(); } } else { Buff = null; } List<Transform> list = new List<Transform>(); foreach (Transform item in root.transform) { Transform val2 = item; if (((Object)val2).name.IndexOf("food", StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(val2); } } list.Sort((Transform a, Transform b) => string.Compare(((Object)a).name, ((Object)b).name, StringComparison.Ordinal)); int num = list.Count; while (list.Count > 0 && num < Slots.Length) { GameObject val3 = Object.Instantiate<GameObject>(((Component)list[0]).gameObject, root.transform); ((Object)val3).name = "food_extra" + num; list.Add(val3.transform); num++; } for (int num2 = 0; num2 < Slots.Length; num2++) { if (num2 >= list.Count) { Slots[num2] = null; continue; } Transform val4 = list[num2]; FoodSlotUI foodSlotUI = new FoodSlotUI { Root = ((Component)val4).gameObject, Timer = ((Component)val4).GetComponentInChildren<TextMeshProUGUI>(true) }; foodSlotUI.VanillaIcon = FindVanillaFoodIconImage(val4); if ((Object)(object)DefaultFoodIcon == (Object)null && (Object)(object)foodSlotUI.VanillaIcon != (Object)null) { DefaultFoodIcon = foodSlotUI.VanillaIcon.sprite; } if ((Object)(object)foodSlotUI.VanillaIcon != (Object)null) { ((Behaviour)foodSlotUI.VanillaIcon).enabled = false; } GameObject val5 = new GameObject("UIReforgeGlow", new Type[2] { typeof(RectTransform), typeof(Image) }); val5.transform.SetParent(val4, false); foodSlotUI.Glow = val5.GetComponent<Image>(); ((Graphic)foodSlotUI.Glow).raycastTarget = false; ((Behaviour)foodSlotUI.Glow).enabled = false; GameObject val6 = new GameObject("UIReforgeIcon", new Type[2] { typeof(RectTransform), typeof(Image) }); val6.transform.SetParent(val4, false); RectTransform component = val6.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; foodSlotUI.Icon = val6.GetComponent<Image>(); ((Graphic)foodSlotUI.Icon).raycastTarget = false; foodSlotUI.Icon.preserveAspect = true; ((Component)foodSlotUI.Icon).transform.SetAsLastSibling(); if ((Object)(object)foodSlotUI.Timer != (Object)null) { SetupDiamondTimerText(foodSlotUI.Timer); ((TMP_Text)foodSlotUI.Timer).transform.SetAsLastSibling(); } Slots[num2] = foodSlotUI; } } internal static void Place(RectTransform rt, float x, float y, float width, float height, bool fromBottomLeft = false, float rotation = 0f) { //IL_0021: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_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_0060: 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_007b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rt == (Object)null)) { Vector2 anchorMin = (rt.anchorMax = (Vector2)(fromBottomLeft ? Vector2.zero : new Vector2(0.5f, 0.5f))); rt.anchorMin = anchorMin; rt.pivot = new Vector2(0.5f, 0.5f); ((Transform)rt).localScale = Vector3.one; ((Transform)rt).localRotation = Quaternion.Euler(0f, 0f, rotation); rt.anchoredPosition = new Vector2(x, y); rt.sizeDelta = new Vector2(width, height); } } private static void UseBarGeometry(float left, float width, float height, float plate, Color track, Color plateColor) { //IL_0018: 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_001f: 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) BarLeft = left; BarWidth = width; BarHeight = height; PlateWidth = plate; BarTrackColor = track; BarPlateColor = plateColor; BarPlateColor.a = (BarTrackColor.a = HudUpdatePlugin.BarBackgroundOpacity?.Value ?? 0.75f); } private static void BuildGuardian(RectTransform root, Vector2 center, Vector2 iconPos, Vector2 iconSize, float nameY, bool outlinedName, float diamond = 100f) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00f4: Unknown result type (might be due to invalid IL or missing references) if (Buff == null || (Object)(object)Buff.Root == (Object)null) { return; } RectTransform component = Buff.Root.GetComponent<RectTransform>(); RectTransform component2 = new GameObject("GuardianContent", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)component2).SetParent((Transform)(object)root, false); Place(component2, center.x, center.y, 142f, 142f, fromBottomLeft: true); ((Transform)component).SetParent((Transform)(object)component2, false); Place(component, 0f, 0f, diamond, diamond, fromBottomLeft: false, 45f); ((Component)component).gameObject.SetActive(true); TintDiamond((Transform)(object)component); if ((Object)(object)Buff.Icon != (Object)null) { ((Component)Buff.Icon).transform.SetParent((Transform)(object)component2, false); Place(((Graphic)Buff.Icon).rectTransform, iconPos.x, iconPos.y, iconSize.x, iconSize.y); } if ((Object)(object)Buff.Timer != (Object)null) { ((TMP_Text)Buff.Timer).transform.SetParent((Transform)(object)component2, false); Place(((TMP_Text)Buff.Timer).rectTransform, 0f, nameY - 20f, 130f, 18f); StyleText(Buff.Timer, bold: false); ((TMP_Text)Buff.Timer).fontSize = 13f; ((TMP_Text)Buff.Timer).alignment = (TextAlignmentOptions)514; GuardianName = Object.Instantiate<TextMeshProUGUI>(Buff.Timer, (Transform)(object)component2); ((Object)GuardianName).name = "GuardianName"; Place(((TMP_Text)GuardianName).rectTransform, 0f, nameY, 150f, 24f); StyleText(GuardianName, bold: true); ((TMP_Text)GuardianName).fontSize = (outlinedName ? 18 : 17); if (outlinedName) { Outline(GuardianName, 0.16f); } if (outlinedName) { Outline(Buff.Timer, 0.14f); } ((TMP_Text)GuardianName).text = ""; } Buff.Root = ((Component)component2).gameObject; } private static void BuildTimerShadows() { //IL_00c6: 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_0123: 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_0138: 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) FoodSlotUI[] slots = Slots; foreach (FoodSlotUI foodSlotUI in slots) { if (foodSlotUI == null || (Object)(object)foodSlotUI.Timer == (Object)null) { continue; } TextMeshProUGUI timer = foodSlotUI.Timer; if ((Object)(object)((TMP_Text)timer).font != (Object)null && (Object)(object)((TMP_Asset)((TMP_Text)timer).font).material != (Object)null) { ((TMP_Text)timer).fontSharedMaterial = ((TMP_Asset)((TMP_Text)timer).font).material; } List<TextMeshProUGUI> list = new List<TextMeshProUGUI>(); int siblingIndex = ((TMP_Text)timer).transform.GetSiblingIndex(); for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { if (j == 0 && k == 0) { continue; } TextMeshProUGUI val = Object.Instantiate<TextMeshProUGUI>(timer, ((TMP_Text)timer).transform.parent); ((Object)val).name = "TimerRim"; foreach (Transform item in ((TMP_Text)val).transform) { Object.Destroy((Object)(object)((Component)item).gameObject); } ((TMP_Text)val).fontSharedMaterial = ((TMP_Text)timer).fontSharedMaterial; ((Graphic)val).color = FoodTimerRimColor; ((Graphic)val).raycastTarget = false; ((TMP_Text)val).rectTransform.anchoredPosition = ((TMP_Text)timer).rectTransform.anchoredPosition + new Vector2((float)j, (float)k) * 1f; ((TMP_Text)val).transform.SetSiblingIndex(siblingIndex); list.Add(val); } } ((TMP_Text)timer).transform.SetAsLastSibling(); foodSlotUI.TimerShadow = list.ToArray(); } } internal static void SyncTimerShadow(FoodSlotUI slot) { if (slot?.TimerShadow == null || (Object)(object)slot.Timer == (Object)null) { return; } TextMeshProUGUI[] timerShadow = slot.TimerShadow; foreach (TextMeshProUGUI val in timerShadow) { if (!((Object)(object)val == (Object)null)) { if (((TMP_Text)val).text != ((TMP_Text)slot.Timer).text) { ((TMP_Text)val).text = ((TMP_Text)slot.Timer).text; } ((Behaviour)val).enabled = ((Behaviour)slot.Timer).enabled; } } } private static void Outline(TextMeshProUGUI text, float width) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)text).outlineColor = new Color32((byte)12, (byte)10, (byte)8, byte.MaxValue); ((TMP_Text)text).outlineWidth = width; try { ((TMP_Text)text).fontMaterial.SetFloat(ShaderUtilities.ID_FaceDilate, width); } catch (Exception ex) { Debug.LogWarning((object)("[UIReforge] Face dilate failed: " + ex.Message)); } } internal static void ApplyReferenceLayout() { //IL_002b: 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_009b: 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_00be: 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_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) RectTransform component = Panel.GetComponent<RectTransform>(); Place(component, 32f, 26f, 550f, 200f, fromBottomLeft: true); component.pivot = Vector2.zero; Transform val = Panel.transform.Find("darken"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } UseBarGeometry(238f, 266f, 27f, 34f, new Color(PanelDark.r, PanelDark.g, PanelDark.b, 0.75f), PanelDark); BuildGuardian(component, new Vector2(80f, 105f), new Vector2(2f, 12f), new Vector2(98f, 90f), -52f, outlinedName: false); float[] array = new float[4] { 158f, 209f, 158f, 209f }; float[] array2 = new float[4] { 153f, 105f, 57f, 201f }; for (int i = 0; i < Slots.Length; i++) { FoodSlotUI foodSlotUI = Slots[i]; if (foodSlotUI != null) { Place(foodSlotUI.Root.GetComponent<RectTransform>(), array[i], array2[i], 62.5f, 62.5f, fromBottomLeft: true); Transform obj = foodSlotUI.Root.transform.Find("substrate"); Transform obj2 = ((obj is RectTransform) ? obj : null); Place((RectTransform)(object)obj2, 0f, 0f, 62.5f, 62.5f, fromBottomLeft: false, 45f); TintDiamond(obj2); if ((Object)(object)foodSlotUI.Icon != (Object)null) { Place(((Graphic)foodSlotUI.Icon).rectTransform, 0f, 2f, 28f, 28f); } PlaceGlow(foodSlotUI); SetupDiamondTimerText(foodSlotUI.Timer); } } BuildBar("Health", 122f, cutFromBottom: false, HpColor, HpTrailColor, ref HpFastImage, ref HpSlowImage, ref HpText, out HpCapacityImage); BuildBar("Stamina", 88f, cutFromBottom: true, StaminaColor, StaminaTrailColor, ref StaminaFastImage, ref StaminaSlowImage, ref StaminaText, out StaminaCapacityImage); LayoutResourceIcon("HealthIcon", 122f); LayoutResourceIcon("StaminaIcon", 88f); BuildTimerShadows(); Graphic[] componentsInChildren = Panel.GetComponentsInChildren<Graphic>(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].raycastTarget = false; } } internal static void ApplyYggdrasilLayout() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) RectTransform component = Panel.GetComponent<RectTransform>(); Place(component, 0f, 0f, 600f, 440f, fromBottomLeft: true); component.pivot = Vector2.zero; Transform val = Panel.transform.Find("darken"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } bool flag = Slots.Length >= 4; Image val2 = AddArt(component, flag ? "ygg_back" : "ygg_back3"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).transform.SetAsFirstSibling(); } Image val3 = AddArt(component, flag ? "ygg_back_glow" : "ygg_back3_glow"); if ((Object)(object)val3 != (Object)null) { ((Component)val3).transform.SetAsFirstSibling(); } for (int i = 0; i < Slots.Length; i++) { FoodSlotUI foodSlotUI = Slots[i]; if (foodSlotUI != null) { Place(foodSlotUI.Root.GetComponent<RectTransform>(), 97.86f, YggFoodY[i], 45f, 45f, fromBottomLeft: true); Transform obj = foodSlotUI.Root.transform.Find("substrate"); Transform obj2 = ((obj is RectTransform) ? obj : null); Place((RectTransform)(object)obj2, 0f, 0f, 45f, 45f, fromBottomLeft: false, 45f); TintDiamond(obj2); if ((Object)(object)foodSlotUI.Icon != (Object)null) { Place(((Graphic)foodSlotUI.Icon).rectTransform, 0f, 0.3f, 25f, 25f); } PlaceGlow(foodSlotUI); SetupDiamondTimerText(foodSlotUI.Timer); if ((Object)(object)foodSlotUI.Timer != (Object)null) { ((TMP_Text)foodSlotUI.Timer).rectTransform.anchoredPosition = new Vector2(8.1f, -9.2f); ((TMP_Text)foodSlotUI.Timer).fontSize = 10f; } } } UseBarGeometry(146f, 253.7f, 25.5f, 26.8f, YggTrack, YggTrack); BuildBar("Health", 70.25f, cutFromBottom: false, YggHp, HpTrailColor, ref HpFastImage, ref HpSlowImage, ref HpText, out HpCapacityImage); BuildBar("Stamina", 37.15f, cutFromBottom: true, YggStamina, StaminaTrailColor, ref StaminaFastImage, ref StaminaSlowImage, ref StaminaText, out StaminaCapacityImage); TextMeshProUGUI[] array = (TextMeshProUGUI[])(object)new TextMeshProUGUI[2] { HpText, StaminaText }; foreach (TextMeshProUGUI val4 in array) { if (!((Object)(object)val4 == (Object)null)) { ((TMP_Text)val4).fontSize = 13f; Outline(val4, 0.18f); } } string[] array2 = new string[2] { "HealthIcon", "StaminaIcon" }; foreach (string text in array2) { Transform val5 = Panel.transform.Find(text); if ((Object)(object)val5 != (Object)null) { ((Component)val5).gameObject.SetActive(false); } } BuildTimerShadows(); Image val6 = AddArt(component, flag ? "ygg_front_glow" : "ygg_front3_glow"); if ((Object)(object)val6 != (Object)null) { ((Component)val6).transform.SetAsLastSibling(); } Image val7 = AddArt(component, flag ? "ygg_front" : "ygg_front3"); if ((Object)(object)val7 != (Object)null) { ((Component)val7).transform.SetAsLastSibling(); } YggGlowImages = (Image[])(object)new Image[2] { val3, val6 }; ApplyYggGlow(); BuildGuardian(component, new Vector2(98.07f, 53.4f), new Vector2(-0.3f, 13.5f), new Vector2(100f, 93f), -40.5f, outlinedName: true, 75f); if ((Object)(object)GuardianName != (Object)null) { ((TMP_Text)GuardianName).fontSize = 13f; } if (Buff != null && (Object)(object)Buff.Timer != (Object)null) { ((TMP_Text)Buff.Timer).rectTransform.anchoredPosition = new Vector2(0f, -27f); ((TMP_Text)Buff.Timer).fontSize = 12f; } if (Buff != null && (Object)(object)Buff.Root != (Object)null) { Buff.Root.transform.SetAsLastSibling(); } Graphic[] componentsInChildren = Panel.GetComponentsInChildren<Graphic>(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].raycastTarget = false; } } internal static void ApplyYggGlow() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (YggGlowImages == null) { return; } float num = ((HudUpdatePlugin.YggGlow != null) ? HudUpdatePlugin.YggGlow.Value : 0.25f); Image[] yggGlowImages = YggGlowImages; foreach (Image val in yggGlowImages) { if (!((Object)(object)val == (Object)null)) { ((Graphic)val).color = new Color(1f, 1f, 1f, num); ((Behaviour)val).enabled = num > 0.001f; } } } private static Image AddArt(RectTransform root, string key) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) if (!FoodIconOverrides.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { Debug.LogWarning((object)("[UIReforge] Missing art " + key + ".png")); return null; } Image component = ((Component)NewRect("UIReforge_" + key, (Transform)(object)root, typeof(Image))).GetComponent<Image>(); Place(((Graphic)component).rectTransform, 220f, 220f, 440f, 440f, fromBottomLeft: true); component.sprite = value; ((Graphic)component).color = Color.white; component.preserveAspect = false; ((Graphic)component).raycastTarget = false; return component; } internal static void ApplyChevronLayout() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c0: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_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_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) RectTransform component = Panel.GetComponent<RectTransform>(); Place(component, 32f, 26f, 550f, 200f, fromBottomLeft: true); component.pivot = Vector2.zero; Transform val = Panel.transform.Find("darken"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(80f, 105f); Vector2 val3 = val2 + new Vector2(77f, 0f); Vector2[] array = (Vector2[])(object)new Vector2[4] { val3 + new Vector2(-1.28f, 45.62f), val3 + new Vector2(46.72f, 0.28f), val3 + new Vector2(-1.28f, -46.38f), val3 + new Vector2(152f, 0.28f) }; for (int i = 0; i < Slots.Length; i++) { FoodSlotUI foodSlotUI = Slots[i]; if (foodSlotUI != null) { Place(foodSlotUI.Root.GetComponent<RectTransform>(), array[i].x, array[i].y, 60f, 60f, fromBottomLeft: true); Transform obj = foodSlotUI.Root.transform.Find("substrate"); RectTransform val4 = (RectTransform)(object)((obj is RectTransform) ? obj : null); Place(val4, 0f, 0f, 60f, 60f, fromBottomLeft: false, 45f); TintDiamond((Transform)(object)val4); Image val5 = (((Object)(object)val4 != (Object)null) ? ((Component)val4).GetComponent<Image>() : null); if ((Object)(object)val5 != (Object)null) { ((Graphic)val5).color = ChevronCell; } if ((Object)(object)foodSlotUI.Icon != (Object)null) { Place(((Graphic)foodSlotUI.Icon).rectTransform, 0f, 0f, 33f, 33f); } PlaceGlow(foodSlotUI); SetupDiamondTimerText(foodSlotUI.Timer); if ((Object)(object)foodSlotUI.Timer != (Object)null) { ((TMP_Text)foodSlotUI.Timer).rectTransform.anchoredPosition = new Vector2(10.2f, -13.5f); StyleText(foodSlotUI.Timer, bold: false); ((TMP_Text)foodSlotUI.Timer).fontSize = 11f; } } } BuildGuardian(component, val2, new Vector2(2f, 12f), new Vector2(98f, 90f), -51.3f, outlinedName: false); if ((Object)(object)GuardianName != (Object)null) { ((TMP_Text)GuardianName).fontSize = 16f; } Image val6 = ((Buff != null && (Object)(object)Buff.Root != (Object)null) ? ((IEnumerable<Image>)Buff.Root.GetComponentsInChildren<Image>(true)).FirstOrDefault((Func<Image, bool>)((Image img) => (Object)(object)Buff.Icon == (Object)null || (Object)(object)img != (Object)(object)Buff.Icon)) : null); if ((Object)(object)val6 != (Object)null) { ((Graphic)val6).color = ChevronCell; } BuildChevron(component, val3); string[] array2 = new string[4] { "Health", "Stamina", "HealthIcon", "StaminaIcon" }; foreach (string text in array2) { Transform val7 = Panel.transform.Find(text); if ((Object)(object)val7 != (Object)null && (Object)(object)((Component)val7).GetComponent<TextMeshProUGUI>() == (Object)null) { ((Component)val7).gameObject.SetActive(false); } } StaminaFastImage = (StaminaSlowImage = null); if (!ChevronStaminaOn) { StaminaText = null; } BuildTimerShadows(); Graphic[] componentsInChildren = Panel.GetComponentsInChildren<Graphic>(true); for (int num = 0; num < componentsInChildren.Length; num++) { componentsInChildren[num].raycastTarget = false; } } private static void BuildChevron(RectTransform root, Vector2 c) { //IL_005b: 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) //IL_0068: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: 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_0319: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_029c: 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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) FoodIconOverrides.TryGetValue("chevron_shape", out var value); FoodIconOverrides.TryGetValue("chevron_outline", out var value2); if ((Object)(object)value == (Object)null) { throw new InvalidDataException("chevron_shape.png is not embedded"); } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(19.625f, 14.709999f); RectTransform val2 = NewRect("HpChevron", (Transform)(object)root); Place(val2, c.x + val.x, c.y + val.y, 198.67f, 205.34f, fromBottomLeft: true); Image component = ((Component)NewRect("track", (Transform)(object)val2, typeof(Image))).GetComponent<Image>(); Stretch(((Graphic)component).rectTransform); component.sprite = value; ((Graphic)component).color = ChevronTrack; Image component2 = ((Component)NewRect("fill", (Transform)(object)val2, typeof(Image), typeof(Mask))).GetComponent<Image>(); Stretch(((Graphic)component2).rectTransform); component2.sprite = value; ((Component)component2).GetComponent<Mask>().showMaskGraphic = false; ChevronSlow = BuildChevronSegments("slow", ((Component)component2).transform, val, ChevronTrail); ChevronFast = BuildChevronSegments("fast", ((Component)component2).transform, val, ChevronRed); HpFastImage = (HpSlowImage = null); if (ChevronStaminaOn) { BuildStaminaChevron(root, c, val); } if ((Object)(object)value2 != (Object)null) { Image component3 = ((Component)NewRect("outline", (Transform)(object)val2, typeof(Image))).GetComponent<Image>(); Stretch(((Graphic)component3).rectTransform); component3.sprite = value2; ((Graphic)component3).color = ChevronOutline; } if (ChevronStaminaOn && (Object)(object)StaminaText != (Object)null) { ((TMP_Text)StaminaText).transform.SetParent((Transform)(object)root, false); RectTransform rectTransform = ((TMP_Text)StaminaText).rectTransform; Vector2 anchorMin = (rectTransform.anchorMax = Vector2.zero); rectTransform.anchorMin = anchorMin; rectTransform.pivot = new Vector2(0f, 0.5f); ((Transform)rectTransform).localScale = Vector3.one; ((Transform)rectTransform).localRotation = Quaternion.identity; rectTransform.anchoredPosition = new Vector2(c.x + 40f, c.y - 92f); rectTransform.sizeDelta = new Vector2(90f, 22f); StyleText(StaminaText, bold: true); ((TMP_Text)StaminaText).fontSize = 16f; TextMeshProUGUI staminaText = StaminaText; Color32 val3 = (((TMP_Text)StaminaText).faceColor = Color32.op_Implicit(new Color(1f, 0.82f, 0.5f, 1f))); ((Graphic)staminaText).color = Color32.op_Implicit(val3); ((TMP_Text)StaminaText).alignment = (TextAlignmentOptions)513; ((TMP_Text)StaminaText).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)StaminaText).overflowMode = (TextOverflowModes)0; } if ((Object)(object)HpText != (Object)null) { ((TMP_Text)HpText).transform.SetParent((Transform)(object)root, false); RectTransform rectTransform2 = ((TMP_Text)HpText).rectTransform; Vector2 anchorMin = (rectTransform2.anchorMax = Vector2.zero); rectTransform2.anchorMin = anchorMin; rectTransform2.pivot = new Vector2(0f, 0.5f); ((Transform)rectTransform2).localScale = Vector3.one; ((Transform)rectTransform2).localRotation = Quaternion.identity; rectTransform2.anchoredPosition = new Vector2(c.x - 79.71f, c.y + 102f); rectTransform2.sizeDelta = new Vector2(90f, 22f); StyleText(HpText, bold: true); ((TMP_Text)HpText).fontSize = 16f; ((TMP_Text)HpText).alignment = (TextAlignmentOptions)513; ((TMP_Text)HpText).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)HpText).overflowMode = (TextOverflowModes)0; } } private static void BuildStaminaChevron(RectTransform root, Vector2 c, Vector2 mid) { //IL_0039: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_0109: 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_0124: Unknown result type (might be due to invalid IL or missing references) if (!FoodIconOverrides.TryGetValue("chevron_stamina", out var value) || (Object)(object)value == (Object)null) { Debug.LogWarning((object)"[UIReforge] chevron_stamina.png missing, stamina stays vanilla"); return; } RectTransform val = NewRect("StaminaChevron", (Transform)(object)root); Place(val, c.x + mid.x, c.y + mid.y, 230.67f, 237.34f, fromBottomLeft: true); ((Transform)val).SetSiblingIndex(0); Image component = ((Component)NewRect("track", (Transform)(object)val, typeof(Image))).GetComponent<Image>(); Stretch(((Graphic)component).rectTransform); component.sprite = value; ((Graphic)component).color = ChevronTrack; Image component2 = ((Component)NewRect("fill", (Transform)(object)val, typeof(Image), typeof(Mask))).GetComponent<Image>(); Stretch(((Graphic)component2).rectTransform); component2.sprite = value; ((Component)component2).GetComponent<Mask>().showMaskGraphic = false; ChevronStaminaSlow = BuildChevronSegments("slow", ((Component)component2).transform, mid, StaminaTrailColor); ChevronStaminaFast = BuildChevronSegments("fast", ((Component)component2).transform, mid, YggStamina); } private static void Stretch(RectTransform rt) { //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_0021: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.pivot = new Vector2(0.5f, 0.5f); Vector2 offsetMin = (rt.offsetMax = Vector2.zero); rt.offsetMin = offsetMin; ((Transform)rt).localScale = Vector3.one; ((Transform)rt).localRotation = Quaternion.identity; } private static Image[] BuildChevronSegments(string name, Transform parent, Vector2 mid, Color color) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) Image[] array = (Image[])(object)new Image[ChevPath.Length - 1]; Vector2 val2 = default(Vector2); for (int i = 0; i < array.Length; i++) { Image component = ((Component)NewRect(name + i, parent, typeof(Image))).GetComponent<Image>(); RectTransform rectTransform = ((Graphic)component).rectTransform; Vector2 val = ChevPath[i + 1] - ChevPath[i]; ((Vector2)(ref val2))..ctor(0.5f, 0.5f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0f, 0.5f); ((Transform)rectTransform).localScale = Vector3.one; ((Transform)rectTransform).localRotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(val.y, val.x) * 57.29578f); rectTransform.anchoredPosition = ChevPath[i] - mid; rectTransform.sizeDelta = new Vector2(0f, 44f); component.sprite = SolidSprite(); ((Graphic)component).color = color; ((Behaviour)component).enabled = false; array[i] = component; } return array; } internal static float BarFraction(float value, float max, ConfigEntry<float> fullValue, Image capacity) { bool flag = HudUpdatePlugin.BarScale != null && HudUpdatePlugin.BarScale.Value == BarScaleMode.Absolute && fullValue != null; float num = (flag ? Mathf.Max(1f, fullValue.Value) : max); if ((Object)(object)capacity != (Object)null) { ((Behaviour)capacity).enabled = flag; if (flag) { capacity.fillAmount = Mathf.Clamp01(max / num); } } return Mathf.Clamp01(value / num); } internal static void SetChevronFill(Image[] segments, float value) { if (segments != null) { if (segments == ChevronStaminaFast || segments == ChevronStaminaSlow) { SetChevronFill(segments, value, 40f, 14f); } else { SetChevronFill(segments, value, 44f, 0f); } } } internal static void SetChevronFill(Image[] segments, float value, float band, float offset) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_003d: 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_008b: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_013d: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) if (segments == null) { return; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(19.625f, 14.709999f); float num = 0f; for (int i = 0; i < segments.Length; i++) { float num2 = num; Vector2 val2 = ChevPath[i + 1] - ChevPath[i]; num = num2 + ((Vector2)(ref val2)).magnitude; } float num3 = Mathf.Clamp01(value) * num; Vector2 val6 = default(Vector2); for (int j = 0; j < segments.Length; j++) { Image val3 = segments[j]; if (!((Object)(object)val3 == (Object)null)) { Vector2 val4 = ChevPath[j + 1] - ChevPath[j]; float magnitude = ((Vector2)(ref val4)).magnitude; float num4 = Mathf.Clamp(num3, 0f, magnitude); num3 -= magnitude; ((Behaviour)val3).enabled = num4 > 0.05f; if (((Behaviour)val3).enabled) { Vector2 val5 = val4 / magnitude; ((Vector2)(ref val6))..ctor(val5.y, 0f - val5.x); float num5 = 14f; float num6 = ((j > 0) ? num5 : 0f); float num7 = ((num4 >= magnitude - 0.05f && j < segments.Length - 1) ? num5 : 0f); RectTransform rectTransform = ((Graphic)val3).rectTransform; rectTransform.anchoredPosition = ChevPath[j] - val - val5 * num6 - val6 * offset; rectTransform.sizeDelta = new Vector2(num6 + num4 + num7, band); } } } } private static void TintDiamond(Transform diamond) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)diamond == (Object)null) { return; } Image component = ((Component)diamond).GetComponent<Image>(); if (!((Object)(object)component == (Object)null)) { Color panelDark = PanelDark; if (CurrentStyle != HudStyle.Chevron && HudUpdatePlugin.DiamondOpacity != null) { panelDark.a = HudUpdatePlugin.DiamondOpacity.Value; } ((Graphic)component).color = panelDark; } } private static RectTransform NewRect(string name, Transform parent, params Type[] components) { //IL_0024: 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) List<Type> list = new List<Type> { typeof(RectTransform) }; list.AddRange(components); GameObject val = new GameObject(name, list.ToArray()); val.transform.SetParent(parent, false); return val.GetComponent<RectTransform>(); } private static void PlaceLeft(RectTransform rt, float left, float width, float height) { //IL_0013: 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_002a: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 0.5f); rt.anchorMax = val; rt.anchorMin = val; rt.pivot = new Vector2(0f, 0.5f); ((Transform)rt).localScale = Vector3.one; ((Transform)rt).localRotation = Quaternion.identity; rt.anchoredPosition = new Vector2(left, 0f); rt.sizeDelta = new Vector2(width, height); } private static void BuildBar(string name, float y, bool cutFromBottom, Color fill, Color trail, ref Image fast, ref Image slow, ref TextMeshProUGUI text, out Image capacity) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_019f: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) Transform val = Panel.transform.Find(name); RectTransform val2 = NewRect("UIReforge" + name, Panel.transform); Place(val2, BarLeft + BarWidth / 2f, y, BarWidth, BarHeight, fromBottomLeft: true); float num = BarWidth - PlateWidth; Sprite sprite = CreateCutSprite(num, BarHeight, cutFromBottom); Image component = ((Component)NewRect("track", (Transform)(object)val2, typeof(Image))).GetComponent<Image>(); PlaceLeft(((Graphic)component).rectTransform, 0f, num, BarHeight); component.sprite = sprite; ((Graphic)component).color = BarTrackColor; capacity = NewFilled("capacity", (Transform)(object)val2, sprite, new Color(fill.r, fill.g, fill.b, 0.22f), num); ((Behaviour)capacity).enabled = false; slow = NewFilled("slow", (Transform)(object)val2, sprite, trail, num); fast = NewFilled("fast", (Transform)(object)val2, sprite, fill, num); Image component2 = ((Component)NewRect("plate", (Transform)(object)val2, typeof(Image))).GetComponent<Image>(); PlaceLeft(((Graphic)component2).rectTransform, num, PlateWidth, BarHeight); component2.sprite = SolidSprite(); ((Graphic)component2).color = BarPlateColor; if ((Object)(object)text != (Object)null) { ((TMP_Text)text).transform.SetParent(((Component)component2).transform, false); RectTransform rectTransform = ((TMP_Text)text).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.pivot = new Vector2(0.5f, 0.5f); ((Transform)rectTransform).localScale = Vector3.one; ((Transform)rectTransform).localRotation = Quaternion.identity; rectTransform.offsetMin = new Vector2(1f, 0f); rectTransform.offsetMax = new Vector2(-1f, 0f); StyleText(text, bold: true); ((TMP_Text)text).fontSize = 15f; ((TMP_Text)text).alignment = (TextAlignmentOptions)514; ((TMP_Text)text).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)text).overflowMode = (TextOverflowModes)0; } if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } } private static Image NewFilled(string name, Transform parent, Sprite sprite, Color color, float width) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) Image component = ((Component)NewRect(name, parent, typeof(Image))).GetComponent<Image>(); PlaceLeft(((Graphic)component).rectTransform, 0f, width, BarHeight); component.sprite = sprite; ((Graphic)component).color = color; component.type = (Type)3; component.fillMethod = (FillMethod)0; component.fillOrigin = 0; component.fillAmount = 1f; component.preserveAspect = false; return component; } private static Sprite SolidSprite() { //IL_0026: 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) if ((Object)(object)solidSprite == (Object)null) { solidSprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 4f, 4f), new Vector2(0.5f, 0.5f)); Object.DontDestroyOnLoad((Object)(object)solidSprite); } return solidSprite; } private static Sprite CreateCutSprite(float width, float height, bool cutFromBottom) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0127: 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_00e5: 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) string text = width + "x" + height + (cutFromBottom ? "b" : "t"); if (cutSprites.TryGetValue(text, out var value) && (Object)(object)value != (Object)null) { return value; } int num = Mathf.RoundToInt(width * 4f); int num2 = Mathf.RoundToInt(height * 4f); Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; Color32[] array = (Color32[])(object)new Color32[num * num2]; for (int i = 0; i < num2; i++) { float num3 = (cutFromBottom ? ((float)i + 0.5f) : ((float)(num2 - i) - 0.5f)); for (int j = 0; j < num; j++) { float num4 = Mathf.Clamp01((float)j + 0.5f - num3 + 0.5f); array[i * num + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(num4 * 255f)); } } val.SetPixels32(array); val.Apply(false, true); Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num2), new Vector2(0.5f, 0.5f), 100f); ((Object)val2).name = "UIReforgeBarCut_" + text; Object.DontDestroyOnLoad((Object)(object)val); Object.DontDestroyOnLoad((Object)(object)val2); cutSprites[text] = val2; return val2; } internal static void SetupDiamondTimerText(TextMeshProUGUI text) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_005a: 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) if (!((Object)(object)text == (Object)null)) { RectTransform rectTransform = ((TMP_Text)text).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.anchoredPosition = new Vector2(12f, -13f); rectTransform.sizeDelta = new Vector2(46f, 20f); StyleText(text, bold: true); ((TMP_Text)text).fontSize = 14f; ((TMP_Text)text).alignment = (TextAlignmentOptions)514; ((TMP_Text)text).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)text).overflowMode = (TextOverflowModes)0; } } private static void LayoutResourceIcon(string name, float y) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) Transform val = Panel.transform.Find(name); Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null); if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }); val3.transform.SetParent(Panel.transform, false); val2 = val3.GetComponent<Image>(); } if (FoodIconOverrides.TryGetValue(name, out var value)) { val2.sprite = value; } ((Graphic)val2).color = Color.white; val2.preserveAspect = true; ((Behaviour)val2).enabled = (Object)(object)val2.sprite != (Object)null; Place(((Graphic)val2).rectTransform, BarLeft + BarWidth + 10f, y, 12f, 14f, fromBottomLeft: true); ((Component)val2).transform.SetAsLastSibling(); } private static void StyleText(TextMeshProUGUI text, bool bold) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)text).enableAutoSizing = false; ((TMP_Text)text).fontStyle = (FontStyles)(bold ? 1 : 0); ((Graphic)text).color = Color.white; ((TMP_Text)text).faceColor = Color32.op_Implicit(Color.white); ((TMP_Text)text).outlineWidth = 0f; ((TMP_Text)text).enableVertexGradient = false; ((TMP_Text)text).characterSpacing = 0f; } internal static void FindBarGroup(Transform groupRoot, out Image fastImage, out Image slowImage, out TextMeshProUGUI text) { //IL_00a5: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) fastImage = null; slowImage = null; text = null; if ((Object)(object)groupRoot == (Object)null) { return; } Transform val = groupRoot.Find("Mask"); Transform val2 = groupRoot.Find("Mask/fast/bar"); Transform val3 = groupRoot.Find("Mask/slow/bar"); if ((Object)(object)val2 != (Object)null) { fastImage = ((Component)val2).GetComponent<Image>(); SetupFilledBar(fastImage); } if ((Object)(object)val3 != (Object)null) { slowImage = ((Component)val3).GetComponent<Image>(); SetupFilledBar(slowImage); } text = ((Component)groupRoot).GetComponentInChildren<TextMeshProUGUI>(true); if ((Object)(object)text != (Object)null) { RectTransform rectTransform = ((TMP_Text)text).rectTransform; RectTransform val4 = (RectTransform)(object)((val is RectTransform) ? val : null); if (val4 != null) { ((Transform)rectTransform).SetParent((Transform)(object)val4, true); } rectTransform.anchorMin = new Vector2(1f, 0.5f); rectTransform.anchorMax = new Vector2(1f, 0.5f); rectTransform.pivot = new Vector2(1f, 0.5f); rectTransform.anchoredPosition = new Vector2(-10f, 0f); rectTransform.sizeDelta = new Vector2(80f, rectTransform.sizeDelta.y); ((TMP_Text)text).alignment = (TextAlignmentOptions)516; ((TMP_Text)text).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)text).overflowMode = (TextOverflowModes)0; ((TMP_Text)text).transform.SetAsLastSibling(); } } internal static void SetupFilledBar(Image img) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)img == (Object)null)) { img.type = (Type)3; img.fillMethod = (FillMethod)0; img.fillOrigin = 0; if ((Object)(object)SolidBarSprite == (Object)null) { SolidBarSprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f)); } img.sprite = SolidBarSprite; img.preserveAspect = false; } } internal static void HideVanillaStamina(Hud hud) { string[] array = new string[4] { "Stamina", "stamina", "StaminaBar", "StaminaPanel" }; Transform[] componentsInChildren = hud.m_rootObject.GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { string[] array2 = array; for (int j = 0; j < array2.Length; j++) { if (string.Equals(array2[j], ((Object)val).name, StringComparison.OrdinalIgnoreCase) && ((Object)(object)Panel == (Object)null || !val.IsChildOf(Panel.transform))) { if (((Component)val).gameObject.activeSelf) { HiddenVanillaStamina.Add(((Component)val).gameObject); } ((Component)val).gameObject.SetActive(false); break; } } } } internal static void CaptureVanillaGuardian(Hud hud) { try { if ((Object)(object)hud?.m_rootObject == (Object)null) { return; } Transform val = FindDeepChild(hud.m_rootObject.transform, "GuardianPower"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"[UIReforge] Vanilla GuardianPower not found"); return; } VanillaGuardianRoot = ((Component)val).gameObject; Transform obj = val.Find("Icon"); VanillaGuardianIcon = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null); Transform val2 = val.Find("TimeBar"); if ((Object)(object)val2 != (Object)null) { VanillaGuardianTimeBar = ((Component)val2).GetComponent<Image>(); if ((Object)(object)VanillaGuardianTimeBar == (Object)null) { VanillaGuardianTimeBar = ((Component)val2).GetComponentInChildren<Image>(true); } } Transform obj2 = val.Find("TimeText"); VanillaGuardianTimeText = ((obj2 != null) ? ((Component)obj2).GetComponent<TextMeshProUGUI>() : null); if ((Object)(object)VanillaGuardianTimeText == (Object)null) { VanillaGuardianTimeText = ((Component)val).GetComponentInChildren<TextMeshProUGUI>(true); } Transform obj3 = val.Find("TimeText"); VanillaGuardianLegacyTimeText = ((obj3 != null) ? ((Component)obj3).GetComponent<Text>() : null); if ((Object)(object)VanillaGuardianLegacyTimeText == (Object)null) { VanillaGuardianLegacyTimeText = ((Component)val).GetComponentInChildren<Text>(true); } Transform obj4 = val.Find("Name"); VanillaGuardianNameText = ((obj4 != null) ? ((Component)obj4).GetComponent<TextMeshProUGUI>() : null); if ((Object)(object)VanillaGuardianNameText == (Object)null) { VanillaGuardianNameText = ((IEnumerable<TextMeshProUGUI>)((Component)val).GetComponentsInChildren<TextMeshProUGUI>(true)).FirstOrDefault((Func<TextMeshProUGUI, bool>)((TextMeshProUGUI x) => ((Object)x).name == "Name")); } Transform obj5 = val.Find("Name"); VanillaGuardianLegacyNameText = ((obj5 != null) ? ((Component)obj5).GetComponent<Text>() : null); if ((Object)(object)VanillaGuardianLegacyNameText == (Object)null) { VanillaGuardianLegacyNameText = ((IEnumerable<Text>)((Component)val).GetComponentsInChildren<Text>(true)).FirstOrDefault((Func<Text, bool>)((Text x) => ((Object)x).name == "Name")); } } catch (Exception ex) { Debug.LogError((object)("[UIReforge] CaptureVanillaGuardian error: " + ex)); } } internal static void HideVanillaGuardianVisuals() { try { if (!((Object)(object)VanillaGuardianRoot == (Object)null)) { Graphic[] componentsInChildren = VanillaGuardianRoot.GetComponentsInChildren<Graphic>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } } } catch (Exception ex) { Debug.LogError((object)("[UIReforge] HideVanillaGuardianVisuals error: " + ex)); } } internal static void RefreshGuardian(Hud hud) { if (guardianUpdateFrame == Time.frameCount) { return; } guardianUpdateFrame = Time.frameCount; try { if (!((Object)(object)hud == (Object)null)) { if ((Object)(object)VanillaGuardianRoot == (Object)null) { CaptureVanillaGuardian(hud); } HideVanillaGuardianVisuals(); SyncGuardianFromVanilla(); } } catch (Exception ex) { Debug.LogError((object)("[UIReforge] RefreshGuardian error: " + ex)); } } internal static void SyncGuardianFromVanilla() { //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) try { if (Buff == null || (Object)(object)Buff.Root == (Object)null) { return; } if ((Object)(object)VanillaGuardianRoot == (Object)null) { Buff.Root.SetActive(false); return; } string text = string.Empty; if ((Object)(object)VanillaGuardianTimeText != (Object)null) { text = ((TMP_Text)VanillaGuardianTimeText).text; } else if ((Object)(object)VanillaGuardianLegacyTimeText != (Object)null) { text = VanillaGuardianLegacyTimeText.text; } string text2 = string.Empty; if ((Object)(object)VanillaGuardianNameText != (Object)null) { text2 = ((TMP_Text)VanillaGuardianNameText).text; } else if ((Object)(object)VanillaGuardianLegacyNameText != (Object)null) { text2 = VanillaGuardianLegacyNameText.text; } if ((Object)(object)GuardianName != (Object)null) { ((TMP_Text)GuardianName).text = text2.ToUpperInvariant(); } Sprite vanillaSprite = (((Object)(object)VanillaGuardianIcon != (Object)null) ? VanillaGuardianIcon.sprite : null); Sprite val = ResolveGuardianIcon(text2, vanillaSprite); bool flag = (Object)(object)val != (Object)null || !string.IsNullOrWhiteSpace(text); Buff.Root.SetActive(flag); if (!flag) { return; } if ((Object)(object)Buff.Icon != (Object)null) { Buff.Icon.sprite = val; ((Behaviour)Buff.Icon).enabled = true; ((Component)Buff.Icon).gameObject.SetActive(true); ((Graphic)Buff.Icon).color = Color.white; Buff.Icon.preserveAspect = true; ((Component)Buff.Icon).transform.localScale = Vector3.one; ((Component)Buff.Icon).transform.SetAsLastSibling(); } if ((Object)(object)Buff.Timer != (Object)null) { float num = 0f; if ((Object)(object)Player.m_localPlayer != (Object)null) { StatusEffect val2 = default(StatusEffect); Player.m_localPlayer.GetGuardianPowerHUD(ref val2, ref num); } ((TMP_Text)Buff.Timer).text = text; ((Behaviour)Buff.Timer).enabled = num > 0f; ((TMP_Text)Buff.Timer).transform.SetAsLastSibling(); } } catch (Exception ex) { Debug.LogError((object)("[UIReforge] SyncGuardianFromVanilla error: " + ex)); } } internal static Sprite ResolveGuardianIcon(string guardianName, Sprite vanillaSprite) { try { string text = (((Object)(object)Player.m_localPlayer != (Object)null) ? Player.m_localPlayer.GetGuardianPowerName() : null); if (!string.IsNullOrEmpty(text) && GuardianEmblems.TryGetValue(text, out var value) && FoodIconOverrides.TryGetValue(value, out var value2)) { return value2; } if (!string.IsNullOrEmpty(text) && FoodIconOverrides.TryGetValue(text, out var value3)) { return value3; } if (!string.IsNullOrWhiteSpace(guardianName)) { string text2 = guardianName.ToLowerInvariant().Replace("$", "").Replace("guardian_", ""); foreach (KeyValuePair<string, string> guardianEmblem in GuardianEmblems) { if (text2.Contains(guardianEmblem.Value.ToLowerInvariant().Replace("the", "")) && FoodIconOverrides.TryGetValue(guardianEmblem.Value, out var value4)) { return value4; } } if (FoodIconOverrides.TryGetValue(guardianName, out var value5)) { return value5; } } if ((Object)(object)vanillaSprite != (Object)null && FoodIconOverrides.TryGetValue(((Object)vanillaSprite).name, out var value6)) { return value6; } } catch (Exception ex) { Debug.LogError((object)("[UIReforge] ResolveGuardianIcon error: " + ex)); } return vanillaSprite; } internal static Transform FindDeepChild(Transform parent, string exactName) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if ((Object)(object)parent == (Object)null) { return null; } foreach (Transform item in parent) { Transform val = item; if (string.Equals(((Object)val).name, exactName, StringComparison.Ordinal)) { return val; } Transform val2 = FindDeepChild(val, exactName); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } internal static Image FindVanillaFoodIconImage(Transform slotTr) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Image[] componentsInChildren = ((Component)slotTr).GetComponentsInChildren<Image>(true); foreach (Image val in componentsInChildren) { if (!(((Object)val).name == "UIReforgeIcon") && !(((Object)val).name == "UIReforgeGlow")) { RectTransform rectTransform = ((Graphic)val).rectTransform; if ((!(rectTransform.anchorMin == Vector2.zero) || !(rectTransform.anchorMax == Vector2.one) || !(rectTransform.offsetMin == Vector2.zero) || !(rectTransform.offsetMax == Vector2.zero)) && (val.preserveAspect || ((Object)val).name.ToLower().Contains("icon"))) { return val; } } } return null; } internal static string FormatTime(float seconds) { int num = Mathf.CeilToInt(Mathf.Max(0f, seconds)); if (num < 60) { return $"{num}s"; } return $"{Mathf.CeilToInt((float)num / 60f)}m"; } internal static FoodStat DominantStat(ItemData item) { SharedData val = item?.m_shared; if (val == null) { return FoodStat.Neutral; } float[] array = new float[3] { val.m_food, val.m_foodStamina, val.m_foodEitr }; int num = 0; for (int i = 1; i < array.Length; i++) { if (array[i] > array[num]) { num = i; } } float num2 = 0f; for (int j = 0; j < array.Length; j++) { if (j != num) { num2 = Mathf.Max(num2, array[j]); } } if (array[num] <= 0f || array[num] < num2 * 1.3f) { return FoodStat.Neutral; } return num switch { 1 => FoodStat.Stamina, 0 => FoodStat.Health, _ => FoodStat.Eitr, }; } internal static Color GlowColor(FoodStat stat) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) return (Color)(stat switch { FoodStat.Health => new Color(1f, 0.22f, 0.18f, 1f), FoodStat.Stamina => new Color(1f, 0.78f, 0.22f, 1f), FoodStat.Eitr => new Color(0.32f, 0.58f, 1f, 1f), _ => new Color(1f, 1f, 1f, 0.5f), }); } internal static Color TintColor(FoodStat stat) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) return (Color)(stat switch { FoodStat.Health => new Color(1f, 0.64f, 0.6f, 1f), FoodStat.Stamina => new Color(1f, 0.88f, 0.56f, 1f), FoodStat.Eitr => new Color(0.68f, 0.8f, 1f, 1f), _ => Color.white, });