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 ItemDuplicator v1.0.3
plugins/ItemDuplicator.dll
Decompiled 5 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ItemDuplicator")] [assembly: AssemblyDescription("Duplicates items on pickup with full configuration support")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ItemDuplicator")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 ItemDuplicator { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.yourname.itemduplicator", "ItemDuplicator", "1.0.2")] public class ItemDuplicatorPlugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static IsDisabledDelegate <>9__17_0; public static IsDisabledDelegate <>9__17_1; public static IsDisabledDelegate <>9__17_2; public static IsDisabledDelegate <>9__17_3; public static IsDisabledDelegate <>9__17_4; public static IsDisabledDelegate <>9__17_5; internal bool <RegisterRiskOfOptions>b__17_0() { return !ModEnabled.Value; } internal bool <RegisterRiskOfOptions>b__17_1() { return !ModEnabled.Value; } internal bool <RegisterRiskOfOptions>b__17_2() { return !ModEnabled.Value; } internal bool <RegisterRiskOfOptions>b__17_3() { return !ModEnabled.Value; } internal bool <RegisterRiskOfOptions>b__17_4() { return !ModEnabled.Value; } internal bool <RegisterRiskOfOptions>b__17_5() { return !ModEnabled.Value; } } [CompilerGenerated] private sealed class <GiveItemsGradually>d__22 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Inventory inventory; public int total; public ItemDuplicatorPlugin <>4__this; public ItemIndex itemIndex; private int <batchSize>5__2; private int <given>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GiveItemsGradually>d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; ItemDuplicatorPlugin itemDuplicatorPlugin = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <batchSize>5__2 = 50; <given>5__3 = 0; break; case 1: <>1__state = -1; break; } if (<given>5__3 < total) { if ((Object)(object)inventory == (Object)null) { return false; } int num2 = Mathf.Min(<batchSize>5__2, total - <given>5__3); itemDuplicatorPlugin._givingBonus = true; if (itemDuplicatorPlugin._giveItemOrig != null) { itemDuplicatorPlugin._giveItemOrig.Invoke(inventory, itemIndex, num2); } else { inventory.GiveItemPermanent(itemIndex, num2); } itemDuplicatorPlugin._givingBonus = false; <given>5__3 += num2; <>2__current = null; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string PluginGUID = "com.yourname.itemduplicator"; public const string PluginName = "ItemDuplicator"; public const string PluginVersion = "1.0.2"; internal static ManualLogSource? Log; public static ConfigEntry<bool>? ModEnabled; public static ConfigEntry<int>? DuplicateCount; public static ConfigEntry<bool>? DuplicateLunarItems; public static ConfigEntry<bool>? DuplicateVoidItems; public static ConfigEntry<bool>? ShredderTakesFullStack; public static ConfigEntry<bool>? PrinterTakesFullStack; public static ConfigEntry<bool>? LockItemsOnPickup; public static ConfigEntry<string>? LockDuration; private bool _itemsLockedThisRun; private bool _itemsLockedThisStage; private bool _givingBonus; private orig_GiveItem_ItemIndex_int? _giveItemOrig; private bool _removingFullStack; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; BindConfig(); if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { RegisterRiskOfOptions(); } HookEvents(); Log.LogInfo((object)"ItemDuplicator v1.0.2 loaded!"); } private void BindConfig() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "Master switch. When false the mod does nothing."); DuplicateCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DuplicateCount", 999, new ConfigDescription("How many copies of each item you receive on pickup (1 = normal, 999 = max stack).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 999), Array.Empty<object>())); DuplicateLunarItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Types", "DuplicateLunarItems", true, "Should lunar items (blue items) be duplicated?"); DuplicateVoidItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Types", "DuplicateVoidItems", true, "Should void-tier items be duplicated? (Survivors of the Void DLC)"); ShredderTakesFullStack = ((BaseUnityPlugin)this).Config.Bind<bool>("Machines", "ShredderTakesFullStack", false, "When true the scrapper/shredder consumes the ENTIRE stack of the chosen item instead of just one."); PrinterTakesFullStack = ((BaseUnityPlugin)this).Config.Bind<bool>("Machines", "PrinterTakesFullStack", false, "When true the 3D printer consumes the ENTIRE stack of the chosen item instead of just one."); LockItemsOnPickup = ((BaseUnityPlugin)this).Config.Bind<bool>("Lock", "LockItemsOnPickup", false, "When true, picking up an item prevents you from collecting any more items for the lock duration."); LockDuration = ((BaseUnityPlugin)this).Config.Bind<string>("Lock", "LockDuration", "stage", new ConfigDescription("How long the item-pickup lock lasts.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "stage", "run" }), Array.Empty<object>())); } private void RegisterRiskOfOptions() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00e7: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00dd: Expected O, but got Unknown //IL_012b: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_016f: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_01b3: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown //IL_01f7: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Expected O, but got Unknown ModSettingsManager.SetModDescription("Duplicate items on pickup. Configure multiplier, item types, machines, and lock behaviour.", "com.yourname.itemduplicator", "ItemDuplicator"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ModEnabled, new CheckBoxConfig { description = "Master switch. Turn off to disable the mod without uninstalling it." })); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(DuplicateCount, new IntSliderConfig { description = "Total copies of each item received per pickup. 1 = vanilla, 999 = maximum stack.", min = 0, max = 999 })); ConfigEntry<bool>? duplicateLunarItems = DuplicateLunarItems; CheckBoxConfig val = new CheckBoxConfig { description = "Should lunar (blue) items be duplicated?" }; object obj = <>c.<>9__17_0; if (obj == null) { IsDisabledDelegate val2 = () => !ModEnabled.Value; <>c.<>9__17_0 = val2; obj = (object)val2; } ((BaseOptionConfig)val).checkIfDisabled = (IsDisabledDelegate)obj; ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(duplicateLunarItems, val)); ConfigEntry<bool>? duplicateVoidItems = DuplicateVoidItems; CheckBoxConfig val3 = new CheckBoxConfig { description = "Should void-tier items (Survivors of the Void DLC) be duplicated?" }; object obj2 = <>c.<>9__17_1; if (obj2 == null) { IsDisabledDelegate val4 = () => !ModEnabled.Value; <>c.<>9__17_1 = val4; obj2 = (object)val4; } ((BaseOptionConfig)val3).checkIfDisabled = (IsDisabledDelegate)obj2; ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(duplicateVoidItems, val3)); ConfigEntry<bool>? shredderTakesFullStack = ShredderTakesFullStack; CheckBoxConfig val5 = new CheckBoxConfig { description = "When ON, the scrapper/shredder removes your ENTIRE stack of the chosen item instead of just one." }; object obj3 = <>c.<>9__17_2; if (obj3 == null) { IsDisabledDelegate val6 = () => !ModEnabled.Value; <>c.<>9__17_2 = val6; obj3 = (object)val6; } ((BaseOptionConfig)val5).checkIfDisabled = (IsDisabledDelegate)obj3; ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(shredderTakesFullStack, val5)); ConfigEntry<bool>? printerTakesFullStack = PrinterTakesFullStack; CheckBoxConfig val7 = new CheckBoxConfig { description = "When ON, the 3D printer removes your ENTIRE stack of the input item instead of just one." }; object obj4 = <>c.<>9__17_3; if (obj4 == null) { IsDisabledDelegate val8 = () => !ModEnabled.Value; <>c.<>9__17_3 = val8; obj4 = (object)val8; } ((BaseOptionConfig)val7).checkIfDisabled = (IsDisabledDelegate)obj4; ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(printerTakesFullStack, val7)); ConfigEntry<bool>? lockItemsOnPickup = LockItemsOnPickup; CheckBoxConfig val9 = new CheckBoxConfig { description = "When ON, picking up an item prevents you from collecting more items until the lock expires." }; object obj5 = <>c.<>9__17_4; if (obj5 == null) { IsDisabledDelegate val10 = () => !ModEnabled.Value; <>c.<>9__17_4 = val10; obj5 = (object)val10; } ((BaseOptionConfig)val9).checkIfDisabled = (IsDisabledDelegate)obj5; ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(lockItemsOnPickup, val9)); ConfigEntry<string>? lockDuration = LockDuration; ChoiceConfig val11 = new ChoiceConfig { description = "How long the pickup lock lasts: 'stage' resets each stage, 'run' lasts the whole run. Only applies when Lock Items On Pickup is enabled." }; object obj6 = <>c.<>9__17_5; if (obj6 == null) { IsDisabledDelegate val12 = () => !ModEnabled.Value; <>c.<>9__17_5 = val12; obj6 = (object)val12; } ((BaseOptionConfig)val11).checkIfDisabled = (IsDisabledDelegate)obj6; ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)lockDuration, val11)); } private void HookEvents() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown Inventory.GiveItem_ItemIndex_int += new hook_GiveItem_ItemIndex_int(OnGiveItem); Inventory.RemoveItem_ItemIndex_int += new hook_RemoveItem_ItemIndex_int(OnRemoveItem); ShopTerminalBehavior.DropPickup += new hook_DropPickup(OnPrinterDrop); Run.BeginStage += new hook_BeginStage(OnBeginStage); Run.Start += new hook_Start(OnRunStart); } private void OnGiveItem(orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) _giveItemOrig = orig; orig.Invoke(self, itemIndex, count); if (!_givingBonus) { TryGiveBonus(self, itemIndex, count); } } private void TryGiveBonus(Inventory self, ItemIndex itemIndex, int count) { //IL_004d: 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) if (!ModEnabled.Value || !NetworkServer.active || (LockItemsOnPickup.Value && ((LockDuration.Value.ToLower() == "run") ? _itemsLockedThisRun : _itemsLockedThisStage))) { return; } ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); if ((Object)(object)itemDef == (Object)null || !ShouldDuplicate(itemDef)) { return; } int num = Mathf.Clamp(DuplicateCount.Value - 1, 0, 999) * count; if (num > 0) { _givingBonus = true; try { ((MonoBehaviour)this).StartCoroutine(GiveItemsGradually(self, itemIndex, num)); } finally { _givingBonus = false; } if (LockItemsOnPickup.Value) { _itemsLockedThisRun = true; _itemsLockedThisStage = true; } } } [IteratorStateMachine(typeof(<GiveItemsGradually>d__22))] private IEnumerator GiveItemsGradually(Inventory inventory, ItemIndex itemIndex, int total) { //IL_0015: 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) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <GiveItemsGradually>d__22(0) { <>4__this = this, inventory = inventory, itemIndex = itemIndex, total = total }; } private bool ShouldDuplicate(ItemDef item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 if ((int)item.tier == 3 && !DuplicateLunarItems.Value) { return false; } if (((int)item.tier == 6 || (int)item.tier == 7 || (int)item.tier == 8 || (int)item.tier == 9) && !DuplicateVoidItems.Value) { return false; } if ((int)item.tier == 5) { return false; } return true; } private void OnRemoveItem(orig_RemoveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_006d: Unknown result type (might be due to invalid IL or missing references) if (!ModEnabled.Value || !ShredderTakesFullStack.Value || _removingFullStack) { orig.Invoke(self, itemIndex, count); return; } if (!NetworkServer.active) { orig.Invoke(self, itemIndex, count); return; } if (count != 1) { orig.Invoke(self, itemIndex, count); return; } int itemCountPermanent = self.GetItemCountPermanent(itemIndex); if (itemCountPermanent <= 1) { orig.Invoke(self, itemIndex, count); return; } _removingFullStack = true; try { orig.Invoke(self, itemIndex, itemCountPermanent); } finally { _removingFullStack = false; } } private void OnPrinterDrop(orig_DropPickup orig, ShopTerminalBehavior self) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Invalid comparison between Unknown and I4 //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Invalid comparison between Unknown and I4 //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) if (!ModEnabled.Value || !PrinterTakesFullStack.Value) { orig.Invoke(self); return; } if (!NetworkServer.active) { orig.Invoke(self); return; } PurchaseInteraction component = ((Component)self).GetComponent<PurchaseInteraction>(); CharacterBody val = null; if ((Object)(object)component?.lastActivator != (Object)null) { val = ((Component)component.lastActivator).GetComponent<CharacterBody>(); } bool flag = (Object)(object)component != (Object)null && (int)component.costType != 0 && (int)component.costType != 1 && (int)component.costType != 2 && (int)component.costType != 3 && (int)component.costType != 14; if ((Object)(object)((val != null) ? val.inventory : null) != (Object)null && flag) { PickupDef pickupDef = PickupCatalog.GetPickupDef(self.CurrentPickup().pickupIndex); ItemDef val2 = ((pickupDef != null) ? ItemCatalog.GetItemDef(pickupDef.itemIndex) : null); if ((Object)(object)val2 != (Object)null) { foreach (ItemIndex item in val.inventory.itemAcquisitionOrder) { if (val.inventory.GetItemCountPermanent(item) <= 0) { continue; } ItemDef itemDef = ItemCatalog.GetItemDef(item); if (!((Object)(object)itemDef == (Object)null) && itemDef.tier == val2.tier) { int itemCountPermanent = val.inventory.GetItemCountPermanent(item); if (itemCountPermanent > 1) { val.inventory.RemoveItemPermanent(item, itemCountPermanent - 1); } break; } } } } orig.Invoke(self); } private void OnBeginStage(orig_BeginStage orig, Run self) { orig.Invoke(self); _itemsLockedThisStage = false; } private void OnRunStart(orig_Start orig, Run self) { orig.Invoke(self); _itemsLockedThisRun = false; _itemsLockedThisStage = false; } } }