Decompiled source of ExponentialItemStacks v1.1.0

exponentialitemstacks/ExponentialItemStacks.dll

Decompiled 10 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using On.RoR2;
using RoR2;
using UnityEngine;

[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ExponentialItemStacks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExponentialItemStacks")]
[assembly: AssemblyTitle("ExponentialItemStacks")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ExponentialItemStacks;

[BepInPlugin("com.yourname.exponentialitemstacks", "Exponential Item Stacks", "1.0.0")]
public class ExponentialItemStacksPlugin : BaseUnityPlugin
{
	public static ManualLogSource logger;

	private const int MAX_STACK = int.MaxValue;

	public void Awake()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		logger = ((BaseUnityPlugin)this).Logger;
		logger.LogInfo((object)"Exponential Item Stacks is loading!");
		GenericPickupController.OnTriggerStay += new hook_OnTriggerStay(OnItemPickup);
		logger.LogInfo((object)"Exponential Item Stacks has loaded successfully!");
	}

	private void OnItemPickup(orig_OnTriggerStay orig, GenericPickupController self, Collider collider)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_0052: Invalid comparison between Unknown and I4
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody component = ((Component)collider).GetComponent<CharacterBody>();
		if ((Object)(object)component != (Object)null && (Object)(object)component.inventory != (Object)null)
		{
			PickupIndex pickupIndex = self.pickupIndex;
			if (((PickupIndex)(ref pickupIndex)).isValid)
			{
				PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
				if (pickupDef != null && (int)pickupDef.itemIndex != -1)
				{
					int itemCount = component.inventory.GetItemCount(pickupDef.itemIndex);
					if (itemCount == 0)
					{
						component.inventory.GiveItem(pickupDef.itemIndex, 1);
					}
					else
					{
						int num = itemCount * 2;
						if (num > int.MaxValue || num < 0)
						{
							num = int.MaxValue;
						}
						int num2 = num - itemCount;
						component.inventory.GiveItem(pickupDef.itemIndex, num2);
						logger.LogInfo((object)$"Item {pickupDef.itemIndex} doubled: {itemCount} -> {num}");
					}
					Object.Destroy((Object)(object)((Component)self).gameObject);
					return;
				}
			}
		}
		orig.Invoke(self, collider);
	}

	public void OnDestroy()
	{
		logger.LogInfo((object)"Exponential Item Stacks is unloading!");
	}
}