using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoreStoneStackSize")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreStoneStackSize")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bcd52f46-2fad-4405-8f3e-f25ec33445a2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.lan.MoreItemStackSize", "同种物品堆叠", "1.2.0")]
public class CustomFishStack : BaseUnityPlugin
{
[HarmonyPatch]
public static class PlayerInventoryPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerInventory))]
[HarmonyPatch("UseItem")]
private static bool Prefix(PlayerInventory __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_0063: Unknown result type (might be due to invalid IL or missing references)
InventorySlot currentInventorySlot = __instance.GetCurrentInventorySlot();
ItemSO itemById = GameManager.Instance.GetItemById(__instance.GetCurrentInventorySlot().itemId);
if (itemById.itemName.Contains("fish_trap") || itemById.itemName.Contains("rug") || itemById.itemName.Contains("carpet"))
{
if (currentInventorySlot.amount <= 1 || currentInventorySlot.itemId == -1)
{
return true;
}
__instance.ReduceCurrentItemAmount();
return false;
}
return true;
}
}
[HarmonyPatch]
public static class ItemCrate_EnableDummyItems_Patch_Compatible
{
[HarmonyPrefix]
[HarmonyPatch(typeof(ItemCrate), "EnableDummyItems")]
public static void Prefix(ItemCrate __instance, ref int amount)
{
if (!((Object)(object)__instance.dummyItems == (Object)null))
{
int num = Mathf.Min(amount, __instance.dummyItems.childCount);
amount = num;
}
}
}
private ConfigEntry<int> stoneStackSize;
private ConfigEntry<int> fishTrophySize;
private ConfigEntry<int> fishTrapSize;
private ConfigEntry<int> boneSize;
private ConfigEntry<int> meatSize;
private ConfigEntry<int> flowerSize;
private ConfigEntry<int> weaponSize;
private ConfigEntry<int> potionSize;
public static List<string> flowerItem = new List<string> { "daffodil", "tulip", "camellia", "hyacinth", "zinnia", "blue_iris", "mint_leaf", "cumin_herb", "bamboo" };
public static List<string> weaponItem = new List<string> { "short_sword", "falchion", "knight_sword", "commander_sword", "ornate_sword", "short_bow", "nomad_bow", "red_bow", "amazon_bow" };
private void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Expected O, but got Unknown
ConfigDescription val = new ConfigDescription("物品堆叠数量 --SameType Item Stack Limit", (AcceptableValueBase)null, Array.Empty<object>());
stoneStackSize = ((BaseUnityPlugin)this).Config.Bind<int>("基本设置", "同类型矿石堆叠数量 --SameType ignot/stone Stack Limit", 20, val);
fishTrophySize = ((BaseUnityPlugin)this).Config.Bind<int>("基本设置", "钓鱼奖杯堆叠数量 --fish trophy Stack Limit", 20, val);
fishTrapSize = ((BaseUnityPlugin)this).Config.Bind<int>("基本设置", "鱼笼堆叠数量 --fish trap Stack Limit", 20, val);
boneSize = ((BaseUnityPlugin)this).Config.Bind<int>("基本设置", "骨头、毛皮、地毯堆叠数量 --bone/leather/rug Stack Limit", 20, val);
flowerSize = ((BaseUnityPlugin)this).Config.Bind<int>("基本设置", "花朵堆叠数量 --flower Stack Limit", 20, val);
meatSize = ((BaseUnityPlugin)this).Config.Bind<int>("基本设置", "肉类堆叠数量 --meat Stack Limit", 20, val);
weaponSize = ((BaseUnityPlugin)this).Config.Bind<int>("基本设置", "武器堆叠数量 --weapon Stack Limit", 20, val);
potionSize = ((BaseUnityPlugin)this).Config.Bind<int>("基本设置", "药品堆叠数量 --potion Stack Limit", 20, val);
Harmony val2 = new Harmony("com.lan.MoreItemStackSize");
val2.PatchAll();
Debug.LogWarning((object)$"设置同种类垃圾堆叠数量为:{stoneStackSize.Value} --Set SameType ignot/stone Stack Limit to:{stoneStackSize.Value}");
Debug.LogWarning((object)("矿石堆叠1.0.0加载成功 --作者:她说缝上都不给我" + stoneStackSize.Value));
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
List<ItemSO> list = Resources.FindObjectsOfTypeAll<ItemSO>().ToList();
if (list == null || list.Count == 0)
{
return;
}
for (int i = 0; i < list.Count; i++)
{
if (list[i].itemName.Contains("ingot") || (list[i].itemName.Contains("stone") && !list[i].itemName.Contains("stand")))
{
list[i].stackSize = stoneStackSize.Value;
}
else if (list[i].itemName.Contains("trophy"))
{
list[i].stackSize = fishTrophySize.Value;
}
else if (list[i].itemName.Contains("bone") || list[i].itemName.Contains("leather") || list[i].itemName.Contains("rug") || list[i].itemName.Contains("carpet"))
{
list[i].stackSize = boneSize.Value;
}
else if (flowerItem.Contains(list[i].itemName))
{
list[i].stackSize = flowerSize.Value;
}
else if (list[i].itemName.Contains("fish_trap"))
{
list[i].stackSize = fishTrapSize.Value;
}
else if (list[i].itemName.Equals("meat"))
{
list[i].stackSize = meatSize.Value;
}
else if (weaponItem.Contains(list[i].itemName))
{
list[i].stackSize = weaponSize.Value;
}
else if (list[i].itemName.Contains("potion"))
{
list[i].stackSize = potionSize.Value;
}
}
}
}