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 NerfRecycler v0.1.1
NerfRecycler.dll
Decompiled 6 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using HG; using HarmonyLib; using Microsoft.CodeAnalysis; using RoR2; using RoR2.DirectionalSearch; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.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 Prototype { [BepInPlugin("prototype.nerf.recycler", "NerfRecycler", "0.1.1")] public class NerfRecycler : BaseUnityPlugin { [CompilerGenerated] private sealed class <Transpile>d__5 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable<CodeInstruction> IL; public IEnumerable<CodeInstruction> <>3__IL; private MethodInfo <hook>5__2; private MethodInfo <target>5__3; private IEnumerator<CodeInstruction> <>7__wrap3; private CodeInstruction <instruction>5__5; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Transpile>d__5(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 3u) { try { } finally { <>m__Finally1(); } } <hook>5__2 = null; <target>5__3 = null; <>7__wrap3 = null; <instruction>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <hook>5__2 = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => PickupTransmutationManager.GetAvailableGroupFromPickupIndex(default(PickupIndex)))); <target>5__3 = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => FilterByCategory(default(PickupIndex), null))); <>7__wrap3 = IL.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; <>2__current = <instruction>5__5; <>1__state = 2; return true; case 2: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Call, (object)<target>5__3); <>1__state = 3; return true; case 3: <>1__state = -3; goto IL_01b7; case 4: { <>1__state = -3; goto IL_01b7; } IL_01b7: <instruction>5__5 = null; break; } if (<>7__wrap3.MoveNext()) { <instruction>5__5 = <>7__wrap3.Current; if (CodeInstructionExtensions.Calls(<instruction>5__5, <hook>5__2)) { <>2__current = new CodeInstruction(OpCodes.Dup, (object)null); <>1__state = 1; return true; } <>2__current = <instruction>5__5; <>1__state = 4; return true; } <>m__Finally1(); <>7__wrap3 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap3 != null) { <>7__wrap3.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <Transpile>d__5 <Transpile>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <Transpile>d__ = this; } else { <Transpile>d__ = new <Transpile>d__5(0); } <Transpile>d__.IL = <>3__IL; return <Transpile>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } public const string version = "0.1.1"; public const string identifier = "prototype.nerf.recycler"; protected void Awake() { Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SetLanguage)); add("RoR2/DLC1/MinorConstructOnKill/MinorConstructOnKill.asset", (ItemTag)3); replace("RoR2/Base/ParentEgg/ParentEgg.asset", (ItemTag)1, (ItemTag)2); add("RoR2/Base/LunarTrinket/LunarTrinket.asset", (ItemTag)3); add("RoR2/Base/LunarSkillReplacements/LunarUtilityReplacement.asset", (ItemTag)2); replace("RoR2/DLC1/HalfSpeedDoubleHealth/HalfSpeedDoubleHealth.asset", (ItemTag)3, (ItemTag)2); replace("RoR2/DLC1/LunarSun/LunarSun.asset", (ItemTag)3, (ItemTag)1); replace("RoR2/Base/RandomDamageZone/RandomDamageZone.asset", (ItemTag)3, (ItemTag)1); static void add(string key, ItemTag tag) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0013: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<ItemDef> val2 = load(key); val2.Completed += delegate(AsyncOperationHandle<ItemDef> handle) { ArrayUtils.ArrayAppend<ItemTag>(ref handle.Result.tags, ref tag); }; } static AsyncOperationHandle<ItemDef> load(string key) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Addressables.LoadAssetAsync<ItemDef>((object)key); } static void replace(string key, ItemTag previous, ItemTag tag) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<ItemDef> val = load(key); val.Completed += delegate(AsyncOperationHandle<ItemDef> handle) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected I4, but got Unknown handle.Result.tags[Array.IndexOf(handle.Result.tags, previous)] = (ItemTag)(int)tag; }; } } private void SetLanguage() { Language language = Language.english; remove("EQUIPMENT_RECYCLER_PICKUP"); remove("EQUIPMENT_RECYCLER_DESC"); void remove(string token) { language.SetStringByToken(token, language.GetLocalizedStringByToken(token).Replace(" or Equipment", "")); } } [HarmonyPatch(typeof(PickupSearchFilter), "PassesFilter")] [HarmonyPostfix] private static void ItemOnly(GenericPickupController genericPickupController, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if (__result && (int)GetIndex(genericPickupController.pickupIndex) == -1) { __result = false; } } [IteratorStateMachine(typeof(<Transpile>d__5))] [HarmonyPatch(typeof(EquipmentSlot), "FireRecycle")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> IL) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Transpile>d__5(-2) { <>3__IL = IL }; } private static PickupIndex[] FilterByCategory(PickupIndex target, PickupIndex[] original) { //IL_0015: 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) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0027: Invalid comparison between Unknown and I4 //IL_0029: 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_002e: Invalid comparison between Unknown and I4 //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) int num = Run.instance.treasureRng.RangeInt(0, 100); PickupIndex[] array = null; ItemTier tier = item(target).tier; PickupIndex[] array2; if (tier - 6 > 1) { if (tier - 8 > 1) { goto IL_0118; } PickupIndex[] itemVoidTier3Group = PickupTransmutationManager.itemVoidTier3Group; PickupIndex[] itemVoidBossGroup = PickupTransmutationManager.itemVoidBossGroup; int num2 = 0; array2 = (PickupIndex[])(object)new PickupIndex[itemVoidTier3Group.Length + itemVoidBossGroup.Length]; ReadOnlySpan<PickupIndex> readOnlySpan = new ReadOnlySpan<PickupIndex>(itemVoidTier3Group); readOnlySpan.CopyTo(new Span<PickupIndex>(array2).Slice(num2, readOnlySpan.Length)); num2 += readOnlySpan.Length; ReadOnlySpan<PickupIndex> readOnlySpan2 = new ReadOnlySpan<PickupIndex>(itemVoidBossGroup); readOnlySpan2.CopyTo(new Span<PickupIndex>(array2).Slice(num2, readOnlySpan2.Length)); num2 += readOnlySpan2.Length; original = array2; } switch (num) { case 0: case 1: case 2: case 3: case 4: array = PickupTransmutationManager.itemVoidBossGroup; break; case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: array = PickupTransmutationManager.itemVoidTier3Group; break; case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: array = PickupTransmutationManager.itemVoidTier2Group; break; case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: array = PickupTransmutationManager.itemVoidTier1Group; break; } goto IL_0118; IL_0118: if (num >= 75) { return original; } if (array == null) { array = original; } List<PickupIndex> list = new List<PickupIndex>(); IEnumerable<ItemTag> source = item(target).tags.Where((ItemTag category) => category - 1 <= 2); array2 = array; foreach (PickupIndex val in array2) { if (source.Any((Func<ItemTag, bool>)item(val).ContainsTag)) { list.Add(val); } } if (list.Count > 1) { return list.ToArray(); } return original; static ItemDef item(PickupIndex pickup) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ItemCatalog.GetItemDef(GetIndex(pickup)); } } private static ItemIndex GetIndex(PickupIndex pickup) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return PickupCatalog.GetPickupDef(pickup).itemIndex; } } }