using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using LevelGeneration;
using Player;
using SNetwork;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c08182ce-7ec3-4a99-95c6-9fa68e997ee4")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Hikaria.ResourceStack")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Hikaria.ResourceStack")]
[assembly: AssemblyTitle("Hikaria.ResourceStack")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Hikaria.ResourceStack
{
[BepInPlugin("Hikaria.ResourceStack", "ResourceStack", "2.1.1")]
internal class EntryPoint : BasePlugin
{
public static EntryPoint Instance;
private Harmony m_Harmony;
public override void Load()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
Instance = this;
m_Harmony = new Harmony("Hikaria.ResourceStack");
m_Harmony.PatchAll();
Logs.LogMessage("OK");
}
}
internal static class Logs
{
public static void LogDebug(object data)
{
((BasePlugin)EntryPoint.Instance).Log.LogDebug(data);
}
public static void LogError(object data)
{
((BasePlugin)EntryPoint.Instance).Log.LogError(data);
}
public static void LogFatal(object data)
{
((BasePlugin)EntryPoint.Instance).Log.LogFatal(data);
}
public static void LogInfo(object data)
{
((BasePlugin)EntryPoint.Instance).Log.LogInfo(data);
}
public static void LogMessage(object data)
{
((BasePlugin)EntryPoint.Instance).Log.LogMessage(data);
}
public static void LogWarning(object data)
{
((BasePlugin)EntryPoint.Instance).Log.LogWarning(data);
}
}
public static class PluginInfo
{
public const string GUID = "Hikaria.ResourceStack";
public const string NAME = "ResourceStack";
public const string VERSION = "2.1.1";
}
}
namespace Hikaria.ResourceStack.Patches
{
[HarmonyPatch]
internal static class Patch_LG_PickupItem_Sync
{
[HarmonyPatch(typeof(LG_PickupItem_Sync), "AttemptInteract")]
[HarmonyPrefix]
private static void LG_PickupItem_Sync__AttemptInteract__Prefix(LG_PickupItem_Sync __instance, pPickupItemInteraction interaction)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
SNet_Player val = default(SNet_Player);
if (SNet.IsMaster && (int)interaction.type == 0 && ((pPlayer)(ref interaction.pPlayer)).TryGetPlayer(ref val) && val.HasCharacterSlot)
{
TryStackItem(__instance.item, val);
}
}
public static void TryStackItem(Item item, SNet_Player player)
{
//IL_0001: 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)
//IL_000c: Invalid comparison between Unknown and I4
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
//IL_002a: 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_0044: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
//IL_0080: 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_008b: Invalid comparison between Unknown and I4
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
PlayerBackpack val = default(PlayerBackpack);
BackpackItem val2 = default(BackpackItem);
if (((int)item.pItemData.slot != 4 && (int)item.pItemData.slot != 5) || !PlayerBackpackManager.TryGetBackpack(player, ref val) || !val.TryGetBackpackItem(item.pItemData.slot, ref val2) || val2.Instance.pItemData.itemID_gearCRC != item.pItemData.itemID_gearCRC)
{
return;
}
float num = item.ItemDataBlock.ConsumableAmmoMax;
if ((int)item.pItemData.slot == 4)
{
num = 100f;
}
AmmoType val3 = (AmmoType)(((int)item.pItemData.slot == 4) ? 3 : 5);
float ammoInPack = val.AmmoStorage.GetAmmoInPack(val3);
if (!(ammoInPack >= num))
{
float num2 = item.pItemData.custom.ammo + ammoInPack;
pItemData_Custom customData = item.GetCustomData();
if (num2 > num)
{
customData.ammo = num;
((Il2CppObjectBase)item).TryCast<ItemInLevel>().GetSyncComponent().SetCustomData(customData, true);
val.AmmoStorage.SetAmmo(val3, num2 - num);
}
else
{
PlayerBackpackManager.MasterRemoveItem(val2.Instance, player);
customData.ammo = num2;
((Il2CppObjectBase)item).TryCast<ItemInLevel>().GetSyncComponent().SetCustomData(customData, true);
}
}
}
}
}