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 Style; internal static ConfigEntry FoodColor; internal static ConfigEntry UseVanillaFoodIcons; internal static ConfigEntry FoodGlowStrength; internal static ConfigEntry BarScale; internal static ConfigEntry HealthBarMax; internal static ConfigEntry StaminaBarMax; internal static ConfigEntry DiamondOpacity; internal static ConfigEntry BarBackgroundOpacity; internal static ConfigEntry HudScale; internal static ConfigEntry YggGlow; internal static ConfigEntry ChevronStamina; internal static ConfigEntry 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("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("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("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("Food", "FoodGlowStrength", 0.7f, new ConfigDescription("Glow opacity, 0 - invisible, 1 - strongest.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); BarScale = ((BaseUnityPlugin)this).Config.Bind("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("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(25f, 1000f), Array.Empty())); StaminaBarMax = ((BaseUnityPlugin)this).Config.Bind("Bars", "StaminaBarMax", 200f, new ConfigDescription("Stamina that fills the whole bar with BarScale = Absolute.", (AcceptableValueBase)(object)new AcceptableValueRange(25f, 1000f), Array.Empty())); DiamondOpacity = ((BaseUnityPlugin)this).Config.Bind("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(0f, 1f), Array.Empty())); DiamondOpacity.SettingChanged += delegate { HudState.RequestRebuild(); }; BarBackgroundOpacity = ((BaseUnityPlugin)this).Config.Bind("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(0f, 1f), Array.Empty())); BarBackgroundOpacity.SettingChanged += delegate { HudState.RequestRebuild(); }; HudScale = ((BaseUnityPlugin)this).Config.Bind("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(0.5f, 2f), Array.Empty())); HudScale.SettingChanged += delegate { HudState.RequestRebuild(); }; ChevronStamina = ((BaseUnityPlugin)this).Config.Bind("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("Yggdrasil", "GlowStrength", 0.25f, new ConfigDescription("Blue glow around the branches, 0 - none, 1 - as in the mockup.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); YggGlow.SettingChanged += delegate { HudState.ApplyYggGlow(); }; ExtraSlotsLayout = ((BaseUnityPlugin)this).Config.Bind("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 HiddenVanillaStamina = new List(); 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 EmbeddedFoodIcons = new Dictionary(); private static bool embeddedIconsLoaded; internal static readonly Dictionary FoodIconOverrides = new Dictionary(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 NonFoodIcons = new HashSet(StringComparer.OrdinalIgnoreCase) { "HealthIcon", "StaminaIcon", "chevron_shape", "chevron_outline", "Eikthyr", "TheElder", "Bonemass" }; private static readonly List LoadedIconObjects = new List(); 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 cutSprites = new Dictionary(); private static readonly Dictionary GuardianEmblems = new Dictionary(StringComparer.Ordinal) { { "GP_Eikthyr", "Eikthyr" }, { "GP_TheElder", "TheElder" }, { "GP_Bonemass", "Bonemass" } }; private static readonly Dictionary GlowSprites = new Dictionary(); private static Sprite radialGlow; private const float GlowScale = 1.7f; private static readonly Dictionary FoodGlyphByPrefab = new Dictionary(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("healthpanel"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"[UIReforge] Failed to load prefab 'healthpanel' from bundle"); return; } DefaultFoodIcon = HudBundle.LoadAsset("default-food-icon"); LoadFoodIconsBundle(); TmpFontFix.ApplyFontsToPrefab(val); Panel = Object.Instantiate(val, hud.m_rootObject.transform); ((Object)Panel).name = "CustomHealthPanel"; TmpFontFix.FixFontsOnInstance(Panel); MonoBehaviour[] componentsInChildren = Panel.GetComponentsInChildren(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(); 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 dictionary = new Dictionary(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 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 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() : null); Transform obj3 = val.Find("time"); obj.Timer = ((obj3 != null) ? ((Component)obj3).GetComponent() : 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 list = new List(); 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(((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(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(); ((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(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; foodSlotUI.Icon = val6.GetComponent(); ((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 component2 = new GameObject("GuardianContent", new Type[1] { typeof(RectTransform) }).GetComponent(); ((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(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 list = new List(); 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(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(); 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(), 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(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(); 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(), 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(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(); 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(); 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(), 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() : 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)Buff.Root.GetComponentsInChildren(true)).FirstOrDefault((Func)((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() == (Object)null) { ((Component)val7).gameObject.SetActive(false); } } StaminaFastImage = (StaminaSlowImage = null); if (!ChevronStaminaOn) { StaminaText = null; } BuildTimerShadows(); Graphic[] componentsInChildren = Panel.GetComponentsInChildren(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(); Stretch(((Graphic)component).rectTransform); component.sprite = value; ((Graphic)component).color = ChevronTrack; Image component2 = ((Component)NewRect("fill", (Transform)(object)val2, typeof(Image), typeof(Mask))).GetComponent(); Stretch(((Graphic)component2).rectTransform); component2.sprite = value; ((Component)component2).GetComponent().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(); 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(); Stretch(((Graphic)component).rectTransform); component.sprite = value; ((Graphic)component).color = ChevronTrack; Image component2 = ((Component)NewRect("fill", (Transform)(object)val, typeof(Image), typeof(Mask))).GetComponent(); Stretch(((Graphic)component2).rectTransform); component2.sprite = value; ((Component)component2).GetComponent().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(); 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 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(); 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 list = new List { typeof(RectTransform) }; list.AddRange(components); GameObject val = new GameObject(name, list.ToArray()); val.transform.SetParent(parent, false); return val.GetComponent(); } 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(); 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(); 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(); 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() : 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(); } 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(); SetupFilledBar(fastImage); } if ((Object)(object)val3 != (Object)null) { slowImage = ((Component)val3).GetComponent(); SetupFilledBar(slowImage); } text = ((Component)groupRoot).GetComponentInChildren(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(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() : null); Transform val2 = val.Find("TimeBar"); if ((Object)(object)val2 != (Object)null) { VanillaGuardianTimeBar = ((Component)val2).GetComponent(); if ((Object)(object)VanillaGuardianTimeBar == (Object)null) { VanillaGuardianTimeBar = ((Component)val2).GetComponentInChildren(true); } } Transform obj2 = val.Find("TimeText"); VanillaGuardianTimeText = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); if ((Object)(object)VanillaGuardianTimeText == (Object)null) { VanillaGuardianTimeText = ((Component)val).GetComponentInChildren(true); } Transform obj3 = val.Find("TimeText"); VanillaGuardianLegacyTimeText = ((obj3 != null) ? ((Component)obj3).GetComponent() : null); if ((Object)(object)VanillaGuardianLegacyTimeText == (Object)null) { VanillaGuardianLegacyTimeText = ((Component)val).GetComponentInChildren(true); } Transform obj4 = val.Find("Name"); VanillaGuardianNameText = ((obj4 != null) ? ((Component)obj4).GetComponent() : null); if ((Object)(object)VanillaGuardianNameText == (Object)null) { VanillaGuardianNameText = ((IEnumerable)((Component)val).GetComponentsInChildren(true)).FirstOrDefault((Func)((TextMeshProUGUI x) => ((Object)x).name == "Name")); } Transform obj5 = val.Find("Name"); VanillaGuardianLegacyNameText = ((obj5 != null) ? ((Component)obj5).GetComponent() : null); if ((Object)(object)VanillaGuardianLegacyNameText == (Object)null) { VanillaGuardianLegacyNameText = ((IEnumerable)((Component)val).GetComponentsInChildren(true)).FirstOrDefault((Func)((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(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 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(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, }); } internal static bool IsStyledIcon(Sprite sprite) { if ((Object)(object)sprite != (Object)null) { if (!GlowSprites.ContainsKey(sprite)) { return FoodIconOverrides.ContainsValue(sprite); } return true; } return false; } private static void PlaceGlow(FoodSlotUI slot) { //IL_003b: 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_0051: 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) if (!((Object)(object)slot?.Glow == (Object)null) && !((Object)(object)slot.Icon == (Object)null)) { RectTransform rectTransform = ((Graphic)slot.Icon).rectTransform; Place(((Graphic)slot.Glow).rectTransform, rectTransform.anchoredPosition.x, rectTransform.anchoredPosition.y, rectTransform.sizeDelta.x * 1.7f, rectTransform.sizeDelta.y * 1.7f); } } internal static void UpdateFoodColour(FoodSlotUI slot, Sprite icon, ItemData item, float blink) { //IL_004d: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) FoodIconColorMode foodIconColorMode = ((HudUpdatePlugin.FoodColor != null) ? HudUpdatePlugin.FoodColor.Value : FoodIconColorMode.Off); FoodStat stat = DominantStat(item); bool flag = foodIconColorMode == FoodIconColorMode.Tint || foodIconColorMode == FoodIconColorMode.TintAndGlow; bool flag2 = foodIconColorMode == FoodIconColorMode.Glow || foodIconColorMode == FoodIconColorMode.TintAndGlow; if ((Object)(object)slot.Icon != (Object)null) { Color color = ((flag && IsStyledIcon(icon)) ? TintColor(stat) : Color.white); color.a = blink; ((Graphic)slot.Icon).color = color; } if (!((Object)(object)slot.Glow == (Object)null)) { float num = ((HudUpdatePlugin.FoodGlowStrength != null) ? HudUpdatePlugin.FoodGlowStrength.Value : 0.7f); ((Behaviour)slot.Glow).enabled = flag2 && (Object)(object)icon != (Object)null && num > 0f; if (((Behaviour)slot.Glow).enabled) { slot.Glow.sprite = (((Object)(object)icon != (Object)null && GlowSprites.TryGetValue(icon, out var value)) ? value : RadialGlow()); Color color2 = GlowColor(stat); color2.a *= num * blink; ((Graphic)slot.Glow).color = color2; } } } internal static void HideFoodGlow(FoodSlotUI slot) { if ((Object)(object)slot?.Glow != (Object)null) { ((Behaviour)slot.Glow).enabled = false; } } private static Sprite BuildGlowSprite(Texture2D source, string key) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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) //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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.RoundToInt(37.647057f); int num2 = (64 - num) / 2; float[] array = new float[4096]; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { array[(i + num2) * 64 + j + num2] = source.GetPixelBilinear(((float)j + 0.5f) / (float)num, ((float)i + 0.5f) / (float)num).a; } } float[] array2 = new float[4096]; for (int k = 0; k < 3; k++) { BoxBlur(array, array2, 64, 3, horizontal: true); BoxBlur(array2, array, 64, 3, horizontal: false); } float num3 = 0f; float[] array3 = array; foreach (float num4 in array3) { num3 = Mathf.Max(num3, num4); } if (num3 <= 0f) { num3 = 1f; } Color32[] array4 = (Color32[])(object)new Color32[4096]; for (int m = 0; m < array4.Length; m++) { array4[m] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(Mathf.Pow(array[m] / num3, 0.8f) * 255f)); } Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, name = key + "_glow" }; val.SetPixels32(array4); val.Apply(false, true); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); ((Object)obj).name = key + "_glow"; Object.DontDestroyOnLoad((Object)(object)val); Object.DontDestroyOnLoad((Object)(object)obj); return obj; } private static void BoxBlur(float[] src, float[] dst, int size, int radius, bool horizontal) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num = 0f; for (int k = -radius; k <= radius; k++) { int num2 = (horizontal ? (j + k) : j); int num3 = (horizontal ? i : (i + k)); if (num2 >= 0 && num3 >= 0 && num2 < size && num3 < size) { num += src[num3 * size + num2]; } } dst[i * size + j] = num / (float)(radius * 2 + 1); } } } private static Sprite RadialGlow() { //IL_00cc: 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_00d8: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_011f: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)radialGlow != (Object)null) { return radialGlow; } Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = ((float)j + 0.5f) / 64f * 2f - 1f; float num2 = ((float)i + 0.5f) / 64f * 2f - 1f; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = Mathf.Clamp01(1f - num3); array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(num4 * num4 * 255f)); } } Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1 }; val.SetPixels32(array); val.Apply(false, true); radialGlow = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); Object.DontDestroyOnLoad((Object)val); Object.DontDestroyOnLoad((Object)(object)radialGlow); return radialGlow; } private static Sprite FoodGlyph(string glyph) { if (glyph == null || !FoodIconOverrides.TryGetValue("food_" + glyph, out var value)) { return null; } return value; } internal static Sprite ResolveFoodIcon(Food food) { ItemData val = food?.m_item; if (val == null) { return DefaultFoodIcon; } object obj = ResolveItemIcon(val, null); if (obj == null) { if (val.m_shared?.m_icons == null || val.m_shared.m_icons.Length == 0) { return DefaultFoodIcon; } obj = val.m_shared.m_icons[0]; } return (Sprite)obj; } internal static Sprite ResolveItemIcon(ItemData item, Sprite fallback) { ConfigEntry useVanillaFoodIcons = HudUpdatePlugin.UseVanillaFoodIcons; if (useVanillaFoodIcons != null && useVanillaFoodIcons.Value) { return fallback; } if (item == null || item.m_shared == null) { return fallback; } if (item.m_shared.m_food <= 0f && item.m_shared.m_foodStamina <= 0f && item.m_shared.m_foodEitr <= 0f) { return fallback; } string text = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : null); string text2 = ((item.m_shared != null) ? item.m_shared.m_name : null); if (text2 != null && FoodIconOverrides.TryGetValue(text2, out var value)) { return value; } if (text != null && FoodIconOverrides.TryGetValue(text, out var value2)) { return value2; } string text3 = text2?.Replace("$item_", "").Replace("_", ""); if (text3 != null && FoodIconOverrides.TryGetValue(text3, out var value3)) { return value3; } if (text != null && FoodGlyphByPrefab.TryGetValue(text, out var value4)) { Sprite val = FoodGlyph(value4); if ((Object)(object)val != (Object)null) { return val; } } string text4 = (text + " " + text3).ToLowerInvariant(); string[][] foodGlyphKeywords = FoodGlyphKeywords; foreach (string[] array in foodGlyphKeywords) { if (text4.Contains(array[0])) { Sprite val2 = FoodGlyph(array[1]); if (!((Object)(object)val2 != (Object)null)) { break; } return val2; } } return fallback; } } [HarmonyPatch] internal static class HudHealthPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Hud), "UpdateHealth", (Type[])null, (Type[])null); } private static bool Prefix(Hud __instance) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } HudState.EnsureInit(__instance); if ((Object)(object)HudState.Panel == (Object)null) { return true; } HudState.RefreshGuardian(__instance); float health = ((Character)localPlayer).GetHealth(); float max = Mathf.Max(1f, ((Character)localPlayer).GetMaxHealth()); float num = HudState.BarFraction(health, max, HudUpdatePlugin.HealthBarMax, HudState.HpCapacityImage); if (HudState.HpFastValue < 0f) { HudState.HpFastValue = num; HudState.HpSlowValue = num; } float deltaTime = Time.deltaTime; HudState.HpFastValue = num; HudState.HpSlowValue = ((num >= HudState.HpSlowValue) ? num : Mathf.MoveTowards(HudState.HpSlowValue, num, 0.3f * deltaTime)); if ((Object)(object)HudState.HpFastImage != (Object)null) { HudState.HpFastImage.fillAmount = HudState.HpFastValue; } if ((Object)(object)HudState.HpSlowImage != (Object)null) { HudState.HpSlowImage.fillAmount = HudState.HpSlowValue; } HudState.SetChevronFill(HudState.ChevronFast, HudState.HpFastValue); HudState.SetChevronFill(HudState.ChevronSlow, HudState.HpSlowValue); if ((Object)(object)HudState.HpText != (Object)null) { ((TMP_Text)HudState.HpText).text = ((HudState.ActiveStyle == HudStyle.Chevron) ? (Mathf.RoundToInt(health) + " HP") : Mathf.RoundToInt(health).ToString()); } return false; } } [HarmonyPatch] internal static class HudStaminaPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Hud), "UpdateStamina", (Type[])null, (Type[])null); } private static bool Prefix(Hud __instance) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } HudState.EnsureInit(__instance); if ((Object)(object)HudState.Panel == (Object)null) { return true; } HudState.RefreshGuardian(__instance); if (HudState.ActiveStyle == HudStyle.Chevron && !HudState.ChevronStaminaOn) { return true; } float stamina = localPlayer.GetStamina(); float max = Mathf.Max(1f, ((Character)localPlayer).GetMaxStamina()); float num = HudState.BarFraction(stamina, max, HudUpdatePlugin.StaminaBarMax, HudState.StaminaCapacityImage); if (HudState.StaminaFastValue < 0f) { HudState.StaminaFastValue = num; HudState.StaminaSlowValue = num; } float deltaTime = Time.deltaTime; HudState.StaminaFastValue = num; HudState.StaminaSlowValue = ((num >= HudState.StaminaSlowValue) ? num : Mathf.MoveTowards(HudState.StaminaSlowValue, num, 1.2f * deltaTime)); if ((Object)(object)HudState.StaminaFastImage != (Object)null) { HudState.StaminaFastImage.fillAmount = HudState.StaminaFastValue; } if ((Object)(object)HudState.StaminaSlowImage != (Object)null) { HudState.StaminaSlowImage.fillAmount = HudState.StaminaSlowValue; } HudState.SetChevronFill(HudState.ChevronStaminaFast, HudState.StaminaFastValue); HudState.SetChevronFill(HudState.ChevronStaminaSlow, HudState.StaminaSlowValue); if ((Object)(object)HudState.StaminaText != (Object)null) { ((TMP_Text)HudState.StaminaText).text = Mathf.RoundToInt(stamina).ToString(); } return false; } } [HarmonyPatch] internal static class HudFoodPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Hud), "UpdateFood", (Type[])null, (Type[])null); } private static bool Prefix(Hud __instance) { //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } HudState.EnsureInit(__instance); if ((Object)(object)HudState.Panel == (Object)null) { return true; } List foods = localPlayer.GetFoods(); for (int i = 0; i < HudState.Slots.Length; i++) { HudState.FoodSlotUI foodSlotUI = HudState.Slots[i]; if (foodSlotUI == null || (Object)(object)foodSlotUI.Root == (Object)null) { continue; } if (i < foods.Count) { foodSlotUI.Root.SetActive(true); Food val = foods[i]; Sprite val2 = HudState.ResolveFoodIcon(val); if ((Object)(object)foodSlotUI.Icon != (Object)null) { foodSlotUI.Icon.sprite = val2; ((Behaviour)foodSlotUI.Icon).enabled = true; ((Transform)((Graphic)foodSlotUI.Icon).rectTransform).localScale = Vector3.one; } float blink = (val.CanEatAgain() ? (0.7f + Mathf.Sin(Time.time * 5f) * 0.3f) : 1f); HudState.UpdateFoodColour(foodSlotUI, val2, val.m_item, blink); if ((Object)(object)foodSlotUI.Timer != (Object)null) { ((TMP_Text)foodSlotUI.Timer).text = HudState.FormatTime(val.m_time); ((Behaviour)foodSlotUI.Timer).enabled = true; } HudState.SyncTimerShadow(foodSlotUI); } else { foodSlotUI.Root.SetActive(true); if ((Object)(object)foodSlotUI.Icon != (Object)null) { foodSlotUI.Icon.sprite = HudState.DefaultFoodIcon; ((Behaviour)foodSlotUI.Icon).enabled = (Object)(object)HudState.DefaultFoodIcon != (Object)null; ((Graphic)foodSlotUI.Icon).color = new Color(1f, 1f, 1f, 0.35f); ((Transform)((Graphic)foodSlotUI.Icon).rectTransform).localScale = Vector3.one; } HudState.HideFoodGlow(foodSlotUI); if ((Object)(object)foodSlotUI.Timer != (Object)null) { ((Behaviour)foodSlotUI.Timer).enabled = false; } HudState.SyncTimerShadow(foodSlotUI); } } return false; } } internal static class TmpFontFix { private static TMP_FontAsset _defaultFont; private static bool _logged; private static TMP_FontAsset GetDefaultFont() { if ((Object)(object)_defaultFont != (Object)null) { return _defaultFont; } _defaultFont = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((TMP_FontAsset f) => (Object)(object)f != (Object)null && ((Object)f).name == "LiberationSans SDF")); if ((Object)(object)_defaultFont == (Object)null) { _defaultFont = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((TMP_FontAsset f) => (Object)(object)f != (Object)null && ((Object)f).name.Contains("LiberationSans"))); } if ((Object)(object)_defaultFont == (Object)null) { _defaultFont = (from f in Resources.FindObjectsOfTypeAll() where (Object)(object)f != (Object)null && ((Object)f).name.IndexOf("Sans", StringComparison.OrdinalIgnoreCase) >= 0 orderby (!(((Object)f).name == "NotoSansJP-Regular SDF")) ? 1 : 0 select f).ThenBy((TMP_FontAsset f) => ((Object)f).name, StringComparer.Ordinal).FirstOrDefault(); } if ((Object)(object)_defaultFont == (Object)null) { _defaultFont = TMP_Settings.defaultFontAsset ?? (from f in Resources.FindObjectsOfTypeAll() where (Object)(object)f != (Object)null select f).OrderBy((TMP_FontAsset f) => ((Object)f).name, StringComparer.Ordinal).FirstOrDefault(); } if (!_logged) { _logged = true; Debug.Log((object)(((Object)(object)_defaultFont != (Object)null) ? ("[UIReforge] TMP default font: " + ((Object)_defaultFont).name) : "[UIReforge] TMP default font NOT FOUND")); } return _defaultFont; } public static void ApplyFontsToPrefab(GameObject prefabRoot) { if ((Object)(object)prefabRoot == (Object)null) { return; } TMP_FontAsset defaultFont = GetDefaultFont(); if ((Object)(object)defaultFont == (Object)null) { return; } TMP_Text[] componentsInChildren = prefabRoot.GetComponentsInChildren(true); foreach (TMP_Text val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && (Object)(object)val.font == (Object)null) { val.font = defaultFont; val.enableAutoSizing = false; } } TMP_SubMeshUI[] componentsInChildren2 = prefabRoot.GetComponentsInChildren(true); foreach (TMP_SubMeshUI val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null) && (Object)(object)val2.textComponent != (Object)null && (Object)(object)val2.textComponent.font == (Object)null) { val2.textComponent.font = defaultFont; val2.textComponent.enableAutoSizing = false; } } } public static void FixFontsOnInstance(GameObject root) { if ((Object)(object)root == (Object)null) { return; } TMP_FontAsset defaultFont = GetDefaultFont(); if ((Object)(object)defaultFont == (Object)null) { return; } TMP_Text[] componentsInChildren = root.GetComponentsInChildren(true); foreach (TMP_Text val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && (Object)(object)val.font == (Object)null) { val.font = defaultFont; val.enableAutoSizing = false; val.ForceMeshUpdate(false, false); } } } } internal static class ExtraSlotsSkin { private enum Kind { Ammo, Food, Quick } private class BarState { public RectTransform Rect; public Vector3 Position; public Vector3 Scale; } private class ElementSkin { public GameObject Root; public RectTransform Skin; public Image Frame; public Image Marks; public Image Icon; public Image Tip; public TextMeshProUGUI Binding; public TextMeshProUGUI Amount; public Graphic Background; public readonly List Hidden = new List(); } internal const string AmmoBar = "ExtraSlotsAmmoHotBar"; internal const string FoodBar = "ExtraSlotsFoodHotBar"; internal const string QuickBar = "ExtraSlotsQuickSlotsHotBar"; private const string VanillaBar = "HotKeyBar"; private const string SkinName = "YggSkin"; private static readonly Dictionary Bars = new Dictionary(); private static readonly Dictionary Skins = new Dictionary(); private static readonly Dictionary ItemsByIcon = new Dictionary(); private static int itemsByIconSource = -1; private static FieldInfo elementsField; private static FieldInfo goField; private static FieldInfo iconField; private static FieldInfo amountField; private static FieldInfo equipedField; private static FieldInfo usedField; private static bool wasActive; private static readonly MethodInfo UpdateIconsMethod = AccessTools.Method(typeof(HotkeyBar), "UpdateIcons", (Type[])null, (Type[])null); internal static bool Active { get { if (HudState.Initialized && (Object)(object)HudState.Panel != (Object)null && HudUpdatePlugin.ExtraSlotsLayout != null) { return HudUpdatePlugin.ExtraSlotsLayout.Value == ExtraSlotsLayoutMode.Auto; } return false; } } private static bool Handles(Kind kind) { return true; } private static void RowStarts(out Vector2 ammo, out Vector2 food) { //IL_0030: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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) switch (HudState.ActiveStyle) { case HudStyle.Yggdrasil: ammo = HudState.YggAmmoStart; food = HudState.YggFoodBarStart; break; case HudStyle.Chevron: ammo = new Vector2(300f, 185f); food = new Vector2(300f, 25f); break; default: ammo = new Vector2(377.5f, 166f); food = new Vector2(371.5f, 44f); break; } } private static bool TryKind(string barName, out Kind kind) { kind = Kind.Ammo; switch (barName) { case "ExtraSlotsAmmoHotBar": kind = Kind.Ammo; break; case "ExtraSlotsFoodHotBar": kind = Kind.Food; break; case "ExtraSlotsQuickSlotsHotBar": kind = Kind.Quick; break; default: return false; } return true; } internal static void AfterUpdateIcons(HotkeyBar bar) { //IL_0128: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bar == (Object)null || !TryKind(((Object)bar).name, out var kind) || !Active || !Handles(kind) || !BindFields() || !(elementsField.GetValue(bar) is IList list)) { return; } List list2 = new List(); foreach (object item in list) { object? value = goField.GetValue(item); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { continue; } ElementSkin skin = GetSkin(val, kind); if (skin != null) { Dress(skin, item, kind); if (val.activeSelf) { list2.Add(skin); } } } list2.Sort(delegate(ElementSkin a, ElementSkin b) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) Vector3 localPosition = a.Root.transform.localPosition; Vector3 localPosition2 = b.Root.transform.localPosition; int num3 = -localPosition.y.CompareTo(localPosition2.y); return (!(Mathf.Abs(localPosition.y - localPosition2.y) > 1f)) ? localPosition.x.CompareTo(localPosition2.x) : num3; }); float num = ((kind == Kind.Food) ? 55f : 52f) / UnitsPerLocal(list2); for (int num2 = 0; num2 < list2.Count; num2++) { list2[num2].Root.transform.localPosition = new Vector3((float)num2 * num, 0f, 0f); } } private static float UnitsPerLocal(List skins) { foreach (ElementSkin skin in skins) { float num = SlotWidth(skin); if (num > 1f) { return 45f / num; } } return 45f / 64f; } private static float SlotWidth(ElementSkin skin) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)(((Object)(object)skin.Background != (Object)null) ? ((object)skin.Background.rectTransform) : ((object)/*isinst with value type is only supported in some contexts*/)); if (!((Object)(object)val != (Object)null)) { return 64f; } Rect rect = val.rect; return ((Rect)(ref rect)).width; } private static ElementSkin GetSkin(GameObject go, Kind kind) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: 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_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0346: 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_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) if (Skins.TryGetValue(go, out var value) && (Object)(object)value.Skin != (Object)null) { return value; } value = new ElementSkin { Root = go }; Transform val = go.transform.Find("bkg"); value.Background = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); RectTransform val2 = (RectTransform)(((Object)(object)value.Background != (Object)null) ? ((object)value.Background.rectTransform) : ((object)/*isinst with value type is only supported in some contexts*/)); value.Skin = new GameObject("YggSkin", new Type[1] { typeof(RectTransform) }).GetComponent(); ((Transform)value.Skin).SetParent(go.transform, false); if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)go.transform) { value.Skin.anchorMin = val2.anchorMin; value.Skin.anchorMax = val2.anchorMax; value.Skin.pivot = val2.pivot; value.Skin.anchoredPosition = val2.anchoredPosition; value.Skin.sizeDelta = val2.sizeDelta; } else { value.Skin.anchorMin = Vector2.zero; value.Skin.anchorMax = Vector2.one; RectTransform skin = value.Skin; Vector2 offsetMin = (value.Skin.offsetMax = Vector2.zero); skin.offsetMin = offsetMin; } float num = SlotWidthOf(value.Skin) / 45f; value.Frame = NewImage("frame", (Transform)(object)value.Skin, "ygg_slot", Vector2.zero, 45f * num * Vector2.one); value.Marks = NewImage("marks", (Transform)(object)value.Skin, "ygg_slot_marks", Vector2.zero, 61f * num * Vector2.one); value.Icon = NewImage("icon", (Transform)(object)value.Skin, null, Vector2.zero, 24f * num * Vector2.one); value.Icon.preserveAspect = true; value.Tip = NewImage("tip", (Transform)(object)((Graphic)value.Icon).rectTransform, "ygg_ammo_tip", Vector2.zero, Vector2.zero); StretchFull(((Graphic)value.Tip).rectTransform); TextMeshProUGUI componentInChildren = go.GetComponentInChildren(true); value.Binding = NewText("binding", (Transform)(object)value.Skin, componentInChildren, 10f * num); float num2 = ((HudState.ActiveStyle == HudStyle.Chevron) ? 11f : ((HudState.ActiveStyle == HudStyle.Yggdrasil) ? 10f : 14f)); value.Amount = NewText("amount", (Transform)(object)value.Skin, componentInChildren, kind switch { Kind.Ammo => 10f, Kind.Food => num2, _ => 9f, } * num); if (kind == Kind.Food && HudState.ActiveStyle == HudStyle.Chevron) { ((TMP_Text)value.Amount).fontStyle = (FontStyles)0; } if (kind == Kind.Ammo) { PlaceText(value.Binding, new Vector2(-1f, 9.5f) * num, new Vector2(44f, 14f) * num, (TextAlignmentOptions)514); PlaceText(value.Amount, new Vector2(0f, -10.5f) * num, new Vector2(44f, 14f) * num, (TextAlignmentOptions)514); Place(((Graphic)value.Icon).rectTransform, new Vector2(0.5f, 0f) * num, new Vector2(32f, 5f) * num); } else { PlaceText(value.Binding, new Vector2(0.5f, 11.5f) * num, new Vector2(44f, 14f) * num, (TextAlignmentOptions)514); PlaceText(value.Amount, new Vector2((kind == Kind.Food) ? (-3f) : 1f, -11.5f) * num, new Vector2(42f, (kind == Kind.Food) ? 18f : 12f) * num, (TextAlignmentOptions)516); Place(((Graphic)value.Icon).rectTransform, new Vector2(0.5f, -3.5f) * num, ((kind == Kind.Food) ? 21f : 24f) * num * Vector2.one); } ((Transform)value.Skin).SetAsLastSibling(); Skins[go] = value; return value; } private static float SlotWidthOf(RectTransform rt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Rect rect = rt.rect; float width = ((Rect)(ref rect)).width; if (!(width > 1f)) { return 64f; } return width; } private static void Dress(ElementSkin skin, object element, Kind kind) { //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) object? value = iconField.GetValue(element); Image val = (Image)((value is Image) ? value : null); object? value2 = amountField.GetValue(element); TMP_Text val2 = (TMP_Text)((value2 is TMP_Text) ? value2 : null); object? value3 = equipedField.GetValue(element); GameObject val3 = (GameObject)((value3 is GameObject) ? value3 : null); bool flag = usedField != null && (bool)usedField.GetValue(element); Transform obj = skin.Root.transform.Find("binding"); TMP_Text val4 = ((obj != null) ? ((Component)obj).GetComponent() : null); bool flag2 = (Object)(object)val3 != (Object)null && val3.activeSelf; if ((Object)(object)val3 != (Object)null) { Graphic[] componentsInChildren = val3.GetComponentsInChildren(true); foreach (Graphic graphic in componentsInChildren) { Hide(skin, graphic); } } Hide(skin, skin.Background); Hide(skin, (Graphic)(object)val); Hide(skin, (Graphic)(object)val2); Hide(skin, (Graphic)(object)val4); ((Component)skin.Skin).gameObject.SetActive(true); ((TMP_Text)skin.Binding).text = (((Object)(object)val4 != (Object)null) ? val4.text : ""); ((Behaviour)skin.Binding).enabled = (Object)(object)val4 != (Object)null && ((Component)val4).gameObject.activeInHierarchy && !string.IsNullOrEmpty(val4.text); ((TMP_Text)skin.Amount).text = (((Object)(object)val2 != (Object)null) ? CountOnly(val2.text) : ""); ((Behaviour)skin.Amount).enabled = flag && (Object)(object)val2 != (Object)null && ((Component)val2).gameObject.activeSelf; Sprite val5 = ((flag && (Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf) ? val.sprite : null); ItemData val6 = (((Object)(object)val5 != (Object)null) ? FindItem(val5) : null); bool flag3 = kind == Kind.Ammo && IsArrowLike(val6, val5); ((Behaviour)skin.Icon).enabled = (Object)(object)val5 != (Object)null; ((Behaviour)skin.Tip).enabled = false; if ((Object)(object)val5 != (Object)null) { if (flag3 && HudState.FoodIconOverrides.TryGetValue("ygg_ammo", out var value4)) { skin.Icon.sprite = value4; skin.Icon.preserveAspect = false; ((Graphic)skin.Icon).color = Color.white; Color? val7 = TipColor((val6 != null && (Object)(object)val6.m_dropPrefab != (Object)null) ? ((Object)val6.m_dropPrefab).name : ((Object)val5).name); ((Behaviour)skin.Tip).enabled = val7.HasValue; if (val7.HasValue) { ((Graphic)skin.Tip).color = val7.Value; } } else { Sprite val8 = ((kind == Kind.Food) ? HudState.ResolveItemIcon(val6, null) : null); skin.Icon.sprite = val8 ?? val5; skin.Icon.preserveAspect = true; ((Graphic)skin.Icon).color = (((Object)(object)val != (Object)null) ? ((Graphic)val).color : Color.white); } } bool flag4 = kind == Kind.Ammo && !flag; bool flag5 = kind != Kind.Ammo || flag2 || flag4; ((Behaviour)skin.Frame).enabled = flag5 && (Object)(object)skin.Frame.sprite != (Object)null; ((Behaviour)skin.Marks).enabled = kind == Kind.Ammo && flag2 && (Object)(object)skin.Marks.sprite != (Object)null; if (kind != Kind.Ammo && flag2 && ((Behaviour)skin.Frame).enabled) { ((Graphic)skin.Frame).color = new Color(0.55f, 0.85f, 1f, 1f); } else { ((Graphic)skin.Frame).color = (Color)((flag4 && !flag2) ? new Color(0.7f, 0.7f, 0.7f, 0.35f) : Color.white); } } private static string CountOnly(string text) { if (string.IsNullOrEmpty(text)) { return ""; } int num = text.IndexOf('/'); if (num <= 0) { return text; } return text.Substring(0, num).Trim(); } private static void Hide(ElementSkin skin, Graphic graphic) { if (!((Object)(object)graphic == (Object)null) && ((Behaviour)graphic).enabled) { ((Behaviour)graphic).enabled = false; if (!skin.Hidden.Contains(graphic)) { skin.Hidden.Add(graphic); } } } internal static void AfterHudUpdate(Hud hud) { //IL_008d: 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) if ((Object)(object)hud == (Object)null || (Object)(object)hud.m_rootObject == (Object)null) { return; } if (!Active) { wasActive = false; if (Bars.Count > 0 || Skins.Count > 0) { RestoreAll(); } return; } if (!wasActive) { wasActive = true; RefreshBars(); } Transform transform = hud.m_rootObject.transform; Transform transform2 = HudState.Panel.transform; RectTransform panel = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); RowStarts(out var ammo, out var food); Transform obj = transform.Find("ExtraSlotsAmmoHotBar"); Place((RectTransform)(object)((obj is RectTransform) ? obj : null), panel, ammo); Transform obj2 = transform.Find("ExtraSlotsFoodHotBar"); Place((RectTransform)(object)((obj2 is RectTransform) ? obj2 : null), panel, food); Transform obj3 = transform.Find("ExtraSlotsQuickSlotsHotBar"); Transform bar = ((obj3 is RectTransform) ? obj3 : null); Transform obj4 = transform.Find("HotKeyBar"); PlaceQuick((RectTransform)(object)bar, (RectTransform)(object)((obj4 is RectTransform) ? obj4 : null), panel); } private static void Place(RectTransform bar, RectTransform panel, Vector2 firstSlot) { //IL_0029: 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_003b: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)bar == (Object)null) && ((Component)bar).gameObject.activeInHierarchy) { ElementSkin elementSkin = FirstSkin(bar); if (elementSkin != null) { Remember(bar); float x = ((Transform)panel).localScale.x; Vector3 target = ((Transform)panel).TransformPoint(new Vector3(firstSlot.x, firstSlot.y, 0f)); Move(bar, elementSkin, target, x); } } } private static void PlaceQuick(RectTransform bar, RectTransform hotbar, RectTransform panel) { //IL_0029: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00cd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bar == (Object)null || !((Component)bar).gameObject.activeInHierarchy) { return; } ElementSkin elementSkin = FirstSkin(bar); if (elementSkin != null) { Remember(bar); float x = ((Transform)panel).localScale.x; RectTransform val = (((Object)(object)hotbar != (Object)null) ? FirstVanillaSlot(hotbar) : null); Vector3 target; if ((Object)(object)val != (Object)null) { Vector3[] array = (Vector3[])(object)new Vector3[4]; val.GetWorldCorners(array); float y = ((Transform)bar).parent.lossyScale.y; target = array[0] + new Vector3(22.5f * x * y, -32.5f * x * y, 0f); } else { target = ((Transform)panel).TransformPoint(new Vector3(HudState.YggAmmoStart.x, HudState.YggAmmoStart.y + 60f, 0f)); } Move(bar, elementSkin, target, x); } } private static RectTransform FirstVanillaSlot(RectTransform hotbar) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) RectTransform result = null; float num = float.MaxValue; foreach (Transform item in (Transform)hotbar) { Transform val = item; if (!((Component)val).gameObject.activeSelf) { continue; } Transform obj = val.Find("bkg"); RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null); if (!((Object)(object)val2 == (Object)null)) { float x = ((Transform)val2).position.x; if (x < num) { num = x; result = val2; } } } return result; } private static ElementSkin FirstSkin(RectTransform bar) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) ElementSkin result = null; float num = float.MaxValue; foreach (Transform item in (Transform)bar) { Transform val = item; if (((Component)val).gameObject.activeSelf && Skins.TryGetValue(((Component)val).gameObject, out var value) && !((Object)(object)value.Skin == (Object)null)) { float x = val.localPosition.x; if (x < num) { num = x; result = value; } } } return result; } private static void Move(RectTransform bar, ElementSkin first, Vector3 target, float scale) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) float num = SlotWidthOf(first.Skin); float num2 = 45f / num * scale; if (Mathf.Abs(((Transform)bar).localScale.x - num2) > 0.0001f) { ((Transform)bar).localScale = new Vector3(num2, num2, 1f); } RectTransform skin = first.Skin; Rect rect = first.Skin.rect; Vector3 val = ((Transform)skin).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)); Vector3 val2 = target - val; if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f) { ((Transform)bar).position = ((Transform)bar).position + new Vector3(val2.x, val2.y, 0f); } } private static void Remember(RectTransform bar) { //IL_0022: 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_002e: 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) if (!Bars.ContainsKey(bar)) { Bars[bar] = new BarState { Rect = bar, Position = ((Transform)bar).localPosition, Scale = ((Transform)bar).localScale }; } } internal static void RestoreAll() { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) foreach (ElementSkin value in Skins.Values) { foreach (Graphic item in value.Hidden) { if ((Object)(object)item != (Object)null) { ((Behaviour)item).enabled = true; } } value.Hidden.Clear(); if ((Object)(object)value.Skin != (Object)null) { Object.Destroy((Object)(object)((Component)value.Skin).gameObject); } } Skins.Clear(); foreach (BarState value2 in Bars.Values) { if (!((Object)(object)value2.Rect == (Object)null)) { ((Transform)value2.Rect).localPosition = value2.Position; ((Transform)value2.Rect).localScale = value2.Scale; } } Bars.Clear(); RefreshBars(); } private static void RefreshBars() { if ((Object)(object)Hud.instance == (Object)null || (Object)(object)Hud.instance.m_rootObject == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return; } string[] array = new string[3] { "ExtraSlotsAmmoHotBar", "ExtraSlotsFoodHotBar", "ExtraSlotsQuickSlotsHotBar" }; foreach (string text in array) { Transform obj = Hud.instance.m_rootObject.transform.Find(text); HotkeyBar val = ((obj != null) ? ((Component)obj).GetComponent() : null); if (!((Object)(object)val == (Object)null)) { try { UpdateIconsMethod?.Invoke(val, new object[1] { Player.m_localPlayer }); } catch (Exception ex) { Debug.LogWarning((object)("[UIReforge] ExtraSlots refresh: " + ex.Message)); } } } } private static bool BindFields() { if (elementsField != null) { return goField != null; } elementsField = AccessTools.Field(typeof(HotkeyBar), "m_elements"); FieldInfo fieldInfo = elementsField; Type type = (((object)fieldInfo != null && fieldInfo.FieldType.IsGenericType) ? elementsField.FieldType.GetGenericArguments()[0] : null); if (type == null) { return false; } goField = AccessTools.Field(type, "m_go"); iconField = AccessTools.Field(type, "m_icon"); amountField = AccessTools.Field(type, "m_amount"); equipedField = AccessTools.Field(type, "m_equiped"); usedField = AccessTools.Field(type, "m_used"); int num; if (goField != null && iconField != null && amountField != null) { num = ((equipedField != null) ? 1 : 0); if (num != 0) { goto IL_0102; } } else { num = 0; } Debug.LogWarning((object)"[UIReforge] HotkeyBar layout changed, ExtraSlots skin disabled"); goField = null; goto IL_0102; IL_0102: return (byte)num != 0; } private static ItemData FindItem(Sprite icon) { ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null || instance.m_items == null) { return null; } if (itemsByIconSource != instance.m_items.Count) { itemsByIconSource = instance.m_items.Count; ItemsByIcon.Clear(); foreach (GameObject item in instance.m_items) { ItemDrop val = (((Object)(object)item != (Object)null) ? item.GetComponent() : null); SharedData val2 = val?.m_itemData?.m_shared; if (val2?.m_icons == null) { continue; } if ((Object)(object)val.m_itemData.m_dropPrefab == (Object)null) { val.m_itemData.m_dropPrefab = item; } Sprite[] icons = val2.m_icons; foreach (Sprite val3 in icons) { if ((Object)(object)val3 != (Object)null && !ItemsByIcon.ContainsKey(val3)) { ItemsByIcon[val3] = val.m_itemData; } } } } if (!ItemsByIcon.TryGetValue(icon, out var value)) { return null; } return value; } private static bool IsArrowLike(ItemData item, Sprite sprite) { string text = ((item != null && (Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : (((Object)(object)sprite != (Object)null) ? ((Object)sprite).name : "")); text = text.ToLowerInvariant(); if (!text.Contains("arrow")) { return text.Contains("bolt"); } return true; } private static Color? TipColor(string prefab) { //IL_002c: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) string text = (prefab ?? "").ToLowerInvariant(); if (text.Contains("fire")) { return new Color(0.93f, 0.42f, 0.19f); } if (text.Contains("frost") || text.Contains("ice")) { return new Color(0.55f, 0.85f, 1f); } if (text.Contains("poison")) { return new Color(0.48f, 0.85f, 0.29f); } if (text.Contains("silver")) { return new Color(0.78f, 0.8f, 0.88f); } if (text.Contains("carapace")) { return new Color(0.25f, 0.65f, 0.63f); } if (text.Contains("charred")) { return new Color(0.55f, 0.25f, 0.85f); } return null; } private static Image NewImage(string name, Transform parent, string spriteKey, Vector2 pos, Vector2 size) { //IL_0021: 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_0040: Unknown result type (might be due to invalid IL or missing references) Image component = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }).GetComponent(); ((Component)component).transform.SetParent(parent, false); Place(((Graphic)component).rectTransform, pos, size); if (spriteKey != null && HudState.FoodIconOverrides.TryGetValue(spriteKey, out var value)) { component.sprite = value; } ((Graphic)component).raycastTarget = false; ((Behaviour)component).enabled = false; return component; } private static void Place(RectTransform rt, Vector2 pos, Vector2 size) { //IL_0014: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); rt.pivot = val; Vector2 anchorMin = (rt.anchorMax = val); rt.anchorMin = anchorMin; rt.anchoredPosition = pos; rt.sizeDelta = size; ((Transform)rt).localScale = Vector3.one; ((Transform)rt).localRotation = Quaternion.identity; } private static void StretchFull(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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; Vector2 offsetMin = (rt.offsetMax = Vector2.zero); rt.offsetMin = offsetMin; } private static TextMeshProUGUI NewText(string name, Transform parent, TextMeshProUGUI template, float size) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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) TextMeshProUGUI val; if ((Object)(object)template != (Object)null) { val = Object.Instantiate(template, parent, false); foreach (Transform item in ((TMP_Text)val).transform) { Object.Destroy((Object)(object)((Component)item).gameObject); } } else { val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }).GetComponent(); ((TMP_Text)val).transform.SetParent(parent, false); } ((Object)val).name = name; ((Behaviour)val).enabled = true; ((Component)val).gameObject.SetActive(true); ((TMP_Text)val).enableAutoSizing = false; ((TMP_Text)val).fontSize = size; ((TMP_Text)val).fontStyle = (FontStyles)1; ((Graphic)val).color = Color.white; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val).overflowMode = (TextOverflowModes)0; ((Graphic)val).raycastTarget = false; ((TMP_Text)val).outlineColor = new Color32((byte)12, (byte)10, (byte)8, byte.MaxValue); ((TMP_Text)val).outlineWidth = 0.2f; return val; } private static void PlaceText(TextMeshProUGUI text, Vector2 pos, Vector2 size, TextAlignmentOptions align) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) Place(((TMP_Text)text).rectTransform, pos, size); ((TMP_Text)text).alignment = align; } } [HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")] internal static class ExtraSlotsUpdateIconsPatch { [HarmonyAfter(new string[] { "shudnal.ExtraSlots" })] [HarmonyPriority(0)] private static void Postfix(HotkeyBar __instance) { try { ExtraSlotsSkin.AfterUpdateIcons(__instance); } catch (Exception ex) { Debug.LogError((object)("[UIReforge] ExtraSlots skin: " + ex)); } } } [HarmonyPatch(typeof(Hud), "Update")] internal static class ExtraSlotsHudUpdatePatch { [HarmonyAfter(new string[] { "shudnal.ExtraSlots" })] [HarmonyPriority(0)] private static void Postfix(Hud __instance) { try { ExtraSlotsSkin.AfterHudUpdate(__instance); } catch (Exception ex) { Debug.LogError((object)("[UIReforge] ExtraSlots layout: " + ex)); } } }