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 SimpleTiers v1.0.1
SimpleTiers.dll
Decompiled 20 minutes agousing System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HG.Reflection; using HarmonyLib; using Mono.Cecil.Cil; using MonoMod.Cil; using R2API; using R2API.Utils; using RoR2; using RoR2.ContentManagement; using RoR2BepInExPack.GameAssetPaths; 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: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("SimpleTiers")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SimpleTiers")] [assembly: AssemblyTitle("SimpleTiers")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace SimpleTiers; internal static class Hooks { [SystemInitializer(new Type[] { typeof(ItemTierCatalog) })] private static void AssignTierSortOrder() { SimpleTiersPlugin.RecalculateItemTierSortOrder(); } } [HarmonyPatch] internal class ItemTierOrder { [HarmonyPatch("RoR2.UI.LogBook.LogBookController+<>c, RoR2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "<BuildPickupEntries>b__94_3")] [HarmonyILManipulator] public static void PatchItemTierOrder(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); val.EmitDelegate<Action>((Action)delegate { }); if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<ItemDef>(x, "get_tier") })) { Debug.LogError((object)"SimpleTiers: PatchItemTierOrder failed!"); return; } val.EmitDelegate<Func<int, int>>((Func<int, int>)delegate(int sortOrderIn) { //IL_0002: 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) ItemTier key = (ItemTier)sortOrderIn; int result = sortOrderIn; if (SimpleTiersPlugin.itemTierSortOrder != null && SimpleTiersPlugin.itemTierSortOrder.Count > 0) { result = SimpleTiersPlugin.itemTierSortOrder[key]; } return result; }); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.RiskOfBrainrot.SimpleTiers", "SimpleTiers", "1.0.0")] public class SimpleTiersPlugin : BaseUnityPlugin { public static SimpleTiersPlugin instance; public const string guid = "com.RiskOfBrainrot.SimpleTiers"; public const string teamName = "RiskOfBrainrot"; public const string modName = "SimpleTiers"; public const string version = "1.0.0"; private static AssetBundle _mainAssetBundle; private static Dictionary<ItemTier, int> itemTierDesired = new Dictionary<ItemTier, int>(); public static ReadOnlyDictionary<ItemTier, int> itemTierSortOrder = new ReadOnlyDictionary<ItemTier, int>(_itemTierSortOrder); private static int tierDisplacementCt = 0; public static AssetBundle mainAssetBundle { get { if ((Object)(object)_mainAssetBundle == (Object)null) { _mainAssetBundle = Assets.LoadAssetBundle("simpletiers"); } return _mainAssetBundle; } set { _mainAssetBundle = value; } } internal static Dictionary<ItemTier, int> _itemTierSortOrder { get; private set; } = new Dictionary<ItemTier, int>(); public static void SetDesiredTier(ItemTier tier, int sortOrder) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (itemTierDesired == null) { itemTierDesired = new Dictionary<ItemTier, int>(); } if (!itemTierDesired.TryAdd(tier, sortOrder)) { itemTierDesired[tier] = sortOrder; } RecalculateItemTierSortOrder(); } private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown instance = this; Harmony val = new Harmony("com.RiskOfBrainrot.SimpleTiers"); val.PatchAll(); SetDesiredTier((ItemTier)10, 11); SimpleTiersPlugin.LoadAsync<ItemTierDef>(RoR2_DLC3.FoodTier_asset, (Action<ItemTierDef>)delegate(ItemTierDef foodTier) { //IL_0004: 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_0016: 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) foodTier.colorIndex = (ColorIndex)34; foodTier.darkColorIndex = (ColorIndex)36; ItemTierDef val2 = Addressables.LoadAssetAsync<ItemTierDef>((object)RoR2_DLC4.CursedTierDef_asset).WaitForCompletion(); foodTier.bgIconTexture = val2.bgIconTexture; foodTier.dropletDisplayPrefab = val2.dropletDisplayPrefab; foodTier.highlightPrefab = val2.highlightPrefab; }); QuickFix(RoR2_DLC3_Items_BonusHealthBoost.BonusHealthBoost_asset, "Quick_Fix"); QuickFix(RoR2_DLC3_Items_CookedSteak.CookedSteak_asset, "Seared_Steak"); QuickFix(RoR2_DLC3_Items_Stew.Stew_asset, "Hearty_Stew"); QuickFix(RoR2_DLC3_Items_WyrmOnHit.WyrmOnHit_asset, "Sauteed_Worms"); QuickFix(RoR2_DLC3_Items_UltimateMeal.UltimateMeal_asset, "Ultimate_Meal"); QuickFix(RoR2_DLC4_BlightZone.BlightZone_asset, "Corpse_Lily"); QuickFix(RoR2_DLC4_LowHealthOrbSpawner.LowHealthOrbSpawner_asset, "Dream_Crucible"); QuickFix(RoR2_DLC4_RechargeableJump.RechargeableJump_asset, "Earthbound_Vessel"); QuickFix(RoR2_DLC4_CasuticPheromones.CausticPheromones_asset, "Infernal_Mark"); QuickFix(RoR2_DLC4_DreamDemon.DreamDemon_asset, "Nightmare_Demon"); QuickFix(RoR2_DLC4_SprintDamage.SprintDamage_asset, "Ritual_Helmet"); QuickFix(RoR2_DLC4_SanguineChalice.SanguineChalice_asset, "Sanguine_Chalice"); QuickFix(RoR2_DLC4_GhostBlades.GhostBlades_asset, "Stained_Scimitar"); QuickFix(RoR2_DLC4_GoldenGoose.GoldenGoose_asset, "Totem_of_Avarice"); QuickFix(RoR2_DLC4_VengefulSpirit.VengefulSpirit_asset, "Vengeful_Spirit"); QuickFix(RoR2_DLC4_VileCenser.VileCenser_asset, "Vile_Censer"); LanguageAPI.Add("HEXTIER_DESC_SUFFIX", "{0}\nCan be cleansed at a <style=cHumanObjective>Hallowed Shrine</style> to reveal a <color=#3f870c>Coveted</color> item."); LanguageAPI.Add("ITEM_HEXCLEANSECONSUMED_DESC", "A rune with no Cleansing Power left. It cleansed all your Hexes into Coveted Items."); LanguageAPI.Add("SHRINE_CURSE_ACCEPT_DESCRIPTION", "Spawn the displayed <style=cIsHealing>Coveted Item</style>. This item will be <style=cIsHealing>Vexed</style> requiring its holder to complete a <style=cIsHealing>Cursed Objective</style> to <style=cIsUtility>Calm</style> it."); LanguageAPI.Add("SHRINE_CURSE_REROLL_DESCRIPTION", "Reroll the displayed <style=cIsHealing>Coveted Item</style>."); LanguageAPI.Add("SHRINE_CURSE_REROLL_CONTEXT", "Reroll Coveted Item"); LanguageAPI.Add("CURSED_SEED_LABEL", "Choose a Coveted Item."); } private void QuickFix(string path, string iconPath) { SimpleTiersPlugin.LoadAsync<ItemDef>(path, (Action<ItemDef>)delegate(ItemDef itemDef) { itemDef.pickupIconSpriteReference = null; itemDef.pickupIconSprite = TryLoadSpriteFromBundle("Assets/SimpleTiers/" + iconPath + ".png"); }); } internal static void RecalculateItemTierSortOrder() { //IL_0028: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected I4, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between I4 and Unknown tierDisplacementCt = 0; _itemTierSortOrder.Clear(); if (!((ResourceAvailability)(ref ItemTierCatalog.availability)).available) { return; } IEnumerable<ItemTierDef> enumerable = ((IEnumerable<ItemTierDef>)(object)ItemTierCatalog.allItemTierDefs).OrderBy((ItemTierDef x) => (int)x.tier); foreach (ItemTierDef item in enumerable) { ItemTier tier = item.tier; int num = (int)tier; int value = num + tierDisplacementCt; if (itemTierDesired.ContainsKey(tier)) { num = itemTierDesired[tier]; value = num + tierDisplacementCt; if (num != (int)tier && (Object)(object)ItemTierCatalog.GetItemTierDef((ItemTier)num) != (Object)null) { tierDisplacementCt++; } } _itemTierSortOrder.TryAdd(item.tier, value); } } public static Sprite TryLoadSpriteFromBundle(string path, AssetBundle assetBundle = null, bool fallBackOnWrench = false) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Sprite val = SimpleTiersPlugin.TryLoadFromBundle<Sprite>(path, assetBundle); if (Object.op_Implicit((Object)(object)val)) { return val; } return Addressables.LoadAssetAsync<Sprite>((object)(fallBackOnWrench ? RoR2_Base_Core.texNullIcon_png : RoR2_Base_Common_MiscIcons.texWIPIcon_png)).WaitForCompletion(); } public static T TryLoadFromBundle<T>(string path, AssetBundle assetBundle = null) where T : Object { if ((Object)(object)assetBundle == (Object)null) { assetBundle = mainAssetBundle; } if (Object.op_Implicit((Object)(object)assetBundle) && !string.IsNullOrWhiteSpace(path) && assetBundle.Contains(path)) { return assetBundle.LoadAsset<T>(path); } return default(T); } public static AssetReferenceT<T> LoadAsync<T>(string guid, Action<T> callback) where T : Object { //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_0040: Unknown result type (might be due to invalid IL or missing references) AssetReferenceT<T> val = new AssetReferenceT<T>(guid); AsyncOperationHandle<T> handle = AssetAsyncReferenceManager<T>.LoadAsset(val, (AsyncReferenceHandleUnloadType)2); if (callback == null) { return val; } if (handle.IsDone) { onCompleted(handle); return val; } handle.Completed += onCompleted; return val; void onCompleted(AsyncOperationHandle<T> val2) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 if (val2.Result == null || (int)val2.Status != 1) { Debug.LogError((object)$"Failed to load asset [{val2.DebugName}] : {val2.OperationException}"); } else { callback(val2.Result); } } } public static void RemoveCraftingRecipe(string guid) { SimpleTiersPlugin.LoadAsync<CraftableDef>(guid, (Action<CraftableDef>)delegate(CraftableDef craftableDef) { craftableDef.recipes = (Recipe[])(object)new Recipe[0]; }); } } internal 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(((BaseUnityPlugin)SimpleTiersPlugin.instance).Info.Location), bundleName)); loadedBundles[bundleName] = val; return val; } }