using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using Pigeon.Movement; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 StackUpgrades { [BepInPlugin("com.coloron.stackupgrades", "Stack Upgrades", "1.1.0")] [MycoMod(/*Could not decode attribute arguments.*/)] public class StackUpgrades : BaseUnityPlugin { public static UpgradeID? ExpandedID = null; public static Dictionary> Stacks = new Dictionary>(); public static MethodInfo SetupUpgradesMethod; public static FieldInfo InSkinModeField; public static MethodInfo SoundPostMethod; public static MethodInfo OuroSetupUpgradesMethod; public static FieldInfo OuroSelectedGearField; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("com.coloron.stackupgrades"); val.PatchAll(); SetupUpgradesMethod = typeof(GearDetailsWindow).GetMethod("SetupUpgrades", BindingFlags.Instance | BindingFlags.NonPublic); InSkinModeField = typeof(GearDetailsWindow).GetField("inSkinMode", BindingFlags.Instance | BindingFlags.NonPublic); OuroSetupUpgradesMethod = typeof(OuroGearWindow).GetMethod("SetupUpgrades", BindingFlags.Instance | BindingFlags.NonPublic); OuroSelectedGearField = typeof(OuroGearWindow).GetField("selectedGear", BindingFlags.Instance | BindingFlags.NonPublic); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Stack Upgrades v1.0.0 loaded"); } public static void RefreshWindow(GearDetailsWindow window) { if (!((Object)(object)window == (Object)null) && !(SetupUpgradesMethod == null)) { bool flag = (bool)InSkinModeField.GetValue(window); SetupUpgradesMethod.Invoke(window, new object[3] { window.UpgradablePrefab, flag, true }); window.SetUpgradeListScroll(1f); } } public static void RefreshOuroWindow(OuroGearWindow window) { if (!((Object)(object)window == (Object)null) && !(OuroSetupUpgradesMethod == null) && !(OuroSelectedGearField == null)) { object? value = OuroSelectedGearField.GetValue(window); IUpgradable val = (IUpgradable)((value is IUpgradable) ? value : null); if (val != null) { OuroSetupUpgradesMethod.Invoke(window, new object[1] { val }); window.SetUpgradeListScroll(1f); } } } } public static class SoundHelper { private static object _cachedSoundObj; private static MethodInfo _cachedPost; public static void PlaySoundByName(string fieldName) { if ((Object)(object)Global.Instance == (Object)null || (Object)(object)PlayerLook.Instance == (Object)null) { return; } try { if (_cachedPost == null) { _cachedSoundObj = typeof(Global).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public)?.GetValue(Global.Instance); _cachedPost = _cachedSoundObj?.GetType().GetMethod("Post", new Type[1] { typeof(GameObject) }); } _cachedPost?.Invoke(_cachedSoundObj, new object[1] { ((Component)PlayerLook.Instance).gameObject }); } catch { } } } [HarmonyPatch(typeof(GearDetailsWindow), "SetupUpgrades")] public static class Patch_SetupUpgrades { private static void Prefix() { StackUpgrades.Stacks.Clear(); } } [HarmonyPatch(typeof(GearDetailsWindow), "AddUpgrade")] public static class Patch_AddUpgrade { [HarmonyPrefix] private static bool Prefix(UpgradeInstance upgrade, ref int index) { //IL_0021: 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_002c: 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_006a: 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) if ((Object)(object)((upgrade != null) ? upgrade.Upgrade : null) == (Object)null) { return true; } UpgradeID iD = upgrade.Upgrade.ID; if (!StackUpgrades.Stacks.TryGetValue(iD, out var value)) { value = new List(); StackUpgrades.Stacks[iD] = value; } value.Add(upgrade); if (StackUpgrades.ExpandedID.HasValue) { return iD == StackUpgrades.ExpandedID.Value; } return value.Count == 1; } } [HarmonyPatch(typeof(GearDetailsWindow), "OnClickUp")] public static class Patch_OnClickUp { [HarmonyPrefix] private static void Prefix(GearDetailsWindow __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00ca: 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_00e2: 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_00f8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GearDetailsWindow.SelectedUpgrade != (Object)null) { return; } GearUpgradeUI val = default(GearUpgradeUI); bool flag = UIRaycaster.RaycastForComponent(ref val); UpgradeEquipCell val2 = default(UpgradeEquipCell); bool flag2 = UIRaycaster.RaycastForNearest((RectTransform)((Component)__instance).transform, ref val2); if (flag2 && !flag) { object? obj = typeof(GearDetailsWindow).GetField("equipSlots", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance); ModuleEquipSlots val3 = (ModuleEquipSlots)((obj is ModuleEquipSlots) ? obj : null); if (!((Object)(object)val3 != (Object)null)) { return; } Node val4 = val3.HexMap[val2.X, val2.Y]; if (val4.enabled && val4.upgrade != null) { UpgradeID iD = val4.upgrade.Upgrade.ID; if (!StackUpgrades.ExpandedID.HasValue || StackUpgrades.ExpandedID.Value != iD) { StackUpgrades.ExpandedID = iD; StackUpgrades.RefreshWindow(__instance); SoundHelper.PlaySoundByName("GridHoverSound"); } } } else if (!flag && !flag2 && StackUpgrades.ExpandedID.HasValue) { StackUpgrades.ExpandedID = null; StackUpgrades.RefreshWindow(__instance); SoundHelper.PlaySoundByName("GridHoverSound"); } } } [HarmonyPatch(typeof(GearDetailsWindow), "SelectUpgrade")] public static class Patch_SelectUpgrade { [HarmonyPrefix] private static bool Prefix(GearDetailsWindow __instance, GearUpgradeUI upgrade) { //IL_0048: 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_005f: 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) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)upgrade == (Object)null || ((HoverInfoUpgrade)upgrade).Upgrade == null) { return true; } if (((HoverInfoUpgrade)upgrade).Upgrade.IsEquipped(__instance.UpgradablePrefab)) { return true; } UpgradeID iD = ((HoverInfoUpgrade)upgrade).Upgrade.Upgrade.ID; if ((!StackUpgrades.ExpandedID.HasValue || StackUpgrades.ExpandedID.Value != iD) && StackUpgrades.Stacks.TryGetValue(iD, out var value) && value.Count > 1) { StackUpgrades.ExpandedID = iD; StackUpgrades.RefreshWindow(__instance); SoundHelper.PlaySoundByName("GridHoverSound"); return false; } return true; } } [HarmonyPatch(typeof(GearDetailsWindow), "OnCloseCallback")] public static class Patch_OnClose { private static void Postfix() { StackUpgrades.ExpandedID = null; } } [HarmonyPatch(typeof(OuroGearWindow), "SetupUpgrades")] public static class OuroPatch_SetupUpgrades { private static void Prefix() { StackUpgrades.Stacks.Clear(); } } [HarmonyPatch(typeof(OuroGearWindow), "AddUpgrade")] public static class OuroPatch_AddUpgrade { [HarmonyPrefix] private static bool Prefix(UpgradeInstance upgrade, ref int index) { //IL_0037: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0086: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((upgrade != null) ? upgrade.Upgrade : null) == (Object)null) { return true; } if (!upgrade.RemoveAfterMission) { return true; } UpgradeID iD = upgrade.Upgrade.ID; if (!StackUpgrades.Stacks.TryGetValue(iD, out var value)) { value = new List(); StackUpgrades.Stacks[iD] = value; } value.Add(upgrade); if (StackUpgrades.ExpandedID.HasValue) { return iD == StackUpgrades.ExpandedID.Value; } return value.Count == 1; } } [HarmonyPatch(typeof(OuroGearWindow), "OnClickUp")] public static class OuroPatch_OnClickUp { [HarmonyPrefix] private static void Prefix(OuroGearWindow __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00ca: 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_00e2: 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_00f8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)OuroGearWindow.SelectedUpgrade != (Object)null) { return; } GearUpgradeUI val = default(GearUpgradeUI); bool flag = UIRaycaster.RaycastForComponent(ref val); UpgradeEquipCell val2 = default(UpgradeEquipCell); bool flag2 = UIRaycaster.RaycastForNearest((RectTransform)((Component)__instance).transform, ref val2); if (flag2 && !flag) { object? obj = typeof(OuroGearWindow).GetField("equipSlots", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance); ModuleEquipSlots val3 = (ModuleEquipSlots)((obj is ModuleEquipSlots) ? obj : null); if (!((Object)(object)val3 != (Object)null)) { return; } Node val4 = val3.HexMap[val2.X, val2.Y]; if (val4.enabled && val4.upgrade != null) { UpgradeID iD = val4.upgrade.Upgrade.ID; if (!StackUpgrades.ExpandedID.HasValue || StackUpgrades.ExpandedID.Value != iD) { StackUpgrades.ExpandedID = iD; StackUpgrades.RefreshOuroWindow(__instance); SoundHelper.PlaySoundByName("GridHoverSound"); } } } else if (!flag && !flag2 && StackUpgrades.ExpandedID.HasValue) { StackUpgrades.ExpandedID = null; StackUpgrades.RefreshOuroWindow(__instance); SoundHelper.PlaySoundByName("GridHoverSound"); } } } [HarmonyPatch(typeof(OuroGearWindow), "SelectUpgrade")] public static class OuroPatch_SelectUpgrade { [HarmonyPrefix] private static bool Prefix(OuroGearWindow __instance, GearUpgradeUI upgrade) { //IL_0063: 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_007a: 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_0094: 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) if ((Object)(object)upgrade == (Object)null || ((HoverInfoUpgrade)upgrade).Upgrade == null) { return true; } object? obj = StackUpgrades.OuroSelectedGearField?.GetValue(__instance); IUpgradable val = (IUpgradable)((obj is IUpgradable) ? obj : null); if (val != null && ((HoverInfoUpgrade)upgrade).Upgrade.IsEquipped(val)) { return true; } UpgradeID iD = ((HoverInfoUpgrade)upgrade).Upgrade.Upgrade.ID; if ((!StackUpgrades.ExpandedID.HasValue || StackUpgrades.ExpandedID.Value != iD) && StackUpgrades.Stacks.TryGetValue(iD, out var value) && value.Count > 1) { StackUpgrades.ExpandedID = iD; StackUpgrades.RefreshOuroWindow(__instance); SoundHelper.PlaySoundByName("GridHoverSound"); return false; } return true; } } [HarmonyPatch(typeof(OuroGearWindow), "OnCloseCallback")] public static class OuroPatch_OnClose { private static void Postfix() { StackUpgrades.ExpandedID = null; } } }