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 PartialInventorySortSystem v1.1.0
PartialInventorySort.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HG; using IL.RoR2; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2.UI; using PartialInventorySort.Modules; using R2API.Utils; using RoR2; using RoR2.UI; using RoR2BepInExPack.GameAssetPathsBetter; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("PartialInventorySort")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PartialInventorySort")] [assembly: AssemblyTitle("PartialInventorySort")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: UnverifiableCode] namespace PartialInventorySort { [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.RiskOfBrainrot.PartialInventorySortSystem", "PartialInventorySortSystem", "1.0.1")] public class PartialInventorySortPlugin : BaseUnityPlugin { public static PluginInfo PInfo; public const string guid = "com.RiskOfBrainrot.PartialInventorySortSystem"; public const string teamName = "RiskOfBrainrot"; public const string modName = "PartialInventorySortSystem"; public const string version = "1.0.1"; public static SortMode questItemSortMode => Bindings.questSortMode.Value; public static SortMode scrapItemSortMode => Bindings.scrapSortMode.Value; public static SortMode lunarItemSortMode => Bindings.lunarSortMode.Value; public static SortMode curseItemSortMode => Bindings.curseSortMode.Value; public static SortMode pageItemSortMode => Bindings.pageSortMode.Value; public static bool killYourselfPageIsQuestItem => Bindings.killYourselfPageIsQuestItem.Value; public static void AddHooks() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Inventory.SetItemAcquiredServer += new Manipulator(ChangeItemAcquisitionOrder); } public static void ChangeItemAcquisitionOrder(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<Inventory>(x, "itemAcquisitionOrder"), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1) })) { DebugBreakpoint("ChangeItemAcquisitionOrder"); return; } val.Remove(); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<List<ItemIndex>, ItemIndex, Inventory>>((Action<List<ItemIndex>, ItemIndex, Inventory>)delegate(List<ItemIndex> acquisitionOrder, ItemIndex itemIndexToAdd, Inventory inventory) { //IL_0045: 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_0039: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) if (lunarItemSortMode == SortMode.Unsorted && questItemSortMode == SortMode.Unsorted && scrapItemSortMode == SortMode.Unsorted && curseItemSortMode == SortMode.Unsorted && pageItemSortMode == SortMode.Unsorted) { inventory.itemAcquisitionOrder.Add(itemIndexToAdd); } else { ItemDef itemDef = ItemCatalog.GetItemDef(itemIndexToAdd); SortMode sortMode = GetSortMode(itemIndexToAdd); if (sortMode == SortMode.VeryLast) { inventory.itemAcquisitionOrder.Add(itemIndexToAdd); } else { List<ItemIndex> list = new List<ItemIndex>(); List<ItemIndex> list2 = new List<ItemIndex>(); foreach (ItemIndex item in acquisitionOrder) { SortMode sortMode2 = GetSortMode(item); if (sortMode2 > sortMode) { list2.Add(item); } else { list.Add(item); } } inventory.itemAcquisitionOrder = new List<ItemIndex>(); inventory.itemAcquisitionOrder.AddRange(list); inventory.itemAcquisitionOrder.Add(itemIndexToAdd); inventory.itemAcquisitionOrder.AddRange(list2); } } }); static SortMode GetSortMode(ItemIndex indexToSort) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_008a: Invalid comparison between Unknown and I4 //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Invalid comparison between Unknown and I4 ItemDef itemDef = ItemCatalog.GetItemDef(indexToSort); ItemTier val2 = itemDef.deprecatedTier; ItemTierDef itemTierDef = itemDef._itemTierDef; if ((Object)(object)itemTierDef != (Object)null) { string name = ((Object)itemTierDef).name; string text = name; if (!(text == "HexDef")) { if (text == "PageDef") { val2 = (ItemTier)12; } } else { val2 = (ItemTier)11; } } if (curseItemSortMode != SortMode.Unsorted && (int)val2 == 11) { return curseItemSortMode; } if (pageItemSortMode != SortMode.Unsorted && ((int)val2 == 12 || itemDef.ContainsTag((ItemTag)37))) { return pageItemSortMode; } if (questItemSortMode != SortMode.Unsorted && itemDef.ContainsTag((ItemTag)32)) { return questItemSortMode; } if (scrapItemSortMode != SortMode.Unsorted && (itemDef.ContainsTag((ItemTag)10) || itemDef.ContainsTag((ItemTag)14))) { return scrapItemSortMode; } if (lunarItemSortMode != SortMode.Unsorted && (int)val2 == 3) { return lunarItemSortMode; } return SortMode.Unsorted; } } public static void SortInventoryDisplay(orig_UpdateDisplay orig, ItemInventoryDisplay self) { if ((Object)(object)self == (Object)null || (Object)(object)Run.instance == (Object)null || !Run.instance.isRunning) { orig.Invoke(self); } } private void Awake() { //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) Bindings.Init(); AddHooks(); if (killYourselfPageIsQuestItem) { AsyncOperationHandle<ItemDef> val = Addressables.LoadAssetAsync<ItemDef>((object)RoR2_DLC4_CursedBook.PageDie_asset); val.Completed += delegate(AsyncOperationHandle<ItemDef> pageDie) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) ItemDef result = pageDie.Result; if (result.DoesNotContainTag((ItemTag)32)) { ref ItemTag[] tags = ref result.tags; ItemTag val2 = (ItemTag)32; ArrayUtils.ArrayAppend<ItemTag>(ref tags, ref val2); } }; } Bindings.Save(); } public static void DebugBreakpoint(string methodName, int breakpointNumber = -1) { string text = "(PartialInventorySortSystem) " + methodName + " IL hook failed!"; if (breakpointNumber >= 0) { text += $" (breakpoint {breakpointNumber})"; } Debug.LogError((object)text); } } public enum SortMode { VeryFirst, BeforeUnsorted, Unsorted, AfterUnsorted, VeryLast } } namespace PartialInventorySort.Modules { public static class Tools { internal static bool isLoaded(string modguid) { foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos) { string key = pluginInfo.Key; PluginInfo value = pluginInfo.Value; if (key == modguid) { return true; } } return false; } } public static class Assets { internal static Dictionary<string, AssetBundle> loadedBundles = new Dictionary<string, AssetBundle>(); internal static AssetBundle LoadAssetBundle(string bundleName) { if (loadedBundles.ContainsKey(bundleName)) { return loadedBundles[bundleName]; } AssetBundle val = null; val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PartialInventorySortPlugin.PInfo.Location), bundleName)); loadedBundles[bundleName] = val; return val; } } public static class Bindings { internal static ConfigEntry<SortMode> curseSortMode; internal static ConfigEntry<SortMode> pageSortMode; internal static ConfigEntry<SortMode> lunarSortMode; internal static ConfigEntry<SortMode> questSortMode; internal static ConfigEntry<SortMode> scrapSortMode; internal static ConfigEntry<SortMode> bulkSortMode; internal static ConfigEntry<bool> killYourselfPageIsQuestItem; internal static ConfigFile CustomConfigFile { get; set; } public static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\PartialInventorySortSystem.cfg", true); CustomConfigFile.SaveOnConfigSet = false; curseSortMode = CustomConfigFile.Bind<SortMode>("PISS", "Hex Sort Mode", SortMode.VeryLast, (ConfigDescription)null); pageSortMode = CustomConfigFile.Bind<SortMode>("PISS", "Page Sort Mode", SortMode.Unsorted, (ConfigDescription)null); lunarSortMode = CustomConfigFile.Bind<SortMode>("PISS", "Lunar Item Sort Mode", SortMode.Unsorted, (ConfigDescription)null); questSortMode = CustomConfigFile.Bind<SortMode>("PISS", "Quest Item Sort Mode", SortMode.BeforeUnsorted, (ConfigDescription)null); scrapSortMode = CustomConfigFile.Bind<SortMode>("PISS", "Scrap Item Sort Mode", SortMode.VeryFirst, (ConfigDescription)null); killYourselfPageIsQuestItem = CustomConfigFile.Bind<bool>("PISS", "Sacrifice Page is Quest Item", true, (ConfigDescription)null); } public static void Save() { CustomConfigFile.SaveOnConfigSet = true; CustomConfigFile.Save(); } } }