using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Sparroh.UI; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("GridClear")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("GridClear")] [assembly: AssemblyTitle("GridClear")] [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; } } } public static class GridClearMod { private static readonly PropertyInfo _upgradablePrefabProperty = typeof(GearDetailsWindow).GetProperty("UpgradablePrefab", BindingFlags.Instance | BindingFlags.Public); private static readonly FieldInfo _selectedGearField = typeof(OuroGearWindow).GetField("selectedGear", BindingFlags.Instance | BindingFlags.NonPublic); private static bool _registered; public static void Initialize() { } public static void UpdateUI() { GearActionBar.Tick(); if (GearActionBar.IsGearMenuOpen() && !_registered) { GearActionBar.Register("clear_grid", "Clear Grid", 10, (Action)delegate { UIDialog.Confirm("Clear Grid", "Unequip all upgrades from this gear grid?", (Action)TryClearFromOpenWindow, (Action)null, "Confirm", "Cancel"); }, (UIButtonStyle)2); _registered = true; } } private static void TryClearFromOpenWindow() { if ((Object)(object)Menu.Instance == (Object)null || !Menu.Instance.IsOpen || (Object)(object)Menu.Instance.WindowSystem == (Object)null) { return; } Window top = Menu.Instance.WindowSystem.GetTop(); IUpgradeWindow val = (IUpgradeWindow)(object)((top is GearDetailsWindow) ? top : null); IUpgradable val2 = null; if (val != null) { object? obj = _upgradablePrefabProperty?.GetValue(val); val2 = (IUpgradable)((obj is IUpgradable) ? obj : null); } else { val = (IUpgradeWindow)(object)((top is OuroGearWindow) ? top : null); if (val != null) { object? obj2 = _selectedGearField?.GetValue(val); val2 = (IUpgradable)((obj2 is IUpgradable) ? obj2 : null); } } if (val != null && val2 != null) { ClearAllUpgrades(val, val2); } } private static void ClearAllUpgrades(IUpgradeWindow window, IUpgradable gear) { //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_0037: 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) ModuleEquipSlots equipSlots = GetEquipSlots(window); if ((Object)(object)equipSlots == (Object)null) { return; } HexMap hexMap = equipSlots.HexMap; List list = new List(); for (int i = 0; i < hexMap.Height; i++) { for (int j = 0; j < hexMap.Width; j++) { Node val = hexMap[j, i]; if (val.upgrade != null) { list.Add(val.upgrade); } } } foreach (UpgradeInstance item in list.OrderBy((UpgradeInstance u) => (u.Upgrade.Name == "Boundary Incursion") ? 1 : 0).ToList()) { equipSlots.Unequip(gear, item); } } private static ModuleEquipSlots GetEquipSlots(IUpgradeWindow window) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown return (ModuleEquipSlots)(((object)window).GetType().GetField("equipSlots", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(window)); } public static void Cleanup() { GearActionBar.Unregister("clear_grid"); _registered = false; } } [BepInPlugin("sparroh.gridclear", "GridClear", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [MycoMod(/*Could not decode attribute arguments.*/)] public class SparrohPlugin : BaseUnityPlugin { public const string PluginGUID = "sparroh.gridclear"; public const string PluginName = "GridClear"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Logger; public static SparrohPlugin Instance; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; GridClearMod.Initialize(); Logger.LogInfo((object)"GridClear v1.0.0 loaded successfully."); } private void Update() { GridClearMod.UpdateUI(); } private void OnDestroy() { GridClearMod.Cleanup(); } } namespace GridClear { public static class MyPluginInfo { public const string PLUGIN_GUID = "GridClear"; public const string PLUGIN_NAME = "GridClear"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }