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 NerfGreed v1.0.3
NerfGreed.dll
Decompiled 10 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using RoR2; using RoR2.Items; using RoR2.Orbs; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NerfGreed")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3+f1491a0d1ff19951259d7191135c060826e2d45a")] [assembly: AssemblyProduct("NerfGreed")] [assembly: AssemblyTitle("NerfGreed")] [assembly: AssemblyVersion("1.0.3.0")] [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; } } } namespace NerfGreed { [BepInPlugin("dylhack.NerfGreed", "NerfGreed", "1.0.3")] public sealed class NerfGreedPlugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ReplaceOrbDispatch; } public const string PluginGUID = "dylhack.NerfGreed"; public const string PluginName = "NerfGreed"; public const string PluginVersion = "1.0.3"; private static readonly List<PendingShare> pendingShares = new List<PendingShare>(); private static ManualLogSource log; private ILHook fixedUpdateHook; private void Awake() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown log = ((BaseUnityPlugin)this).Logger; MethodInfo method = typeof(ShareItemsWithEnemiesBehaviour).GetMethod("FixedUpdate", BindingFlags.Instance | BindingFlags.NonPublic); if (method == null) { log.LogError((object)"Couldn't find ShareItemsWithEnemiesBehaviour.FixedUpdate; Hex of Greed is unchanged."); return; } object obj = <>O.<0>__ReplaceOrbDispatch; if (obj == null) { Manipulator val = ReplaceOrbDispatch; <>O.<0>__ReplaceOrbDispatch = val; obj = (object)val; } fixedUpdateHook = new ILHook((MethodBase)method, (Manipulator)obj); } private void OnDestroy() { ILHook obj = fixedUpdateHook; if (obj != null) { obj.Dispose(); } fixedUpdateHook = null; pendingShares.Clear(); } private static void ReplaceOrbDispatch(ILContext il) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) MethodInfo vanillaDispatch = typeof(ItemTransferOrb).GetMethod("DispatchItemTransferOrb", new Type[1] { typeof(DispatchArgs) }); ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)vanillaDispatch) })) { log.LogError((object)"Couldn't find the item orb dispatch in ShareItemsWithEnemiesBehaviour.FixedUpdate; Hex of Greed is unchanged."); return; } val.Remove(); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Call, (MethodBase)typeof(NerfGreedPlugin).GetMethod("DispatchShare", BindingFlags.Static | BindingFlags.NonPublic)); } private static ItemTransferOrb DispatchShare(DispatchArgs args, ShareItemsWithEnemiesBehaviour behaviour) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0081: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) CharacterBody body = ((BaseItemBodyBehavior)behaviour).body; CharacterMaster val = (Object.op_Implicit((Object)(object)body) ? body.master : null); Inventory ownerInventory = (Object.op_Implicit((Object)(object)val) ? val.inventory : null); Inventory inventoryToGrantTo = args.inventoryToGrantTo; if (!Object.op_Implicit((Object)(object)ownerInventory) || !Object.op_Implicit((Object)(object)inventoryToGrantTo)) { return null; } int num = ownerInventory.GetItemCountEffective(args.itemIndex) - inventoryToGrantTo.GetItemCountTotal(args.itemIndex) - CountPending(inventoryToGrantTo, args.itemIndex); int num2 = Mathf.Min(args.permanentCount + args.rentalCount + Mathf.CeilToInt(args.temporaryCount), num); if (num2 <= 0) { return null; } args.permanentCount = 0; args.rentalCount = 0; args.temporaryCount = num2; args.onArrivalBehavior = delegate(ItemTransferOrb orb) { OnShareArrived(orb, ownerInventory); }; ItemTransferOrb val2 = ItemTransferOrb.DispatchItemTransferOrb(args); pendingShares.Add(new PendingShare { orb = val2, expiresAt = Time.fixedTime + args.travelDuration + 1f }); return val2; } private static void OnShareArrived(ItemTransferOrb orb, Inventory ownerInventory) { //IL_0020: 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) RemovePending(orb); Inventory inventoryToGrantTo = orb.inventoryToGrantTo; if (Object.op_Implicit((Object)(object)ownerInventory) && Object.op_Implicit((Object)(object)inventoryToGrantTo)) { int num = ownerInventory.GetItemCountEffective(orb.itemIndex) - inventoryToGrantTo.GetItemCountTotal(orb.itemIndex); orb.tempStack = Mathf.Min(orb.tempStack, (float)num); if (!(orb.tempStack <= 0f)) { ItemTransferOrb.DefaultOnArrivalBehavior(orb); } } } private static int CountPending(Inventory targetInventory, ItemIndex itemIndex) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) int num = 0; for (int num2 = pendingShares.Count - 1; num2 >= 0; num2--) { PendingShare pendingShare = pendingShares[num2]; if (pendingShare.orb == null || !Object.op_Implicit((Object)(object)pendingShare.orb.inventoryToGrantTo) || Time.fixedTime > pendingShare.expiresAt) { pendingShares.RemoveAt(num2); } else if ((Object)(object)pendingShare.orb.inventoryToGrantTo == (Object)(object)targetInventory && pendingShare.orb.itemIndex == itemIndex) { num += Mathf.CeilToInt(pendingShare.orb.tempStack); } } return num; } private static void RemovePending(ItemTransferOrb orb) { for (int num = pendingShares.Count - 1; num >= 0; num--) { if (pendingShares[num].orb == orb) { pendingShares.RemoveAt(num); break; } } } } internal struct PendingShare { public ItemTransferOrb orb; public float expiresAt; } }