Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of GPVStacks v1.0.1
GPVStacks.dll
Decompiled 8 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using GPVStacks; using HarmonyLib; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.ObjectScripts; using Il2CppScheduleOne.UI.Items; using Il2CppScheduleOne.UI.Phone.Delivery; using Il2CppScheduleOne.UI.Shop; using Il2CppScheduleOne.UI.Stations; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(GPVStacksMod), "GPV Stacks", "1.0.0", "Gamingprovids", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("GPVStacks")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("GPVStacks")] [assembly: AssemblyTitle("GPVStacks")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace GPVStacks { public class GPVStacksMod : MelonMod { [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static class StackLimitPatch { private static void Postfix(ItemInstance __instance, ref int __result) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (!_alreadyModifiedItems.Contains(__instance.Definition)) { if (IsSpecialCase(__instance.Name)) { __result *= _config.CocaLeaf; } else { __result *= GetCapacityModifier(__instance.Category); } if (!_alreadyLoggedItems.Contains(__instance.Name)) { MelonLogger.Msg($"[GPV Stacks] {__instance.Name} ({__instance.Category}) stack limit set to {__result}"); _alreadyLoggedItems.Add(__instance.Name); } } } } [HarmonyPatch(typeof(ItemInstance), "SetQuantity")] private static class SetQuantityPatch { private static bool Prefix(ItemInstance __instance, int quantity) { int stackLimit = __instance.StackLimit; quantity = Math.Clamp(quantity, 0, stackLimit); __instance.Quantity = quantity; __instance.InvokeDataChange(); if (!_alreadyLoggedItems.Contains(__instance.Name)) { MelonLogger.Msg($"[GPV Stacks] SetQuantity called on {__instance.Name}, new quantity: {quantity}/{stackLimit}"); _alreadyLoggedItems.Add(__instance.Name); } return false; } } [HarmonyPatch(typeof(ItemInstance), "ChangeQuantity")] private static class ChangeQuantityPatch { private static bool Prefix(ItemInstance __instance, int change) { int num = __instance.Quantity + change; int stackLimit = __instance.StackLimit; if (num < 0) { num = 0; if (!_alreadyLoggedItems.Contains(__instance.Name)) { MelonLogger.Warning("[GPV Stacks] Prevented negative quantity for " + __instance.Name); _alreadyLoggedItems.Add(__instance.Name); } } else if (num > stackLimit) { num = stackLimit; } __instance.Quantity = num; __instance.InvokeDataChange(); return false; } } [HarmonyPatch(typeof(MixingStation), "Start")] private static class MixingStationPatch { private static bool Prefix(MixingStation __instance) { __instance.MixTimePerItem /= _config.MixingStationSpeed; __instance.MixTimePerItem = Math.Max(1, __instance.MixTimePerItem); __instance.MaxMixQuantity *= _config.MixingStationCapacity; MelonLogger.Msg($"[GPV Stacks] Set MixingStation MaxMixQuantity: {__instance.MaxMixQuantity}"); return true; } } [HarmonyPatch(typeof(DryingRackCanvas), "SetIsOpen")] private static class DryingRackPatch { private static void Prefix(DryingRackCanvas __instance, DryingRack rack, bool open) { if ((Object)(object)rack != (Object)null && rack.ItemCapacity != _config.DryingRackCapacity * 20) { rack.ItemCapacity = _config.DryingRackCapacity * 20; MelonLogger.Msg($"[GPV Stacks] Set DryingRack capacity to {rack.ItemCapacity}"); } } } [HarmonyPatch(typeof(ListingEntry), "Initialize")] private static class ListingEntryPatch { private static void Postfix(ListingEntry __instance, ShopListing match) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) StorableItemDefinition item = match.Item; if (!_alreadyModifiedItems.Contains((ItemDefinition)(object)item)) { _alreadyModifiedItems.Add((ItemDefinition)(object)item); int stackLimit = ((ItemDefinition)item).StackLimit; if (IsSpecialCase(((ItemDefinition)item).Name)) { ((ItemDefinition)item).StackLimit = ((ItemDefinition)item).StackLimit * _config.CocaLeaf; } else { ((ItemDefinition)item).StackLimit = ((ItemDefinition)item).StackLimit * GetCapacityModifier(((ItemDefinition)item).Category); } MelonLogger.Msg($"[GPV Stacks] ListingEntry: {((ItemDefinition)item).Name} stack limit set from {stackLimit} to {((ItemDefinition)item).StackLimit}"); } } } [HarmonyPatch(typeof(ItemUIManager))] private static class ItemUIManagerPatches { [CompilerGenerated] private sealed class <ModifyCashDragInstructions>d__3 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> <>3__instructions; private IEnumerator<CodeInstruction> <>s__1; private CodeInstruction <ins>5__2; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ModifyCashDragInstructions>d__3(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } <>s__1 = null; <ins>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>s__1 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; goto IL_00ea; case 2: { <>1__state = -3; goto IL_00ea; } IL_00ea: <ins>5__2 = null; break; } if (<>s__1.MoveNext()) { <ins>5__2 = <>s__1.Current; if (<ins>5__2.opcode == OpCodes.Ldc_R4 && (float)<ins>5__2.operand == 1000f) { <>2__current = new CodeInstruction(OpCodes.Ldc_R4, (object)5000f); <>1__state = 1; return true; } <>2__current = <ins>5__2; <>1__state = 2; return true; } <>m__Finally1(); <>s__1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>s__1 != null) { <>s__1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <ModifyCashDragInstructions>d__3 <ModifyCashDragInstructions>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <ModifyCashDragInstructions>d__ = this; } else { <ModifyCashDragInstructions>d__ = new <ModifyCashDragInstructions>d__3(0); } <ModifyCashDragInstructions>d__.instructions = <>3__instructions; return <ModifyCashDragInstructions>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } [HarmonyPatch("UpdateCashDragAmount")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> UpdateCashDragAmountTranspiler(IEnumerable<CodeInstruction> instructions) { return ModifyCashDragInstructions(instructions); } [HarmonyPatch("StartDragCash")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> StartDragCashTranspiler(IEnumerable<CodeInstruction> instructions) { return ModifyCashDragInstructions(instructions); } [HarmonyPatch("EndCashDrag")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> EndCashDragTranspiler(IEnumerable<CodeInstruction> instructions) { return ModifyCashDragInstructions(instructions); } [IteratorStateMachine(typeof(<ModifyCashDragInstructions>d__3))] private static IEnumerable<CodeInstruction> ModifyCashDragInstructions(IEnumerable<CodeInstruction> instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ModifyCashDragInstructions>d__3(-2) { <>3__instructions = instructions }; } } private static ModConfig _config = new ModConfig(); private static readonly HashSet<ItemDefinition> _alreadyModifiedItems = new HashSet<ItemDefinition>(); private static readonly HashSet<string> _alreadyLoggedItems = new HashSet<string>(); public override void OnInitializeMelon() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown _config = LoadConfig(); Harmony val = new Harmony("com.gamingprovids.gpvstacks"); val.PatchAll(); } private static ModConfig LoadConfig() { string text = Path.Combine(MelonEnvironment.ModsDirectory, "GPVStackConfig.json"); if (File.Exists(text)) { string text2 = File.ReadAllText(text); return JsonConvert.DeserializeObject<ModConfig>(text2); } MelonLogger.Warning("Config file not found: " + text); return new ModConfig(); } private static int GetCapacityModifier(EItemCategory category) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected I4, but got Unknown if (1 == 0) { } int result = (int)category switch { 0 => _config.Product, 1 => _config.Packaging, 2 => _config.Growing, 3 => _config.Tools, 4 => _config.Furniture, 5 => _config.Lighting, 6 => _config.Cash, 7 => _config.Consumable, 8 => _config.Equipment, 9 => _config.Ingredient, 10 => _config.Decoration, 11 => _config.Clothing, _ => 1, }; if (1 == 0) { } return result; } private static bool IsSpecialCase(string itemName) { return itemName == "Coca Leaf" || itemName == "Coca Seed"; } } public class ModConfig { public int Product { get; set; } = 1; public int Packaging { get; set; } = 1; public int Growing { get; set; } = 1; public int Tools { get; set; } = 1; public int Furniture { get; set; } = 1; public int Lighting { get; set; } = 1; public int Cash { get; set; } = 1; public int Consumable { get; set; } = 1; public int Equipment { get; set; } = 1; public int Ingredient { get; set; } = 1; public int Decoration { get; set; } = 1; public int Clothing { get; set; } = 1; public int CocaLeaf { get; set; } = 1; public int MixingStationCapacity { get; set; } = 1; public int MixingStationSpeed { get; set; } = 3; public int DryingRackCapacity { get; set; } = 1; } }