Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ChangeActivePowerOnTheGo v1.0.2
ChangeActivePowerOnTheGo.dll
Decompiled 3 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("ChangeActivePowerOnTheGo")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+86b9b5808aef485bf38d18460f359b23948be61a")] [assembly: AssemblyProduct("ChangeActivePowerOnTheGo")] [assembly: AssemblyTitle("ChangeActivePowerOnTheGo")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ChangeActivePowerOnTheGo { internal static class GuardianPowers { private const string Prefix = "GP_"; private static readonly string[] ProgressionOrder = new string[8] { "GP_Eikthyr", "GP_TheElder", "GP_Bonemass", "GP_Moder", "GP_Yagluth", "GP_Queen", "GP_Ashlands", "GP_DeepNorth" }; public static List<StatusEffect> All() { List<StatusEffect> list = new List<StatusEffect>(); ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null) { return list; } foreach (StatusEffect statusEffect in instance.m_StatusEffects) { if ((Object)(object)statusEffect != (Object)null && ((Object)statusEffect).name.StartsWith("GP_", StringComparison.Ordinal)) { list.Add(statusEffect); } } list.Sort(Compare); return list; } public static List<StatusEffect> Unlocked(Player player) { List<StatusEffect> list = new List<StatusEffect>(); if ((Object)(object)player == (Object)null) { return list; } foreach (StatusEffect item in All()) { if (IsUnlocked(player, item)) { list.Add(item); } } return list; } public static bool IsUnlocked(Player player, StatusEffect se) { if ((Object)(object)player != (Object)null && (Object)(object)se != (Object)null) { return ((Humanoid)player).HaveUniqueKey(((Object)se).name); } return false; } public static bool IsActive(Player player, StatusEffect se) { if ((Object)(object)player != (Object)null && (Object)(object)se != (Object)null) { return player.GetGuardianPowerName() == ((Object)se).name; } return false; } public static StatusEffect Active(Player player) { if ((Object)(object)player == (Object)null) { return null; } StatusEffect result = default(StatusEffect); float num = default(float); player.GetGuardianPowerHUD(ref result, ref num); return result; } public static bool Select(Player player, StatusEffect se) { if ((Object)(object)player == (Object)null || (Object)(object)se == (Object)null) { return false; } if (IsActive(player, se)) { return false; } if (!IsUnlocked(player, se)) { Plugin.Log.LogWarning((object)("Refused to select " + ((Object)se).name + ": not activated at its stone by this character")); return false; } player.SetGuardianPower(((Object)se).name); Game.instance.IncrementPlayerStat((PlayerStatType)87, 1f, false); IncrementSetStat(((Object)se).name); string text = Localization.instance.Localize("$guardianstone_hook_power_activate") + ": " + Localization.instance.Localize(se.m_name); ((Character)player).Message((MessageType)2, text, 0, (Sprite)null, false); Plugin.Log.LogInfo((object)("Guardian power set to " + ((Object)se).name)); return true; } private static void IncrementSetStat(string name) { if (name == null) { return; } switch (name.Length) { case 10: switch (name[3]) { case 'E': if (name == "GP_Eikthyr") { Game.instance.IncrementPlayerStat((PlayerStatType)88, 1f, false); } break; case 'Y': if (name == "GP_Yagluth") { Game.instance.IncrementPlayerStat((PlayerStatType)92, 1f, false); } break; } break; case 11: switch (name[3]) { case 'T': if (name == "GP_TheElder") { Game.instance.IncrementPlayerStat((PlayerStatType)89, 1f, false); } break; case 'B': if (name == "GP_Bonemass") { Game.instance.IncrementPlayerStat((PlayerStatType)90, 1f, false); } break; case 'A': if (name == "GP_Ashlands") { Game.instance.IncrementPlayerStat((PlayerStatType)94, 1f, false); } break; } break; case 8: switch (name[3]) { case 'M': if (name == "GP_Moder") { Game.instance.IncrementPlayerStat((PlayerStatType)91, 1f, false); } break; case 'Q': if (name == "GP_Queen") { Game.instance.IncrementPlayerStat((PlayerStatType)93, 1f, false); } break; } break; case 12: if (name == "GP_DeepNorth") { Game.instance.IncrementPlayerStat((PlayerStatType)95, 1f, false); } break; case 9: break; } } private static int Compare(StatusEffect a, StatusEffect b) { int num = Rank(((Object)a).name); int num2 = Rank(((Object)b).name); if (num != num2) { return num.CompareTo(num2); } return string.Compare(((Object)a).name, ((Object)b).name, StringComparison.Ordinal); } private static int Rank(string name) { int num = Array.IndexOf(ProgressionOrder, name); if (num >= 0) { return num; } return ProgressionOrder.Length; } } [BepInPlugin("rhenn.changeactivepoweronthego", "ChangeActivePowerOnTheGo", "1.0.2")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "rhenn.changeactivepoweronthego"; public const string PluginName = "ChangeActivePowerOnTheGo"; public const string PluginVersion = "1.0.2"; internal static ManualLogSource Log; private readonly Harmony harmony = new Harmony("rhenn.changeactivepoweronthego"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"ChangeActivePowerOnTheGo 1.0.2 has loaded!"); harmony.PatchAll(Assembly.GetExecutingAssembly()); } private void OnDestroy() { harmony.UnpatchSelf(); } } internal class PowersDialog : MonoBehaviour { private const float InputDelay = 0.1f; private const string Title = "Guardian Powers"; private const string EmptyMessage = "No powers unlocked yet.\nActivate a power at its boss stone once, and it will be listed here."; private RectTransform listRoot; private ScrollRect scrollRect; private Scrollbar scrollbar; private static readonly Color TooltipBacking = new Color(0f, 0f, 0f, 0.8f); private const float TooltipGapFromFrame = 8f; private const float TooltipTopOffset = -8f; private RectTransform tooltipAnchor; private GameObject tooltipPrefab; private GameObject rowPrefab; private float spacing; private float baseListSize; private TMP_Text emptyText; private readonly List<GameObject> rows = new List<GameObject>(); private readonly List<TMP_Text> markers = new List<TMP_Text>(); private readonly List<StatusEffect> powers = new List<StatusEffect>(); private int selectionIndex; private float inputDelayTimer; public bool IsOpen => ((Component)this).gameObject.activeSelf; public event Action Changed; public void Init(SkillsDialog template, GameObject itemTooltipPrefab) { //IL_00a4: 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_00ce: 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_00f7: Unknown result type (might be due to invalid IL or missing references) listRoot = template.m_listRoot; scrollRect = template.skillListScrollRect; scrollbar = template.scrollbar; rowPrefab = template.m_elementPrefab; spacing = template.m_spacing; InitTooltip(itemTooltipPrefab, template.m_tooltipAnchor); TMP_Text val = FindText("SkillsFrame/topic"); if ((Object)(object)val != (Object)null) { val.text = "Guardian Powers"; emptyText = Object.Instantiate<TMP_Text>(val, (Transform)(object)listRoot); ((Object)emptyText).name = "empty"; RectTransform rectTransform = emptyText.rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.anchoredPosition = new Vector2(0f, -20f); rectTransform.sizeDelta = new Vector2(-40f, 120f); emptyText.enableAutoSizing = false; emptyText.fontSize = 20f; emptyText.alignment = (TextAlignmentOptions)258; emptyText.textWrappingMode = (TextWrappingModes)1; emptyText.text = "No powers unlocked yet.\nActivate a power at its boss stone once, and it will be listed here."; ((Component)emptyText).gameObject.SetActive(false); } else { Plugin.Log.LogWarning((object)"Powers dialog: SkillsFrame/topic not found; no title or empty-state text"); } } private void InitTooltip(GameObject itemTooltipPrefab, RectTransform skillsAnchor) { //IL_0081: 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_00ef: 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_0119: 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_0139: Unknown result type (might be due to invalid IL or missing references) tooltipAnchor = skillsAnchor; if ((Object)(object)itemTooltipPrefab == (Object)null) { Plugin.Log.LogWarning((object)"Powers dialog: item tooltip prefab not found; rows keep the Skills hover box"); return; } tooltipPrefab = Object.Instantiate<GameObject>(itemTooltipPrefab, ((Component)this).transform); ((Object)tooltipPrefab).name = "PowersTooltip"; tooltipPrefab.SetActive(false); Transform val = tooltipPrefab.transform.Find("Bkg"); Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null); if ((Object)(object)val2 != (Object)null) { ((Graphic)val2).color = TooltipBacking; } else { Plugin.Log.LogWarning((object)"Powers dialog: tooltip prefab has no Bkg image; backing colour not applied"); } Transform val3 = ((Component)this).transform.Find("SkillsFrame"); if ((Object)(object)val3 != (Object)null) { RectTransform component = new GameObject("PowersTooltipAnchor", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)component).SetParent(val3, false); component.anchorMin = new Vector2(1f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0f, 1f); component.anchoredPosition = new Vector2(8f, 0f); component.sizeDelta = Vector2.zero; tooltipAnchor = component; } } public void Setup(Player player) { //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) //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) ((Component)this).gameObject.SetActive(true); if (baseListSize <= 0f) { Rect rect = listRoot.rect; baseListSize = ((Rect)(ref rect)).height; } powers.Clear(); powers.AddRange(GuardianPowers.Unlocked(player)); while (rows.Count < powers.Count) { GameObject val = Object.Instantiate<GameObject>(rowPrefab, Vector3.zero, Quaternion.identity, (Transform)(object)listRoot); PrepareRow(val, rows.Count); rows.Add(val); } for (int i = 0; i < powers.Count; i++) { FillRow(i, player); } for (int j = powers.Count; j < rows.Count; j++) { rows[j].SetActive(false); } float num = Mathf.Max(baseListSize, (float)powers.Count * spacing); listRoot.SetSizeWithCurrentAnchors((Axis)1, num); if ((Object)(object)emptyText != (Object)null) { ((Component)emptyText).gameObject.SetActive(powers.Count == 0); } selectionIndex = 0; for (int k = 0; k < powers.Count; k++) { if (GuardianPowers.IsActive(player, powers[k])) { selectionIndex = k; break; } } ((MonoBehaviour)this).StartCoroutine(SelectFirstEntry()); } public void Close() { ((Component)this).gameObject.SetActive(false); } private void PrepareRow(GameObject row, int index) { //IL_00cb: 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_00f5: 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) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown string[] array = new string[4] { "levelbar_total", "levelbar", "currentlevel", "description" }; foreach (string text in array) { Transform val = Utils.FindChild(row.transform, text, (IterativeSearchType)0); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } } TMP_Text val2 = null; Transform val3 = Utils.FindChild(row.transform, "leveltext", (IterativeSearchType)0); if ((Object)(object)val3 != (Object)null) { val2 = Object.Instantiate<TMP_Text>(((Component)val3).GetComponent<TMP_Text>(), row.transform); ((Object)val2).name = "active"; RectTransform rectTransform = val2.rectTransform; 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(-8f, 0f); rectTransform.sizeDelta = new Vector2(160f, 30f); val2.alignment = (TextAlignmentOptions)4100; val2.text = ""; ((Component)val2).gameObject.SetActive(true); } markers.Add(val2); UITooltip componentInChildren = row.GetComponentInChildren<UITooltip>(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)tooltipPrefab != (Object)null) { componentInChildren.m_tooltipPrefab = tooltipPrefab; } Button component = row.GetComponent<Button>(); if ((Object)(object)component != (Object)null) { component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { OnRowClicked(index); }); } } private void FillRow(int i, Player player) { //IL_003c: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) StatusEffect val = powers[i]; GameObject obj = rows[i]; obj.SetActive(true); Transform transform = obj.transform; RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null); val2.anchoredPosition = new Vector2(0f, (float)(-i) * spacing); string text = Localization.instance.Localize(val.m_name); UITooltip componentInChildren = obj.GetComponentInChildren<UITooltip>(); if ((Object)(object)componentInChildren != (Object)null) { string text2 = Localization.instance.Localize(val.GetTooltipString()); if ((Object)(object)tooltipPrefab != (Object)null) { componentInChildren.Set(text, text2, tooltipAnchor, new Vector2(0f, -8f - (float)i * spacing)); } else { componentInChildren.Set("", "<color=orange>" + text + "</color>\n" + text2, tooltipAnchor, new Vector2(0f, Math.Min(255f, ((Transform)val2).localPosition.y + 10f))); } } Transform val3 = Utils.FindChild(obj.transform, "icon", (IterativeSearchType)0); if ((Object)(object)val3 != (Object)null) { ((Component)val3).GetComponent<Image>().sprite = val.m_icon; } Transform val4 = Utils.FindChild(obj.transform, "name", (IterativeSearchType)0); if ((Object)(object)val4 != (Object)null) { ((Component)val4).GetComponent<TMP_Text>().text = text; } SetMarker(i, GuardianPowers.IsActive(player, val)); } private void SetMarker(int i, bool active) { if (i < markers.Count && (Object)(object)markers[i] != (Object)null) { markers[i].text = (active ? "<color=orange>Active</color>" : ""); } } private void RefreshMarkers(Player player) { for (int i = 0; i < powers.Count; i++) { SetMarker(i, GuardianPowers.IsActive(player, powers[i])); } } private void OnRowClicked(int index) { if ((Object)(object)GamepadRumble.instance != (Object)null) { GamepadRumble.instance.PlayGlobalSelectVibration(); } selectionIndex = index; Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && index >= 0 && index < powers.Count && GuardianPowers.Select(localPlayer, powers[index])) { RefreshMarkers(localPlayer); this.Changed?.Invoke(); } } private void Update() { //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) if (inputDelayTimer > 0f) { inputDelayTimer -= Time.unscaledDeltaTime; return; } if (ZInput.IsExclusiveGamepadActive() && !ZInput.IsTouchActive() && powers.Count > 0) { float joyRightStickY = ZInput.GetJoyRightStickY(); float joyLeftStickY = ZInput.GetJoyLeftStickY(); bool num = ZInput.GetButtonDown("JoyDPadUp") || joyLeftStickY < -0.1f || joyRightStickY < -0.1f; bool flag = ZInput.GetButtonDown("JoyDPadDown") || joyLeftStickY > 0.1f || joyRightStickY > 0.1f; bool flag2 = joyLeftStickY < -0.1f || joyRightStickY < -0.1f || joyLeftStickY > 0.1f || joyRightStickY > 0.1f; int num2 = selectionIndex; if (num && selectionIndex > 0) { selectionIndex--; } if (flag && selectionIndex < powers.Count - 1) { selectionIndex++; } GameObject val = rows[selectionIndex]; if ((Object)(object)EventSystem.current != (Object)null && (Object)(object)EventSystem.current.currentSelectedGameObject != (Object)(object)val) { EventSystem.current.SetSelectedGameObject(val); } if (selectionIndex != num2) { if ((Object)(object)GamepadRumble.instance != (Object)null) { GamepadRumble.instance.PlayGlobalSelectVibration(); } ? val2 = this; Transform transform = val.transform; ((MonoBehaviour)val2).StartCoroutine(FocusOn((RectTransform)(object)((transform is RectTransform) ? transform : null))); UITooltip componentInChildren = val.GetComponentInChildren<UITooltip>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.OnHoverStart(val); } } if (ZInput.GetButtonDown("JoyButtonA")) { OnRowClicked(selectionIndex); } if (flag2) { inputDelayTimer = 0.1f; } } if (powers.Count > 0 && (Object)(object)scrollbar != (Object)null && (Object)(object)scrollRect != (Object)null) { Transform transform2 = ((Component)scrollRect).transform; RectTransform val3 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); Scrollbar obj = scrollbar; Rect rect = val3.rect; float height = ((Rect)(ref rect)).height; rect = listRoot.rect; obj.size = height / ((Rect)(ref rect)).height; } } private IEnumerator SelectFirstEntry() { yield return null; yield return null; if (rows.Count > 0 && powers.Count > 0) { GameObject val = rows[selectionIndex]; if ((Object)(object)EventSystem.current != (Object)null) { EventSystem.current.SetSelectedGameObject(val); } ? val2 = this; PowersDialog powersDialog = this; Transform transform = val.transform; ((MonoBehaviour)val2).StartCoroutine(powersDialog.FocusOn((RectTransform)(object)((transform is RectTransform) ? transform : null))); if ((Object)(object)scrollRect != (Object)null) { scrollRect.verticalNormalizedPosition = 1f; } } } private IEnumerator FocusOn(RectTransform element) { yield return null; yield return null; if (!((Object)(object)element == (Object)null) && !((Object)(object)scrollRect == (Object)null)) { Canvas.ForceUpdateCanvases(); listRoot.anchoredPosition = Vector2.op_Implicit(((Component)scrollRect).transform.InverseTransformPoint(((Transform)listRoot).position)) - Vector2.op_Implicit(((Component)scrollRect).transform.InverseTransformPoint(((Transform)element).position)) - new Vector2(element.sizeDelta.x / 2f, 0f); } } private TMP_Text FindText(string path) { Transform val = ((Component)this).transform.Find(path); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).GetComponent<TMP_Text>(); } } internal static class PowersPanel { [CompilerGenerated] private static class <>O { public static Action <0>__RefreshButton; public static UnityAction <1>__Open; } private const string ButtonName = "Powers"; private const string DialogName = "Powers"; private static readonly (string name, float x)[] ButtonLayout = new(string, float)[6] { ("Texts", -200f), ("Skills", -120f), ("Trophies", -40f), ("Achievements", 40f), ("Powers", 120f), ("PVP", 200f) }; private static InventoryGui gui; private static Button button; private static Image buttonIcon; private static UITooltip buttonTooltip; private static Sprite skillsIcon; private static PowersDialog dialog; public static PowersDialog Dialog => dialog; public static void Install(InventoryGui instance) { gui = instance; if ((Object)(object)gui.m_info == (Object)null || (Object)(object)gui.m_skillsDialog == (Object)null) { Plugin.Log.LogWarning((object)"Inventory screen has no info panel or Skills dialog; Powers button not added"); return; } Transform info = (Transform)(object)gui.m_info; Transform val = info.Find("Skills"); if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent<Button>() == (Object)null) { Plugin.Log.LogWarning((object)"Skills button not found under the info panel; Powers button not added"); return; } InstallDialog(); InstallButton(info, val); Plugin.Log.LogInfo((object)"Powers button and dialog added to the inventory screen"); } private static void InstallDialog() { SkillsDialog skillsDialog = gui.m_skillsDialog; GameObject obj = Object.Instantiate<GameObject>(((Component)skillsDialog).gameObject, ((Component)skillsDialog).transform.parent); ((Object)obj).name = "Powers"; obj.SetActive(false); obj.transform.SetSiblingIndex(((Component)skillsDialog).transform.GetSiblingIndex() + 1); SkillsDialog component = obj.GetComponent<SkillsDialog>(); ((Behaviour)component).enabled = false; dialog = obj.AddComponent<PowersDialog>(); dialog.Init(component, ItemTooltipPrefab()); dialog.Changed += RefreshButton; } private static GameObject ItemTooltipPrefab() { InventoryGrid playerGrid = gui.m_playerGrid; if ((Object)(object)playerGrid == (Object)null || (Object)(object)playerGrid.m_elementPrefab == (Object)null) { return null; } UITooltip component = playerGrid.m_elementPrefab.GetComponent<UITooltip>(); if (!((Object)(object)component != (Object)null)) { return null; } return component.m_tooltipPrefab; } private static void InstallButton(Transform info, Transform skills) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0076: 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) //IL_0081: Expected O, but got Unknown GameObject obj = Object.Instantiate<GameObject>(((Component)skills).gameObject, info); ((Object)obj).name = "Powers"; Transform val = info.Find("Achievements"); obj.transform.SetSiblingIndex((((Object)(object)val != (Object)null) ? val : skills).GetSiblingIndex() + 1); button = obj.GetComponent<Button>(); button.onClick = new ButtonClickedEvent(); ButtonClickedEvent onClick = button.onClick; object obj2 = <>O.<1>__Open; if (obj2 == null) { UnityAction val2 = Open; <>O.<1>__Open = val2; obj2 = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj2); buttonTooltip = obj.GetComponent<UITooltip>(); Transform val3 = obj.transform.Find("Icon"); buttonIcon = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<Image>() : null); skillsIcon = (((Object)(object)buttonIcon != (Object)null) ? buttonIcon.sprite : null); LayOutButtons(info); RefreshButton(); } private static void LayOutButtons(Transform info) { //IL_0075: 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_00bd: 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_00f7: 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_0140: Unknown result type (might be due to invalid IL or missing references) Transform[] array = (Transform[])(object)new Transform[ButtonLayout.Length]; for (int i = 0; i < ButtonLayout.Length; i++) { array[i] = info.Find(ButtonLayout[i].name); if ((Object)(object)array[i] == (Object)null) { Plugin.Log.LogWarning((object)("Info panel button '" + ButtonLayout[i].name + "' not found; Powers button placed at the right edge instead")); Transform transform = ((Component)button).transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); val.anchoredPosition = new Vector2(280f, val.anchoredPosition.y); return; } } for (int j = 0; j < array.Length; j++) { Transform obj = array[j]; RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null); val2.anchoredPosition = new Vector2(ButtonLayout[j].x, val2.anchoredPosition.y); } for (int k = 0; k < array.Length; k++) { Selectable component = ((Component)array[k]).GetComponent<Selectable>(); if (!((Object)(object)component == (Object)null)) { Navigation navigation = component.navigation; ((Navigation)(ref navigation)).mode = (Mode)4; ((Navigation)(ref navigation)).selectOnLeft = ((k > 0) ? ((Component)array[k - 1]).GetComponent<Selectable>() : null); ((Navigation)(ref navigation)).selectOnRight = ((k < array.Length - 1) ? ((Component)array[k + 1]).GetComponent<Selectable>() : null); component.navigation = navigation; } } } private static void Open() { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)dialog == (Object)null)) { if (gui.m_uiGroups != null && gui.m_uiGroups.Length > 2) { gui.SetActiveGroup(gui.m_uiGroups[2], true); } dialog.Setup(localPlayer); } } public static void CloseDialog() { if ((Object)(object)dialog != (Object)null && dialog.IsOpen) { dialog.Close(); } } public static void RefreshButton() { //IL_0079: 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) if (!((Object)(object)buttonIcon == (Object)null)) { StatusEffect val = GuardianPowers.Active(Player.m_localPlayer); if ((Object)(object)val != (Object)null && (Object)(object)val.m_icon != (Object)null) { buttonIcon.sprite = val.m_icon; ((Graphic)buttonIcon).color = Color.white; } else { buttonIcon.sprite = skillsIcon; ((Graphic)buttonIcon).color = new Color(1f, 1f, 1f, 0.35f); } if ((Object)(object)buttonTooltip != (Object)null) { buttonTooltip.m_topic = ""; buttonTooltip.m_text = (((Object)(object)val != (Object)null) ? ("Guardian power: " + Localization.instance.Localize(val.m_name)) : "Guardian powers"); } } } } } namespace ChangeActivePowerOnTheGo.Patches { [HarmonyPatch(typeof(InventoryGui))] internal static class InventoryGuiPatches { private static int dialogClosedFrame = -1; [HarmonyPostfix] [HarmonyPatch("Awake")] private static void Awake_Postfix(InventoryGui __instance) { PowersPanel.Install(__instance); } [HarmonyPostfix] [HarmonyPatch("Show", new Type[] { typeof(Container), typeof(int) })] private static void Show_Postfix() { PowersPanel.RefreshButton(); } [HarmonyPrefix] [HarmonyPatch("Update")] private static void Update_Prefix(InventoryGui __instance) { PowersDialog dialog = PowersPanel.Dialog; if (!((Object)(object)dialog == (Object)null) && dialog.IsOpen && (ZInput.GetButtonDown("JoyButtonB") || ZInput.GetKeyDown((KeyCode)27, true)) && InputGoesToInventory(__instance)) { dialog.Close(); ZInput.ResetButtonStatus("JoyButtonB"); dialogClosedFrame = Time.frameCount; } } private static bool InputGoesToInventory(InventoryGui gui) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && gui.m_craftTimer < 0f && ((Object)(object)Chat.instance == (Object)null || !Chat.instance.HasFocus()) && !Console.IsVisible() && !Menu.IsVisible() && (Object)(object)TextViewer.instance != (Object)null && !TextViewer.instance.IsVisible() && !((Character)localPlayer).InCutscene() && !GameCamera.InFreeFly()) { return !Minimap.IsOpen(); } return false; } [HarmonyPrefix] [HarmonyPatch("Hide")] private static bool Hide_Prefix() { return Time.frameCount != dialogClosedFrame; } [HarmonyPostfix] [HarmonyPatch("Hide")] private static void Hide_Postfix() { if (Time.frameCount != dialogClosedFrame) { PowersPanel.CloseDialog(); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }