using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; 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("AtlyssItemStackMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+54dedd8bf84584f045bb5a856bbff10507f166fc")] [assembly: AssemblyProduct("AtlyssItemStackMod")] [assembly: AssemblyTitle("AtlyssItemStackMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AtlyssItemStackMod { [BepInPlugin("io.github.severnarch.atlyssitemstackmod", "AtlyssItemStackMod", "1.0.1")] public class AtlyssItemStackMod : BaseUnityPlugin { private Harmony _harmony; private static Dictionary _originalMaxStack; public static AtlyssItemStackMod Instance { get; private set; } private void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown Instance = this; _harmony = new Harmony("io.github.severnarch.atlyssitemstackmod"); _originalMaxStack = new Dictionary(); ConstructorInfo constructorInfo = AccessTools.Constructor(typeof(ScriptableItem), (Type[])null, false); _harmony.Patch((MethodBase)constructorInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(AtlyssItemStackMod).GetMethod("ScriptableItemCtorPostfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo = AccessTools.Method(typeof(ItemMenuCell), "PromptCmd_DropItem", (Type[])null, (Type[])null); _harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(AtlyssItemStackMod).GetMethod("DropItemPrefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _harmony.PatchAll(); ((MonoBehaviour)this).StartCoroutine(GameplayLoop()); } private static void ScriptableItemCtorPostfix(ScriptableItem __instance) { if (!((Object)(object)__instance == (Object)null) && __instance._maxStackAmount != 999) { if (!_originalMaxStack.ContainsKey(__instance._itemName)) { _originalMaxStack.Add(__instance._itemName, __instance._maxStackAmount); ((BaseUnityPlugin)Instance).Logger.LogDebug((object)$"Added {__instance._itemName} to stack cache with value of {__instance._maxStackAmount}."); } __instance._maxStackAmount = 999; } } private static bool DropItemPrefix(ref int _quantity, ItemData _itemData) { string itemName = _itemData._itemName; if (_quantity > _originalMaxStack[itemName]) { _quantity = _originalMaxStack[itemName]; } return true; } private void SetAllStackSizes() { try { ScriptableItem[] array = Resources.FindObjectsOfTypeAll(); int num = 0; foreach (ScriptableItem val in array) { if (!((Object)(object)val == (Object)null) && val._maxStackAmount != 999) { if (!_originalMaxStack.ContainsKey(val._itemName)) { _originalMaxStack.Add(val._itemName, val._maxStackAmount); ((BaseUnityPlugin)this).Logger.LogDebug((object)$"Added {val._itemName} to stack cache with value of {val._maxStackAmount}."); } val._maxStackAmount = 999; num++; } } ((BaseUnityPlugin)this).Logger.LogDebug((object)$"Updated {num} ScriptableItems to stack at 999."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Error updating stack sizes: {arg}"); } } private IEnumerator GameplayLoop() { while (true) { yield return (object)new WaitForSeconds(10f); SetAllStackSizes(); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "AtlyssItemStackMod"; public const string PLUGIN_NAME = "AtlyssItemStackMod"; public const string PLUGIN_VERSION = "1.0.1"; } }