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!");
CharacterBody.OnInventoryChanged += new hook_OnInventoryChanged(OnInventoryChanged);
logger.LogInfo((object)"Exponential Item Stacks has loaded successfully!");
}
private void OnInventoryChanged(orig_OnInventoryChanged orig, CharacterBody self)
{
orig.Invoke(self);
}
public void Start()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
logger.LogInfo((object)"Hooking into pickup system...");
GenericPickupController.OnTriggerStay += new hook_OnTriggerStay(OnPickupTrigger);
}
private void OnPickupTrigger(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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Invalid comparison between Unknown and I4
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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)
CharacterBody component = ((Component)collider).GetComponent<CharacterBody>();
if ((Object)(object)component != (Object)null && (Object)(object)component.inventory != (Object)null)
{
PickupIndex pickupIndex = self.pickupIndex;
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
if (pickupDef != null && (int)pickupDef.itemIndex != -1)
{
int itemCountPermanent = component.inventory.GetItemCountPermanent(pickupDef.itemIndex);
if (itemCountPermanent > 0)
{
int num = itemCountPermanent * 2;
if (num > int.MaxValue || num < 0)
{
num = int.MaxValue;
}
int num2 = num - itemCountPermanent;
component.inventory.GiveItemPermanent(pickupDef.itemIndex, num2);
logger.LogInfo((object)$"Doubled item {pickupDef.itemIndex}: {itemCountPermanent} -> {num}");
Object.Destroy((Object)(object)((Component)self).gameObject);
return;
}
}
}
orig.Invoke(self, collider);
}
public void OnDestroy()
{
logger.LogInfo((object)"Exponential Item Stacks is unloading!");
}
}