Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of ProduceMoreIL2CPP v1.1.5
Mods/ProduceMoreIL2CPP.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using HarmonyLib; using Il2CppFishNet; using Il2CppFishNet.Connection; using Il2CppFishNet.Object; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Employees; using Il2CppScheduleOne.EntityFramework; using Il2CppScheduleOne.GameTime; using Il2CppScheduleOne.Growing; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Lighting; using Il2CppScheduleOne.Management; using Il2CppScheduleOne.Money; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.NPCs.Behaviour; using Il2CppScheduleOne.ObjectScripts; using Il2CppScheduleOne.Packaging; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Product; using Il2CppScheduleOne.Product.Packaging; using Il2CppScheduleOne.StationFramework; using Il2CppScheduleOne.Trash; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Items; using Il2CppScheduleOne.UI.Management; using Il2CppScheduleOne.UI.Phone.Delivery; using Il2CppScheduleOne.UI.Shop; using Il2CppScheduleOne.UI.Stations; using Il2CppScheduleOne.UI.Stations.Drying_rack; using Il2CppScheduleOne.Variables; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppTMPro; using MelonLoader; using Microsoft.CodeAnalysis; using ProduceMore; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(ProduceMoreMod), "ProduceMore", "1.1.5", "lasersquid", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ProduceMoreIL2CPP")] [assembly: AssemblyConfiguration("IL2CPP")] [assembly: AssemblyFileVersion("1.1.5.0")] [assembly: AssemblyInformationalVersion("1.1.5+726b7bb9bafdca3060d8d1e6d4638238249e3351")] [assembly: AssemblyProduct("ProduceMoreIL2CPP")] [assembly: AssemblyTitle("ProduceMoreIL2CPP")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.5.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 ProduceMore { public class ProduceMoreMod : MelonMod { public MelonPreferences_Category stationSpeeds; public MelonPreferences_Category stationCapacities; public MelonPreferences_Category employeeAnimation; public MelonPreferences_Category stackSizes; public MelonPreferences_Category stackOverrides; public IEqualityComparer<Object> unityComparer; public HashSet<GridItem> processedStationCapacities; public HashSet<GridItem> processedStationSpeeds; public HashSet<GridItem> processedStationTimes; public HashSet<ItemDefinition> processedItemDefs; public HashSet<StationRecipe> processedRecipes; public Dictionary<string, int> originalStackLimits; public Dictionary<string, int> originalStationCapacities; public Dictionary<string, int> originalStationTimes; public Dictionary<StationRecipe, int> originalRecipeTimes; public HashSet<NPC> registeredEmployees; public List<object> runningCoroutines; public bool plantsAlwaysGrowPresent = false; public bool checkedMelons = false; public Harmony harmony = new Harmony("com.lasersquid.producemore"); public ProduceMoreMod() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown unityComparer = new Utils.UnityObjectComparer(); processedStationCapacities = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer); processedStationSpeeds = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer); processedStationTimes = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer); processedItemDefs = new HashSet<ItemDefinition>((IEqualityComparer<ItemDefinition>?)unityComparer); processedRecipes = new HashSet<StationRecipe>((IEqualityComparer<StationRecipe>?)unityComparer); originalStackLimits = new Dictionary<string, int>(); originalStationCapacities = new Dictionary<string, int>(); originalStationTimes = new Dictionary<string, int>(); originalRecipeTimes = new Dictionary<StationRecipe, int>((IEqualityComparer<StationRecipe>?)unityComparer); registeredEmployees = new HashSet<NPC>((IEqualityComparer<NPC>?)unityComparer); runningCoroutines = new List<object>(); } public override void OnInitializeMelon() { InitializeMelonPreferences(); Utils.Initialize(this); ((MelonBase)this).LoggerInstance.Msg("Initialized."); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { ((MelonMod)this).OnSceneWasLoaded(buildIndex, sceneName); if (sceneName.ToLower().Contains("main") || sceneName.ToLower().Contains("tutorial")) { if (!checkedMelons) { plantsAlwaysGrowPresent = Utils.OtherModIsLoaded("PlantsAlwaysGrowMod"); checkedMelons = true; } Utils.LateInitialize(); } } public override void OnSceneWasUnloaded(int buildIndex, string sceneName) { ((MelonMod)this).OnSceneWasUnloaded(buildIndex, sceneName); if (sceneName.ToLower().Contains("main") || sceneName.ToLower().Contains("tutorial")) { ResetState(); } } public void StopCoroutines() { foreach (object runningCoroutine in runningCoroutines) { if (runningCoroutine != null) { MelonCoroutines.Stop(runningCoroutine); } } runningCoroutines.Clear(); } public override void OnPreferencesSaved() { ((MelonBase)this).OnPreferencesSaved(); ResetState(); } private void ResetState() { processedStationCapacities = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer); processedStationSpeeds = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer); processedStationTimes = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer); processedItemDefs = new HashSet<ItemDefinition>((IEqualityComparer<ItemDefinition>?)unityComparer); processedRecipes = new HashSet<StationRecipe>((IEqualityComparer<StationRecipe>?)unityComparer); } private void InitializeMelonPreferences() { stationSpeeds = MelonPreferences.CreateCategory("ProduceMore_01_station_speeds", "Station Speeds (1=normal, 2=double, 0.5=half)"); employeeAnimation = MelonPreferences.CreateCategory("ProduceMore_02_employee_animation", "Employee Speed (1=normal, 2=double, 0.5=half)"); stationCapacities = MelonPreferences.CreateCategory("ProduceMore_03_station_capacities", "Station Capacities"); stackSizes = MelonPreferences.CreateCategory("ProduceMore_04_stack_sizes", "Stack Limits (by category)"); stackOverrides = MelonPreferences.CreateCategory("ProduceMore_05_stack_overrides", "Stack Limit Overrides"); stationSpeeds.SetFilePath("UserData/ProduceMore.cfg", true, false); stationCapacities.SetFilePath("UserData/ProduceMore.cfg", true, false); employeeAnimation.SetFilePath("UserData/ProduceMore.cfg", true, false); stackSizes.SetFilePath("UserData/ProduceMore.cfg", true, false); stackOverrides.SetFilePath("UserData/ProduceMore.cfg", true, false); stationSpeeds.CreateEntry<float>("LabOven", 1f, "Lab Oven", false); stationSpeeds.CreateEntry<float>("Cauldron", 1f, "Cauldron", false); stationSpeeds.CreateEntry<float>("BrickPress", 1f, "Brick Press", false); stationSpeeds.CreateEntry<float>("ChemistryStation", 1f, "Chemistry Station", false); stationSpeeds.CreateEntry<float>("DryingRack", 1f, "Drying Rack", false); stationSpeeds.CreateEntry<float>("MixingStation", 1f, "Mixing Station", false); stationSpeeds.CreateEntry<float>("MixingStationMk2", 1f, "Mixing Station Mk2", false); stationSpeeds.CreateEntry<float>("PackagingStation", 1f, "Packaging Station", false); stationSpeeds.CreateEntry<float>("PackagingStationMk2", 1f, "Packaging Station Mk2", false); stationSpeeds.CreateEntry<float>("Pot", 1f, "Pot", false); stationSpeeds.CreateEntry<float>("MushroomBed", 1f, "Mushroom Bed", false); stationCapacities.CreateEntry<int>("DryingRack", 20, "Drying Rack", false); stationCapacities.CreateEntry<int>("MixingStation", 10, "Mixing Station", false); stationCapacities.CreateEntry<int>("MixingStationMk2", 20, "Mixing Station Mk2", false); stationCapacities.CreateEntry<int>("PackagingStation", 20, "Packaging Station", false); stationCapacities.CreateEntry<int>("PackagingStationMk2", 20, "Packaging Station Mk2", false); employeeAnimation.CreateEntry<float>("employeeWalkAcceleration", 1f, "Employee walk speed modifier", false); employeeAnimation.CreateEntry<float>("LabOvenAcceleration", 1f, "Lab Oven animation speed modifier", false); employeeAnimation.CreateEntry<float>("CauldronAcceleration", 1f, "Cauldron animation speed modifier", false); employeeAnimation.CreateEntry<float>("BrickPressAcceleration", 1f, "Brick Press animation speed modifier", false); employeeAnimation.CreateEntry<float>("ChemistryStationAcceleration", 1f, "Chemistry Station animation speed modifier", false); employeeAnimation.CreateEntry<float>("DryingRackAcceleration", 1f, "Drying Rack animation speed modifier", false); employeeAnimation.CreateEntry<float>("MixingStationAcceleration", 1f, "Mixing Station animation speed modifier", false); employeeAnimation.CreateEntry<float>("MixingStationMk2Acceleration", 1f, "Mixing Station Mk2 animation speed modifier", false); employeeAnimation.CreateEntry<float>("MushroomBedAcceleration", 1f, "Mushroom Bed animation speed modifier", false); employeeAnimation.CreateEntry<float>("PackagingStationAcceleration", 1f, "Packaging Station animation speed modifier", false); employeeAnimation.CreateEntry<float>("PackagingStationMk2Acceleration", 1f, "Packaging Station Mk2 animation speed modifier", false); employeeAnimation.CreateEntry<float>("PotAcceleration", 1f, "Pot animation speed modifier", false); employeeAnimation.CreateEntry<float>("SpawnStationAcceleration", 1f, "Spawn Station animation speed modifier", false); stackSizes.CreateEntry<int>("Agriculture", 10, "Agriculture", false); stackSizes.CreateEntry<int>("Cash", 1000, "Cash", false); stackSizes.CreateEntry<int>("Clothing", 1, "Clothing", false); stackSizes.CreateEntry<int>("Consumable", 20, "Consumable", false); stackSizes.CreateEntry<int>("Decoration", 1, "Decoration", false); stackSizes.CreateEntry<int>("Equipment", 10, "Equipment", false); stackSizes.CreateEntry<int>("Furniture", 10, "Furniture", false); stackSizes.CreateEntry<int>("Ingredient", 20, "Ingredient", false); stackSizes.CreateEntry<int>("Lighting", 10, "Lighting", false); stackSizes.CreateEntry<int>("Packaging", 20, "Packaging", false); stackSizes.CreateEntry<int>("Product", 20, "Product", false); stackSizes.CreateEntry<int>("Storage", 10, "Storage", false); stackSizes.CreateEntry<int>("Tools", 1, "Tools", false); stackOverrides.CreateEntry<int>("Acid", 10, "Acid", false); stackOverrides.CreateEntry<int>("Phosphorus", 10, "Phosphorus", false); stackOverrides.CreateEntry<int>("Low-Quality Pseudo", 10, "Low-Quality Pseudo", false); stackOverrides.CreateEntry<int>("Pseudo", 10, "Pseudo", false); stackOverrides.CreateEntry<int>("High-Quality Pseudo", 10, "High-Quality Pseudo", false); stackOverrides.CreateEntry<int>("Shotgun Shell", 10, "Shotgun Shell", false); stackOverrides.CreateEntry<int>("M1911 Magazine", 10, "M1911 Magazine", false); stackOverrides.CreateEntry<int>("Revolver Cylinder", 10, "Revolver Cylinder", false); stackOverrides.CreateEntry<int>("Spray Paint", 10, "Spray Paint", false); stackOverrides.CreateEntry<int>("Graffiti Cleaner", 10, "Graffiti Cleaner", false); stationSpeeds.SaveToFile(false); stationCapacities.SaveToFile(false); employeeAnimation.SaveToFile(false); stackSizes.SaveToFile(false); stackOverrides.SaveToFile(false); } public int GetStackLimit(ItemInstance item) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) int result = 10; if (item == null) { return 0; } if (stackOverrides.GetEntry<int>(item.Name) != null) { result = stackOverrides.GetEntry<int>(item.Name).Value; } else { EItemCategory value = ((!(item.Definition.Name == "Speed Grow")) ? item.Category : ((EItemCategory)2)); if (stackSizes.GetEntry<int>(((object)(EItemCategory)(ref value)).ToString()) != null) { result = stackSizes.GetEntry<int>(((object)(EItemCategory)(ref value)).ToString()).Value; } else { MelonLogger.Msg($"Couldn't find stack size for item {item.Name} with category {value}, assuming 10"); } } return result; } public int GetStackLimit(ItemDefinition itemDef) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) int result = 10; if (stackOverrides.GetEntry<int>(itemDef.Name) != null) { result = stackOverrides.GetEntry<int>(itemDef.Name).Value; } else { EItemCategory value = ((!(itemDef.Name == "Speed Grow")) ? itemDef.Category : ((EItemCategory)2)); if (stackSizes.GetEntry<int>(((object)(EItemCategory)(ref value)).ToString()) != null) { result = stackSizes.GetEntry<int>(((object)(EItemCategory)(ref value)).ToString()).Value; } else { MelonLogger.Msg($"Couldn't find stack size for item {itemDef.Name} with category {value}"); } } return result; } public int GetStackLimit(string itemName, EItemCategory category) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) int result = 10; if (stackOverrides.GetEntry<int>(itemName) != null) { result = stackOverrides.GetEntry<int>(itemName).Value; } else { EItemCategory value = ((!(itemName == "Speed Grow")) ? category : ((EItemCategory)2)); if (stackSizes.GetEntry<int>(((object)(EItemCategory)(ref value)).ToString()) != null) { result = stackSizes.GetEntry<int>(((object)(EItemCategory)(ref value)).ToString()).Value; } else { MelonLogger.Msg($"Couldn't find stack size for item {itemName} with category {value}"); } } return result; } public int GetStackLimit(EItemCategory category) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) int result = 10; if (stackSizes.GetEntry<int>(((object)(EItemCategory)(ref category)).ToString()) != null) { result = stackSizes.GetEntry<int>(((object)(EItemCategory)(ref category)).ToString()).Value; } else { MelonLogger.Msg($"Couldn't find stack size for category {category}"); } return result; } public int GetStationCapacity(string station) { int result = 10; if (stationCapacities.GetEntry<int>(station) != null) { result = stationCapacities.GetEntry<int>(station).Value; } else { MelonLogger.Msg("Couldn't find station capacity for " + station); } return result; } public float GetStationSpeed(string station) { float result = 1f; if (stationSpeeds.GetEntry<float>(station) != null) { result = stationSpeeds.GetEntry<float>(station).Value; } else { MelonLogger.Msg("Couldn't find station speed modifier for " + station); } return result; } public float GetStationWorkSpeed(string station) { float result = 1f; if (employeeAnimation.GetEntry<float>(station + "Acceleration") != null) { result = employeeAnimation.GetEntry<float>(station + "Acceleration").Value; } else { MelonLogger.Msg("Couldn't find employee work speed modifier for " + station); } return result; } } public class Utils { public class UnityObjectComparer : IEqualityComparer<Object> { public bool Equals(Object a, Object b) { return a.GetInstanceID() == b.GetInstanceID(); } public int GetHashCode(Object item) { return item.GetInstanceID(); } } public static ProduceMoreMod Mod; private static Assembly S1Assembly; public static Dictionary<Type, string> typeStrings = new Dictionary<Type, string> { { typeof(DryingRack), "DryingRack" }, { typeof(LabOven), "LabOven" }, { typeof(ChemistryStation), "ChemistryStation" }, { typeof(MixingStationMk2), "MixingStationMk2" }, { typeof(MixingStation), "MixingStation" }, { typeof(BrickPress), "BrickPress" }, { typeof(Cauldron), "Cauldron" }, { typeof(PackagingStationMk2), "PackagingStationMk2" }, { typeof(PackagingStation), "PackagingStation" }, { typeof(Pot), "Pot" }, { typeof(MushroomBed), "MushroomBed" }, { typeof(MushroomSpawnStation), "SpawnStation" } }; public static void Initialize(ProduceMoreMod mod) { Mod = mod; S1Assembly = AppDomain.CurrentDomain.GetAssemblies().First((Assembly a) => a.GetName().Name == "Assembly-CSharp"); } public static void LateInitialize() { Singleton<LoadManager>.Instance.onPreSceneChange.AddListener(ToUnityAction(OnPreSceneChange)); } private static void OnPreSceneChange() { Mod.StopCoroutines(); } public static Treturn GetField<Ttarget, Treturn>(string fieldName, object target) where Treturn : class { return (Treturn)GetField<Ttarget>(fieldName, target); } public static object GetField<Ttarget>(string fieldName, object target) { return AccessTools.Property(typeof(Ttarget), fieldName).GetValue(target); } public static void SetField<Ttarget>(string fieldName, object target, object value) { AccessTools.Property(typeof(Ttarget), fieldName).SetValue(target, value); } public static Treturn GetProperty<Ttarget, Treturn>(string fieldName, object target) { return (Treturn)GetProperty<Ttarget>(fieldName, target); } public static object GetProperty<Ttarget>(string fieldName, object target) { return AccessTools.Property(typeof(Ttarget), fieldName).GetValue(target); } public static void SetProperty<Ttarget>(string fieldName, object target, object value) { AccessTools.Property(typeof(Ttarget), fieldName).SetValue(target, value); } public static Treturn CallMethod<Ttarget, Treturn>(string methodName, object target) { return (Treturn)CallMethod<Ttarget>(methodName, target, Array.Empty<object>()); } public static Treturn CallMethod<Ttarget, Treturn>(string methodName, object target, object[] args) { return (Treturn)CallMethod<Ttarget>(methodName, target, args); } public static Treturn CallMethod<Ttarget, Treturn>(string methodName, Type[] argTypes, object target, object[] args) { return (Treturn)CallMethod<Ttarget>(methodName, argTypes, target, args); } public static object CallMethod<Ttarget>(string methodName, object target) { return AccessTools.Method(typeof(Ttarget), methodName, (Type[])null, (Type[])null).Invoke(target, Array.Empty<object>()); } public static object CallMethod<Ttarget>(string methodName, object target, object[] args) { return AccessTools.Method(typeof(Ttarget), methodName, (Type[])null, (Type[])null).Invoke(target, args); } public static object CallMethod<Ttarget>(string methodName, Type[] argTypes, object target, object[] args) { return AccessTools.Method(typeof(Ttarget), methodName, argTypes, (Type[])null).Invoke(target, args); } public static T CastTo<T>(Il2CppObjectBase o) where T : Il2CppObjectBase { if (typeof(T).IsAssignableFrom(GetType(o))) { return (T)Activator.CreateInstance(typeof(T), o.Pointer); } return default(T); } public static bool Is<T>(Il2CppObjectBase o) where T : Il2CppObjectBase { return typeof(T).IsAssignableFrom(GetType(o)); } public static T ToInterface<T>(Il2CppObjectBase o) where T : Il2CppObjectBase { return (T)Activator.CreateInstance(typeof(T), o.Pointer); } public static Type GetType(Il2CppObjectBase o) { if (o == null) { return null; } string fullName = Il2CppType.TypeFromPointer(o.ObjectClass, "<unknown type>").FullName; return S1Assembly.GetType("Il2Cpp" + fullName); } public static UnityAction ToUnityAction(Action action) { return DelegateSupport.ConvertDelegate<UnityAction>((Delegate)action); } public static UnityAction<T> ToUnityAction<T>(Action<T> action) { return DelegateSupport.ConvertDelegate<UnityAction<T>>((Delegate)action); } public static Predicate<T> ToPredicate<T>(Func<T, bool> func) { return DelegateSupport.ConvertDelegate<Predicate<T>>((Delegate)func); } public static void Log(string message) { ((MelonBase)Mod).LoggerInstance.Msg(message); } public static void Warn(string message) { ((MelonBase)Mod).LoggerInstance.Warning(message); } public static void PrintException(Exception e) { Warn("Exception: " + e.GetType().Name + " - " + e.Message); Warn("Source: " + e.Source); Warn(e.StackTrace ?? ""); if (e.InnerException != null) { Warn("Inner exception: " + e.InnerException.GetType().Name + " - " + e.InnerException.Message); Warn("Source: " + e.InnerException.Source); Warn(e.InnerException.StackTrace ?? ""); if (e.InnerException.InnerException != null) { Warn("Inner inner exception: " + e.InnerException.InnerException.GetType().Name + " - " + e.InnerException.InnerException.Message); Warn("Source: " + e.InnerException.InnerException.Source); Warn(e.InnerException.InnerException.StackTrace ?? ""); } } } public static bool OtherModIsLoaded(string modName) { List<MelonBase> list = new List<MelonBase>(MelonBase.RegisteredMelons); MelonBase val = list.Find((MelonBase m) => m.Info.Name == modName); return val != null; } public static object StartCoroutine(IEnumerator func) { if (func == null) { Warn("Tried to start null coroutine."); return null; } object obj = MelonCoroutines.Start(func); Mod.runningCoroutines.Add(obj); return obj; } public static void StopCoroutine(object coroutine) { if (coroutine == null) { Warn($"Tried to stop null coroutine; is there a dead entry in the list? (length {Mod.runningCoroutines.Count})"); return; } Mod.runningCoroutines.Remove(coroutine); try { MelonCoroutines.Stop(coroutine); } catch (Exception e) { PrintException(e); } } public static void AddStationCapacity(GridItem station, int capacity) { if ((Object)(object)station == (Object)null) { return; } string valueOrDefault = typeStrings.GetValueOrDefault(GetType((Il2CppObjectBase)(object)station)); if (!Mod.processedStationCapacities.Contains(station)) { if (!Mod.originalStationCapacities.ContainsKey(valueOrDefault)) { Mod.originalStationCapacities.Add(valueOrDefault, capacity); } Mod.processedStationCapacities.Add(station); } } public static void AddOriginalStationTime(GridItem station, int time) { if ((Object)(object)station == (Object)null) { return; } string valueOrDefault = typeStrings.GetValueOrDefault(GetType((Il2CppObjectBase)(object)station)); if (!Mod.processedStationTimes.Contains(station)) { if (!Mod.originalStationTimes.ContainsKey(valueOrDefault)) { Mod.originalStationTimes.Add(valueOrDefault, time); } Mod.processedStationTimes.Add(station); } } public static void AddOriginalStationTime(string stationString, int time) { if (!Mod.originalStationTimes.ContainsKey(stationString)) { Mod.originalStationTimes.TryAdd(stationString, time); } } public static void ModItemStackLimit(ItemDefinition itemDefinition) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) if (!((Object)(object)itemDefinition == (Object)null) && !Mod.processedItemDefs.Contains(itemDefinition) && itemDefinition.Name.ToLower() != "cash") { EItemCategory val = ((!(itemDefinition.Name == "Speed Grow")) ? itemDefinition.Category : ((EItemCategory)2)); if (!Mod.originalStackLimits.ContainsKey(((object)(EItemCategory)(ref val)).ToString())) { Mod.originalStackLimits[((object)(EItemCategory)(ref val)).ToString()] = itemDefinition.StackLimit; } itemDefinition.StackLimit = Mod.GetStackLimit(itemDefinition.GetDefaultInstance(1)); Mod.processedItemDefs.Add(itemDefinition); } } public static void ModRecipeTime(StationRecipe recipe, float stationSpeed) { if (!((Object)(object)recipe == (Object)null) && !Mod.processedRecipes.Contains(recipe)) { if (!Mod.originalRecipeTimes.ContainsKey(recipe)) { Mod.originalRecipeTimes[recipe] = recipe.CookTime_Mins; } int num = Mod.originalRecipeTimes[recipe]; int cookTime_Mins = Mathf.Max((int)((float)num / stationSpeed), 1); recipe.CookTime_Mins = cookTime_Mins; Mod.processedRecipes.Add(recipe); } } public static int GetStationCapacity(GridItem station) { if ((Object)(object)station == (Object)null) { return 10; } return Mod.GetStationCapacity(typeStrings[GetType((Il2CppObjectBase)(object)station)]); } public static int GetStationCapacity(string stationString) { return Mod.GetStationCapacity(stationString); } public static float GetStationSpeed(GridItem station) { if ((Object)(object)station == (Object)null) { return 1f; } return Mod.GetStationSpeed(typeStrings[GetType((Il2CppObjectBase)(object)station)]); } public static float GetStationSpeed(string stationString) { return Mod.GetStationSpeed(stationString); } public static float GetStationWorkSpeed(GridItem station) { if ((Object)(object)station == (Object)null) { return 1f; } return Mod.GetStationWorkSpeed(typeStrings[GetType((Il2CppObjectBase)(object)station)]); } public static float GetStationWorkSpeed(string stationString) { return Mod.GetStationWorkSpeed(stationString); } public static int GetOriginalStationTime(GridItem station) { int result = 10; if ((Object)(object)station != (Object)null) { string text = typeStrings[GetType((Il2CppObjectBase)(object)station)]; if (Mod.originalStationTimes.ContainsKey(text)) { result = Mod.originalStationTimes[text]; } else { Warn("Tried to get original station time for " + text + ", but there wasn't one in the index?"); } } return result; } public static int GetOriginalStationTime(string stationString) { int result = 10; if (Mod.originalStationTimes.ContainsKey(stationString)) { result = Mod.originalStationTimes[stationString]; } else { Warn("Tried to get original station time for " + stationString + ", but there wasn't one in the index?"); } return result; } } [HarmonyPatch] public class ItemCapacityPatches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] public static void StackLimitPrefix(ItemInstance __instance) { Utils.ModItemStackLimit(__instance.Definition); } [HarmonyPatch(typeof(ListingEntry), "Initialize")] [HarmonyPrefix] public static void InitializePrefix(ShopListing match) { if (match != null && (Object)(object)match.Item != (Object)null) { Utils.ModItemStackLimit((ItemDefinition)(object)match.Item); } } [HarmonyPatch(typeof(ItemSlotUI), "UpdateUI")] [HarmonyPostfix] public static void UpdateUIPostfix(ItemSlotUI __instance) { if (__instance.assignedSlot != null && __instance.assignedSlot.ItemInstance != null) { Utils.ModItemStackLimit(__instance.assignedSlot.ItemInstance.Definition); } } [HarmonyPatch(typeof(ItemSlot), "GetCapacityForItem")] [HarmonyPostfix] public static void GetCapacityForItemPostfix(ItemSlot __instance, ref int __result, ItemInstance item, bool checkPlayerFilters) { if (item != null) { Utils.ModItemStackLimit(item.Definition); } if (!__instance.DoesItemMatchHardFilters(item)) { __result = 0; } else if (checkPlayerFilters && !__instance.DoesItemMatchPlayerFilters(item)) { __result = 0; } else if (__instance.ItemInstance == null || __instance.ItemInstance.CanStackWith(item, false)) { __result = Mathf.Max(item.StackLimit - __instance.Quantity, 0); } else { __result = 0; } } [HarmonyPatch(typeof(NPCInventory), "GetCapacityForItem")] [HarmonyPrefix] public static void NPCGetCapacityForItemPrefix(NPCInventory __instance, ItemInstance item, ref int __result) { if (item != null) { Utils.ModItemStackLimit(item.Definition); } } [HarmonyPatch(typeof(NPCInventory), "GetCapacityForItem")] [HarmonyPostfix] public static void NPCGetCapacityForItemPostfix(NPCInventory __instance, ItemInstance item, ref int __result) { if (item == null) { return; } int num = 0; for (int i = 0; i < __instance.ItemSlots.Count; i++) { if (__instance.ItemSlots[i] != null && !__instance.ItemSlots[i].IsLocked && !__instance.ItemSlots[i].IsAddLocked) { if (__instance.ItemSlots[i].ItemInstance == null) { num += item.StackLimit; } else if (__instance.ItemSlots[i].ItemInstance.CanStackWith(item, true)) { num += Mathf.Max(0, item.StackLimit - __instance.ItemSlots[i].ItemInstance.Quantity); } } } __result = num; } [HarmonyPatch(typeof(NPCInventory), "CanItemFit")] [HarmonyPostfix] public static void NPCCanItemFitPostfix(NPCInventory __instance, ItemInstance item, ref bool __result) { __result = item != null && __instance.GetCapacityForItem(item) >= item.Quantity; } } [HarmonyPatch] public class RegistryPatches { [HarmonyTargetMethod] public static MethodBase TargetMethod() { return AccessTools.FirstMethod(typeof(Registry), (Func<MethodInfo, bool>)((MethodInfo method) => method.Name == "GetItem" && method.ReturnType == typeof(ItemDefinition))); } [HarmonyPatch] [HarmonyPostfix] public static void GetItemPostfix(ref ItemDefinition __result) { if ((Object)(object)__result != (Object)null) { Utils.ModItemStackLimit(__result); } } } [HarmonyPatch] public class DryingRackPatches { [HarmonyPatch(typeof(StartDryingRackBehaviour), "IsRackReady")] [HarmonyPrefix] public static void IsRackReadyPrefix(DryingRack rack, ref bool __result) { Utils.AddStationCapacity((GridItem)(object)rack, 20); rack.ItemCapacity = Utils.GetStationCapacity((GridItem)(object)rack); } [HarmonyPatch(typeof(DryingRack), "CanStartOperation")] [HarmonyPostfix] public static void CanStartOperationPostfix(DryingRack __instance, ref bool __result) { Utils.AddStationCapacity((GridItem)(object)__instance, 20); __instance.ItemCapacity = Utils.GetStationCapacity((GridItem)(object)__instance); __result = __instance.GetTotalDryingItems() < __instance.ItemCapacity && __instance.InputSlot.Quantity != 0 && !__instance.InputSlot.IsLocked && !__instance.InputSlot.IsRemovalLocked; } [HarmonyPatch(typeof(DryingOperationUI), "UpdatePosition")] [HarmonyPostfix] public static void UpdatePositionPostfix(DryingOperationUI __instance) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) DryingRack rack = Singleton<DryingRackCanvas>.Instance.Rack; if ((Object)(object)rack != (Object)null) { Utils.AddOriginalStationTime((GridItem)(object)rack, DryingRack.DRY_MINS_PER_TIER); } int dRY_MINS_PER_TIER = DryingRack.DRY_MINS_PER_TIER; float stationSpeed = Utils.GetStationSpeed("DryingRack"); float num = (float)dRY_MINS_PER_TIER / stationSpeed; float num2 = Mathf.Clamp01((float)__instance.AssignedOperation.Time / num); int num3 = Mathf.Clamp((int)num - __instance.AssignedOperation.Time, 0, (int)num); int num4 = num3 / 60; int num5 = num3 % 60; __instance.Tooltip.text = num4 + "h " + num5 + "m until next tier"; float num6 = -62.5f; float num7 = 0f - num6; __instance.Rect.anchoredPosition = new Vector2(Mathf.Lerp(num6, num7, num2), 0f); } [HarmonyPatch(typeof(DryingOperation), "GetQuality")] [HarmonyPostfix] public static void GetQualityPostfix(DryingOperation __instance, ref EQuality __result) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected I4, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected I4, but got Unknown Utils.AddOriginalStationTime("DryingRack", DryingRack.DRY_MINS_PER_TIER); int dRY_MINS_PER_TIER = DryingRack.DRY_MINS_PER_TIER; float stationSpeed = Utils.Mod.GetStationSpeed("DryingRack"); int num = (int)((float)dRY_MINS_PER_TIER / stationSpeed); if (__instance.Time >= num) { __result = (EQuality)(__instance.StartQuality + 1); } else { __result = (EQuality)(int)__instance.StartQuality; } } [HarmonyPatch(typeof(DryingRack), "MinPass")] [HarmonyPostfix] public static void MinPassPostfix(DryingRack __instance) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 int dRY_MINS_PER_TIER = DryingRack.DRY_MINS_PER_TIER; float stationSpeed = Utils.GetStationSpeed((GridItem)(object)__instance); int num = (int)((float)dRY_MINS_PER_TIER / stationSpeed); foreach (DryingOperation item in __instance.DryingOperations.ToArray()) { if (item.Time < num) { continue; } if ((int)item.StartQuality >= 3) { if (InstanceFinder.IsServer && __instance.GetOutputCapacityForOperation(item, (EQuality)4) >= item.Quantity) { __instance.TryEndOperation(__instance.DryingOperations.IndexOf(item), false, (EQuality)4, Random.Range(int.MinValue, int.MaxValue)); } } else { item.IncreaseQuality(); } } } [HarmonyPatch(typeof(StartDryingRackBehaviour), "RpcLogic___BeginAction_2166136261")] [HarmonyPrefix] public static bool Rpc_BeginActionPrefix(StartDryingRackBehaviour __instance) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown if (__instance.WorkInProgress) { return false; } if ((Object)(object)__instance.Rack == (Object)null) { return false; } Utils.SetProperty<StartDryingRackBehaviour>("WorkInProgress", __instance, true); ((Behaviour)__instance).Npc.Movement.FacePoint(__instance.Rack.uiPoint.position, 0.5f); object obj = Utils.StartCoroutine(BeginActionCoroutine(__instance)); Utils.SetField<StartDryingRackBehaviour>("workRoutine", __instance, (object)(Coroutine)obj); return false; } private static IEnumerator BeginActionCoroutine(StartDryingRackBehaviour behaviour) { yield return (object)new WaitForEndOfFrame(); float workSpeed = Utils.GetStationWorkSpeed((GridItem)(object)behaviour.Rack); float originalTimePerItem = StartDryingRackBehaviour.TIME_PER_ITEM; float waitTimePerItem = originalTimePerItem / workSpeed; int inputQuantity = behaviour.Rack.InputSlot.Quantity; int outputCapacity = behaviour.Rack.ItemCapacity - behaviour.Rack.GetTotalDryingItems(); int quantityToDry = Mathf.Min(inputQuantity, outputCapacity); float waitTime = Mathf.Max(0.1f, waitTimePerItem * (float)quantityToDry); int lastWholeSecond = 0; ((Behaviour)behaviour).Npc.Avatar.Animation.SetTrigger("GrabItem"); for (float i = 0f; i < waitTime; i += Time.deltaTime) { ((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(behaviour.Rack.uiPoint.position, 0, false); if (i - (float)lastWholeSecond >= 1f) { ((Behaviour)behaviour).Npc.Avatar.Animation.SetTrigger("GrabItem"); lastWholeSecond = (int)i; } yield return null; } ((Behaviour)behaviour).Npc.Avatar.Animation.ResetTrigger("GrabItem"); if (InstanceFinder.IsServer) { behaviour.Rack.StartOperation(); } Utils.SetProperty<StartDryingRackBehaviour>("WorkInProgress", behaviour, false); object workRoutine = Utils.GetField<StartDryingRackBehaviour>("workRoutine", behaviour); Utils.StopCoroutine(workRoutine); Utils.SetField<StartDryingRackBehaviour>("workRoutine", behaviour, null); } [HarmonyPatch(typeof(StartDryingRackBehaviour), "StopCauldron")] [HarmonyPrefix] public static void StopCauldronPrefix(StartDryingRackBehaviour __instance) { object field = Utils.GetField<StartDryingRackBehaviour>("workRoutine", __instance); if (field != null) { Utils.StopCoroutine(field); Utils.SetField<StartDryingRackBehaviour>("workRoutine", __instance, null); } Utils.SetProperty<StartDryingRackBehaviour>("WorkInProgress", __instance, false); } } [HarmonyPatch] public class LabOvenPatches { [HarmonyPatch(typeof(OvenCookOperation), "GetCookDuration")] [HarmonyPostfix] public static void GetCookDurationPostfix(OvenCookOperation __instance, ref int __result) { StorableItemDefinition ingredient = __instance.Ingredient; int cookTime = ingredient.StationItem.GetModule<CookableModule>().CookTime; float stationSpeed = Utils.Mod.GetStationSpeed("LabOven"); int num = (int)((float)cookTime / stationSpeed); __result = num; } [HarmonyPatch(typeof(OvenCookOperation), "IsReady")] [HarmonyPostfix] public static void IsReadyPostfix(OvenCookOperation __instance, ref bool __result) { __result = __instance.CookProgress >= __instance.GetCookDuration(); } [HarmonyPatch(typeof(LabOvenCanvas), "DoesOvenOutputHaveSpace")] [HarmonyPostfix] public static void DoesOvenOutputHaveSpacePostfix(LabOvenCanvas __instance, ref bool __result) { ItemInstance productItem = __instance.Oven.CurrentOperation.GetProductItem(1); int productQuantity = __instance.Oven.CurrentOperation.Cookable.ProductQuantity; int capacityForItem = __instance.Oven.OutputSlot.GetCapacityForItem(productItem, false); __result = capacityForItem >= productQuantity; } [HarmonyPatch(typeof(StartLabOvenBehaviour), "RpcLogic___StartCook_2166136261")] [HarmonyPrefix] public static bool Rpc_StartCookPrefix(StartLabOvenBehaviour __instance) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown if (Utils.GetField<StartLabOvenBehaviour>("cookRoutine", __instance) != null || (Object)(object)__instance.targetOven == (Object)null) { return false; } object obj = Utils.StartCoroutine(StartCookCoroutine(__instance)); Utils.SetField<StartLabOvenBehaviour>("cookRoutine", __instance, (object)(Coroutine)obj); return false; } private static IEnumerator StartCookCoroutine(StartLabOvenBehaviour behaviour) { float workSpeed = Utils.GetStationWorkSpeed((GridItem)(object)behaviour.targetOven); behaviour.targetOven.SetNPCUser(((NetworkBehaviour)((Behaviour)behaviour).Npc).NetworkObject); ((Behaviour)behaviour).Npc.Movement.FacePoint(((Component)behaviour.targetOven).transform.position, Mathf.Max(0.1f, 0.5f / workSpeed)); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 0.5f / workSpeed)); if (!(bool)Utils.CallMethod<StartLabOvenBehaviour>("CanCookStart", behaviour)) { Utils.CallMethod<StartLabOvenBehaviour>("StopCook", behaviour); ((Behaviour)behaviour).Deactivate_Networked((NetworkConnection)null); yield break; } behaviour.targetOven.Door.SetPosition(1f); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 0.5f / workSpeed)); behaviour.targetOven.WireTray.SetPosition(1f); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 5f / workSpeed)); behaviour.targetOven.Door.SetPosition(0f); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 1f / workSpeed)); ItemInstance itemInstance = behaviour.targetOven.IngredientSlot.ItemInstance; if (itemInstance == null) { Utils.CallMethod<StartLabOvenBehaviour>("StopCook", behaviour); ((Behaviour)behaviour).Deactivate_Networked((NetworkConnection)null); yield break; } int num = 1; StorableItemDefinition storableItemDef = Utils.CastTo<StorableItemDefinition>((Il2CppObjectBase)(object)itemInstance.Definition); CookableModule cookable = storableItemDef.StationItem.GetModule<CookableModule>(); if ((int)cookable.CookType == 1) { num = Mathf.Min(behaviour.targetOven.IngredientSlot.Quantity, LabOven.SOLID_INGREDIENT_COOK_LIMIT); } itemInstance.ChangeQuantity(-num); string productId = ((ItemDefinition)cookable.Product).ID; EQuality ingredientQuality = (EQuality)2; if (Utils.Is<QualityItemInstance>((Il2CppObjectBase)(object)itemInstance)) { ingredientQuality = Utils.CastTo<QualityItemInstance>((Il2CppObjectBase)(object)itemInstance).Quality; } behaviour.targetOven.SendCookOperation(new OvenCookOperation(itemInstance.ID, ingredientQuality, num, productId)); Utils.CallMethod<StartLabOvenBehaviour>("StopCook", behaviour); ((Behaviour)behaviour).Deactivate_Networked((NetworkConnection)null); } [HarmonyPatch(typeof(StartLabOvenBehaviour), "StopCook")] [HarmonyPrefix] public static void StopCookPrefix(StartLabOvenBehaviour __instance) { object field = Utils.GetField<StartLabOvenBehaviour>("cookRoutine", __instance); if (field != null) { Utils.StopCoroutine(field); Utils.SetField<StartLabOvenBehaviour>("cookRoutine", __instance, null); } } [HarmonyPatch(typeof(FinishLabOvenBehaviour), "RpcLogic___StartAction_2166136261")] [HarmonyPrefix] public static bool Rpc_StartFinishCookPrefix(FinishLabOvenBehaviour __instance) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown if (Utils.GetField<FinishLabOvenBehaviour>("actionRoutine", __instance) != null) { return false; } if ((Object)(object)__instance.targetOven == (Object)null) { return false; } object obj = Utils.StartCoroutine(FinishCookCoroutine(__instance)); Utils.SetField<FinishLabOvenBehaviour>("actionRoutine", __instance, (object)(Coroutine)obj); return false; } private static IEnumerator FinishCookCoroutine(FinishLabOvenBehaviour behaviour) { float stationSpeed = Utils.GetStationWorkSpeed((GridItem)(object)behaviour.targetOven); behaviour.targetOven.SetNPCUser(((NetworkBehaviour)((Behaviour)behaviour).Npc).NetworkObject); ((Behaviour)behaviour).Npc.Movement.FacePoint(((Component)behaviour.targetOven).transform.position, Mathf.Max(0.1f, 0.5f / stationSpeed)); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 0.5f / stationSpeed)); if (!(bool)Utils.CallMethod<FinishLabOvenBehaviour>("CanActionStart", behaviour)) { Utils.CallMethod<FinishLabOvenBehaviour>("StopAction", behaviour); ((Behaviour)behaviour).Deactivate_Networked((NetworkConnection)null); yield break; } ((Behaviour)behaviour).Npc.SetEquippable_Networked((NetworkConnection)null, "Avatar/Equippables/Hammer"); behaviour.targetOven.Door.SetPosition(1f); behaviour.targetOven.WireTray.SetPosition(1f); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 0.5f / stationSpeed)); behaviour.targetOven.SquareTray.SetParent(((Component)behaviour.targetOven).transform); behaviour.targetOven.RemoveTrayAnimation.Play(); yield return (object)new WaitForSeconds(0.1f); behaviour.targetOven.Door.SetPosition(0f); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 1f / stationSpeed)); ((Behaviour)behaviour).Npc.SetAnimationBool_Networked((NetworkConnection)null, "UseHammer", true); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 10f / stationSpeed)); ((Behaviour)behaviour).Npc.SetAnimationBool_Networked((NetworkConnection)null, "UseHammer", false); behaviour.targetOven.Shatter(behaviour.targetOven.CurrentOperation.Cookable.ProductQuantity, ((Component)behaviour.targetOven.CurrentOperation.Cookable.ProductShardPrefab).gameObject); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 1f / stationSpeed)); ItemInstance productItem = behaviour.targetOven.CurrentOperation.GetProductItem(behaviour.targetOven.CurrentOperation.Cookable.ProductQuantity * behaviour.targetOven.CurrentOperation.IngredientQuantity); behaviour.targetOven.OutputSlot.AddItem(productItem, false); behaviour.targetOven.SendCookOperation((OvenCookOperation)null); Utils.CallMethod<FinishLabOvenBehaviour>("StopAction", behaviour); ((Behaviour)behaviour).Deactivate_Networked((NetworkConnection)null); } [HarmonyPatch(typeof(FinishLabOvenBehaviour), "StopAction")] [HarmonyPrefix] public static void StopActionPrefix(FinishLabOvenBehaviour __instance) { object field = Utils.GetField<FinishLabOvenBehaviour>("actionRoutine", __instance); if (field != null) { Utils.StopCoroutine(field); Utils.SetField<FinishLabOvenBehaviour>("actionRoutine", __instance, null); } } } [HarmonyPatch] public class MixingStationPatches { [HarmonyPatch(typeof(MixingStation), "GetMixQuantity")] [HarmonyPostfix] public static void GetMixQuantityPostfix(MixingStation __instance, ref int __result) { Utils.AddStationCapacity((GridItem)(object)__instance, __instance.MaxMixQuantity); __instance.MaxMixQuantity = Utils.GetStationCapacity((GridItem)(object)__instance); if ((Object)(object)__instance.GetProduct() == (Object)null || (Object)(object)__instance.GetMixer() == (Object)null) { __result = 0; return; } int[] array = new int[3] { __instance.ProductSlot.Quantity, __instance.MixerSlot.Quantity, __instance.MaxMixQuantity }; __result = Mathf.Min(array); } [HarmonyPatch(typeof(MixingStation), "CanStartMix")] [HarmonyPostfix] public static void CanStartMixPostfix(MixingStation __instance, ref bool __result) { __result = __instance.GetMixQuantity() > 0 && __instance.OutputSlot.Quantity == 0; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] public static void IsMixingDonePostfix(MixingStation __instance, ref bool __result) { __result = __instance.CurrentMixOperation != null && __instance.CurrentMixTime >= __instance.GetMixTimeForCurrentOperation(); } [HarmonyPatch(typeof(MixingStation), "GetMixTimeForCurrentOperation")] [HarmonyPostfix] public static void GetMixTimePostfix(MixingStation __instance, ref int __result) { if (__instance.CurrentMixOperation != null) { float stationSpeed = Utils.GetStationSpeed((GridItem)(object)__instance); int mixTimePerItem = __instance.MixTimePerItem; int quantity = __instance.CurrentMixOperation.Quantity; float num = (float)mixTimePerItem / stationSpeed; float num2 = num * (float)quantity; __result = (int)Mathf.Max(1f, num2); } } [HarmonyPatch(typeof(StartMixingStationBehaviour), "StartCook")] [HarmonyPrefix] public static void StartCookPrefix(StartMixingStationBehaviour __instance) { if (Utils.Is<MixingStationMk2>((Il2CppObjectBase)(object)__instance.targetStation)) { Utils.AddStationCapacity((GridItem)(object)__instance.targetStation, 20); } else if (Utils.Is<MixingStation>((Il2CppObjectBase)(object)__instance.targetStation)) { Utils.AddStationCapacity((GridItem)(object)__instance.targetStation, 10); } __instance.targetStation.MaxMixQuantity = Utils.GetStationCapacity((GridItem)(object)__instance.targetStation); } [HarmonyPatch(typeof(MixingStation), "MinPass")] [HarmonyPostfix] public static void MinPassPostfix(MixingStation __instance) { if (__instance.CurrentMixOperation != null) { int mixTimeForCurrentOperation = __instance.GetMixTimeForCurrentOperation(); if (__instance.CurrentMixTime == mixTimeForCurrentOperation && InstanceFinder.IsServer) { NetworkSingleton<VariableDatabase>.Instance.SetVariableValue("Mixing_Operations_Completed", (NetworkSingleton<VariableDatabase>.Instance.GetValue<float>("Mixing_Operations_Completed") + 1f).ToString(), true); __instance.MixingDone_Networked(); } if ((Object)(object)__instance.Clock != (Object)null) { __instance.Clock.SetScreenLit(true); __instance.Clock.DisplayMinutes(Mathf.Max(mixTimeForCurrentOperation - __instance.CurrentMixTime, 0)); } } if ((Object)(object)__instance.Light != (Object)null) { if (__instance.OutputSlot.Quantity > 0) { __instance.Light.isOn = (int)Time.timeSinceLevelLoad % 2 == 0; } else if (__instance.CurrentMixOperation != null) { __instance.Light.isOn = true; } else { __instance.Light.isOn = false; } } } [HarmonyPatch(typeof(MixingStationMk2), "UpdateScreen")] [HarmonyPostfix] public static void UpdateScreenPostfix(MixingStationMk2 __instance) { int mixTimeForCurrentOperation = ((MixingStation)__instance).GetMixTimeForCurrentOperation(); ((TMP_Text)__instance.ProgressLabel).text = $"{mixTimeForCurrentOperation - ((MixingStation)__instance).CurrentMixTime} mins remaining"; } [HarmonyPatch(typeof(StartMixingStationBehaviour), "RpcLogic___StartCook_2166136261")] [HarmonyPrefix] public static bool Rpc_StartCookPrefix(StartMixingStationBehaviour __instance) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown if (Utils.GetField<StartMixingStationBehaviour>("startRoutine", __instance) != null) { return false; } if ((Object)(object)__instance.targetStation == (Object)null) { return false; } object obj = Utils.StartCoroutine(StartMixCoroutine(__instance)); Utils.SetField<StartMixingStationBehaviour>("startRoutine", __instance, (object)(Coroutine)obj); return false; } private static IEnumerator StartMixCoroutine(StartMixingStationBehaviour behaviour) { float workSpeed = Utils.GetStationWorkSpeed((GridItem)(object)behaviour.targetStation); ((Behaviour)behaviour).Npc.Movement.FacePoint(((Component)behaviour.targetStation).transform.position, Mathf.Max(0.1f, 0.5f / workSpeed)); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 0.5f / workSpeed)); if (!(bool)Utils.CallMethod<StartMixingStationBehaviour>("CanCookStart", behaviour)) { Utils.CallMethod<StartMixingStationBehaviour>("StopCook", behaviour); ((Behaviour)behaviour).Deactivate_Networked((NetworkConnection)null); yield break; } behaviour.targetStation.SetNPCUser(((NetworkBehaviour)((Behaviour)behaviour).Npc).NetworkObject); ((Behaviour)behaviour).Npc.SetAnimationBool_Networked((NetworkConnection)null, "UseChemistryStation", true); int originalMixTimePerItem = behaviour.targetStation.MixTimePerItem; float mixTimePerItem = (float)originalMixTimePerItem / workSpeed; int mixQuantity = behaviour.targetStation.GetMixQuantity(); float totalMixTime = Mathf.Max(0.1f, mixTimePerItem * (float)mixQuantity); for (float i = 0f; i < totalMixTime; i += Time.deltaTime) { ((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(behaviour.targetStation.uiPoint.position, 0, false); yield return (object)new WaitForEndOfFrame(); } QualityItemInstance product = Utils.CastTo<QualityItemInstance>((Il2CppObjectBase)(object)behaviour.targetStation.ProductSlot.ItemInstance); ItemInstance mixer = behaviour.targetStation.MixerSlot.ItemInstance; if (InstanceFinder.IsServer) { behaviour.targetStation.ProductSlot.ChangeQuantity(-mixQuantity, false); behaviour.targetStation.MixerSlot.ChangeQuantity(-mixQuantity, false); MixOperation operation = new MixOperation(((ItemInstance)product).ID, product.Quality, mixer.ID, mixQuantity); behaviour.targetStation.SendMixingOperation(operation, 0); } Utils.CallMethod<StartMixingStationBehaviour>("StopCook", behaviour); ((Behaviour)behaviour).Deactivate_Networked((NetworkConnection)null); } [HarmonyPatch(typeof(StartMixingStationBehaviour), "StopCook")] [HarmonyPrefix] public static void StopCookPrefix(StartMixingStationBehaviour __instance) { object field = Utils.GetField<StartMixingStationBehaviour>("startRoutine", __instance); if (field != null) { Utils.StopCoroutine(field); Utils.SetField<StartMixingStationBehaviour>("startRoutine", __instance, null); } } [HarmonyPatch(typeof(MixingStationUIElement), "Initialize")] [HarmonyPrefix] public static void InitializeUIPrefix(MixingStation station) { try { int stationCapacity = Utils.GetStationCapacity((GridItem)(object)station); Utils.GetProperty<MixingStation, MixingStationConfiguration>("stationConfiguration", station).StartThrehold.Configure(1f, (float)stationCapacity, true); station.MaxMixQuantity = stationCapacity; } catch (Exception e) { Utils.Warn("Exception while trying to initialize Mixing Station UI."); Utils.PrintException(e); } } } [HarmonyPatch] public class BrickPressPatches { [HarmonyPatch(typeof(BrickPressBehaviour), "RpcLogic___BeginPackaging_2166136261")] [HarmonyPrefix] public static bool Rpc_BeginPackagingPrefix(BrickPressBehaviour __instance) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown if (__instance.PackagingInProgress) { return false; } if ((Object)(object)__instance.Press == (Object)null) { return false; } Utils.SetProperty<BrickPressBehaviour>("PackagingInProgress", __instance, true); ((Behaviour)__instance).Npc.Movement.FaceDirection(__instance.Press.StandPoint.forward, 0.5f); object obj = Utils.StartCoroutine(PackagingCoroutine(__instance)); Utils.SetField<BrickPressBehaviour>("packagingRoutine", __instance, (object)(Coroutine)obj); return false; } private static IEnumerator PackagingCoroutine(BrickPressBehaviour behaviour) { Utils.AddOriginalStationTime((GridItem)(object)behaviour.Press, (int)BrickPressBehaviour.BASE_PACKAGING_TIME); yield return (object)new WaitForEndOfFrame(); ((Behaviour)behaviour).Npc.Avatar.Animation.SetBool("UsePackagingStation", true); float workSpeed = Utils.GetStationWorkSpeed((GridItem)(object)behaviour.Press); float originalDuration = Utils.GetOriginalStationTime((GridItem)(object)behaviour.Press); float employeeMultiplier = Utils.CastTo<Packager>((Il2CppObjectBase)(object)((Behaviour)behaviour).Npc).PackagingSpeedMultiplier; float duration = originalDuration / (employeeMultiplier * workSpeed); for (float i = 0f; i < duration; i += Time.deltaTime) { ((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(behaviour.Press.uiPoint.position, 0, false); yield return null; } ((Behaviour)behaviour).Npc.Avatar.Animation.SetBool("UsePackagingStation", false); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 0.2f / workSpeed)); ((Behaviour)behaviour).Npc.Avatar.Animation.SetTrigger("GrabItem"); behaviour.Press.PlayPressAnim(); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 1f / workSpeed)); ProductItemInstance product = default(ProductItemInstance); if (InstanceFinder.IsServer && behaviour.Press.HasSufficientProduct(ref product)) { behaviour.Press.CompletePress(product); } Utils.SetProperty<BrickPressBehaviour>("PackagingInProgress", behaviour, false); object workRoutine = Utils.GetField<BrickPressBehaviour>("packagingRoutine", behaviour); Utils.StopCoroutine(workRoutine); Utils.SetField<BrickPressBehaviour>("packagingRoutine", behaviour, null); } [HarmonyPatch(typeof(BrickPressBehaviour), "StopPackaging")] [HarmonyPrefix] public static void StopPackagingPrefix(BrickPressBehaviour __instance) { object field = Utils.GetField<BrickPressBehaviour>("packagingRoutine", __instance); if (field != null) { Utils.StopCoroutine(field); Utils.SetField<BrickPressBehaviour>("packagingRoutine", __instance, null); } Utils.SetField<BrickPressBehaviour>("PackagingInProgress", __instance, false); } } [HarmonyPatch] public class CauldronPatches { [HarmonyPatch(typeof(Cauldron), "StartCookOperation")] [HarmonyPrefix] public static void StartCookOperationPrefix(Cauldron __instance, ref int remainingCookTime) { Utils.AddOriginalStationTime((GridItem)(object)__instance, 360); int originalStationTime = Utils.GetOriginalStationTime((GridItem)(object)__instance); float stationSpeed = Utils.GetStationSpeed((GridItem)(object)__instance); int num2 = (__instance.CookTime = (int)Mathf.Max((float)originalStationTime / stationSpeed, 1f)); remainingCookTime = num2; } [HarmonyPatch(typeof(Cauldron), "HasOutputSpace")] [HarmonyPostfix] public static void HasOutputSpacePostfix(Cauldron __instance, ref bool __result) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) QualityItemInstance val = Utils.CastTo<QualityItemInstance>((Il2CppObjectBase)(object)((ItemDefinition)__instance.CocaineBaseDefinition).GetDefaultInstance(1)); val.Quality = __instance.InputQuality; __result = __instance.OutputSlot.GetCapacityForItem((ItemInstance)(object)val, false) >= 10; } [HarmonyPatch(typeof(Cauldron), "GetState")] [HarmonyPostfix] public static void GetStatePostfix(Cauldron __instance, ref EState __result) { if ((bool)Utils.GetProperty<Cauldron>("isCooking", __instance)) { __result = (EState)2; } else if (!__instance.HasIngredients()) { __result = (EState)0; } else if (!__instance.HasOutputSpace()) { __result = (EState)3; } else { __result = (EState)1; } } [HarmonyPatch(typeof(StartCauldronBehaviour), "RpcLogic___BeginCauldron_2166136261")] [HarmonyPrefix] public static bool Rpc_BeginCauldronPrefix(StartCauldronBehaviour __instance) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown if (__instance.WorkInProgress) { return false; } if ((Object)(object)__instance.Station == (Object)null) { return false; } Utils.SetProperty<StartCauldronBehaviour>("WorkInProgress", __instance, true); ((Behaviour)__instance).Npc.Movement.FaceDirection(__instance.Station.StandPoint.forward, 0.5f); object obj = Utils.StartCoroutine(BeginCauldronCoroutine(__instance)); Utils.SetField<StartCauldronBehaviour>("workRoutine", __instance, (object)(Coroutine)obj); return false; } private static IEnumerator BeginCauldronCoroutine(StartCauldronBehaviour behaviour) { yield return (object)new WaitForEndOfFrame(); ((Behaviour)behaviour).Npc.Avatar.Animation.SetBool("UseChemistryStation", true); Utils.GetStationWorkSpeed((GridItem)(object)behaviour.Station); float originalWorkTime = StartCauldronBehaviour.START_CAULDRON_TIME; float workSpeed = Utils.GetStationWorkSpeed((GridItem)(object)behaviour.Station); float workTime = Mathf.Max(0.1f, originalWorkTime / workSpeed); for (float i = 0f; i < workTime; i += Time.deltaTime) { ((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(behaviour.Station.LinkOrigin.position, 0, false); yield return null; } ((Behaviour)behaviour).Npc.Avatar.Animation.SetBool("UseChemistryStation", false); if (InstanceFinder.IsServer) { EQuality quality = behaviour.Station.RemoveIngredients(); behaviour.Station.StartCookOperation((NetworkConnection)null, behaviour.Station.CookTime, quality); } Utils.SetProperty<StartCauldronBehaviour>("WorkInProgress", behaviour, false); object workRoutine = Utils.GetField<StartCauldronBehaviour>("workRoutine", behaviour); Utils.StopCoroutine(workRoutine); Utils.SetField<StartCauldronBehaviour>("workRoutine", behaviour, null); } [HarmonyPatch(typeof(StartCauldronBehaviour), "StopCauldron")] [HarmonyPrefix] public static void StopCauldronPrefix(StartCauldronBehaviour __instance) { object field = Utils.GetField<StartCauldronBehaviour>("workRoutine", __instance); if (field != null) { Utils.StopCoroutine(field); Utils.SetField<StartCauldronBehaviour>("workRoutine", __instance, null); } } } [HarmonyPatch] public class PackagingStationPatches { [HarmonyPatch(typeof(PackagingStationBehaviour), "RpcLogic___BeginPackaging_2166136261")] [HarmonyPrefix] public static bool RpcLogic_BeginPackagingPrefix(PackagingStationBehaviour __instance) { //IL_0049: 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_0076: Expected O, but got Unknown if (__instance.PackagingInProgress || (Object)(object)__instance.Station == (Object)null) { return false; } Utils.SetProperty<PackagingStationBehaviour>("PackagingInProgress", __instance, true); ((Behaviour)__instance).Npc.Movement.FaceDirection(__instance.Station.StandPoint.forward, 0.5f); object obj = Utils.StartCoroutine(BeginPackagingCoroutine(__instance)); Utils.SetField<PackagingStationBehaviour>("packagingRoutine", __instance, (object)(Coroutine)obj); return false; } private static IEnumerator BeginPackagingCoroutine(PackagingStationBehaviour behaviour) { yield return (object)new WaitForEndOfFrame(); ((Behaviour)behaviour).Npc.Avatar.Animation.SetBool("UsePackagingStation", true); ProductItemInstance packagedInstance = Utils.CastTo<ProductItemInstance>((Il2CppObjectBase)(object)behaviour.Station.ProductSlot.ItemInstance.GetCopy(-1)); PackagingDefinition packagingDefinition = Utils.CastTo<PackagingDefinition>((Il2CppObjectBase)(object)behaviour.Station.PackagingSlot.ItemInstance.Definition); packagedInstance.SetPackaging(packagingDefinition); float workSpeed = Utils.GetStationWorkSpeed((GridItem)(object)behaviour.Station); int outputSpace = behaviour.Station.OutputSlot.GetCapacityForItem((ItemInstance)(object)packagedInstance, false); int productPerPackage = packagingDefinition.Quantity; int productQuantity = behaviour.Station.ProductSlot.Quantity; int packagingQuantity = behaviour.Station.PackagingSlot.Quantity; int[] nums = new int[3] { packagingQuantity, productQuantity / productPerPackage, outputSpace }; int numPackages = Mathf.Min(nums); int numBatchPackages = numPackages - 1; if (numPackages > 0) { float basePackagingTime = PackagingStationBehaviour.BASE_PACKAGING_TIME; float employeeMultiplier = Utils.CastTo<Packager>((Il2CppObjectBase)(object)((Behaviour)behaviour).Npc).PackagingSpeedMultiplier; float stationMultiplier = behaviour.Station.PackagerEmployeeSpeedMultiplier; float packageTime = Mathf.Max(0.1f, (float)numPackages * basePackagingTime / (stationMultiplier * employeeMultiplier * workSpeed)); for (float i = 0f; i < packageTime; i += Time.deltaTime) { ((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(behaviour.Station.Container.position, 0, false); yield return null; } if (InstanceFinder.IsServer) { if (numBatchPackages > 0) { float value = NetworkSingleton<VariableDatabase>.Instance.GetValue<float>("PackagedProductCount"); NetworkSingleton<VariableDatabase>.Instance.SetVariableValue("PackagedProductCount", (value + (float)(numBatchPackages * productPerPackage)).ToString(), true); if (behaviour.Station.OutputSlot.ItemInstance == null) { behaviour.Station.OutputSlot.SetStoredItem((ItemInstance)(object)packagedInstance, false); behaviour.Station.OutputSlot.SetQuantity(numBatchPackages, false); } else { behaviour.Station.OutputSlot.ChangeQuantity(numBatchPackages, false); } behaviour.Station.PackagingSlot.ChangeQuantity(-numBatchPackages, false); behaviour.Station.ProductSlot.ChangeQuantity(-numBatchPackages * productPerPackage, false); } behaviour.Station.PackSingleInstance(); } } ((Behaviour)behaviour).Npc.Avatar.Animation.SetBool("UsePackagingStation", false); Utils.SetProperty<PackagingStationBehaviour>("PackagingInProgress", behaviour, false); object workRoutine = Utils.GetField<PackagingStationBehaviour>("packagingRoutine", behaviour); Utils.StopCoroutine(workRoutine); Utils.SetField<PackagingStationBehaviour>("packagingRoutine", behaviour, null); } [HarmonyPatch(typeof(PackagingStationBehaviour), "StopPackaging")] [HarmonyPrefix] public static void StopPackagingPrefix(PackagingStationBehaviour __instance) { object field = Utils.GetField<PackagingStationBehaviour>("packagingRoutine", __instance); if (field != null) { Utils.StopCoroutine(field); Utils.SetField<PackagingStationBehaviour>("packagingRoutine", __instance, null); } } } [HarmonyPatch] public class GrowablePatches { [HarmonyPatch(typeof(Plant), "MinPass")] [HarmonyPrefix] public static bool MinPassPrefix(Plant __instance, int mins) { if (NetworkSingleton<TimeManager>.Instance.IsEndOfDay && !Utils.Mod.plantsAlwaysGrowPresent) { return false; } float num = 1f / ((float)__instance.GrowthTime * 60f) * (float)mins; num *= ((GrowContainer)__instance.Pot).GetTemperatureGrowthMultiplier(); num *= GetAverageLightExposure((GrowContainer)(object)__instance.Pot, out var growSpeedMultiplier); num *= __instance.Pot.GrowSpeedMultiplier; num *= growSpeedMultiplier; if (GameManager.IS_TUTORIAL) { num *= 0.3f; } if (((GrowContainer)__instance.Pot).NormalizedMoistureAmount <= 0f) { num *= 0f; } float stationSpeed = Utils.Mod.GetStationSpeed("Pot"); float normalizedGrowthProgress = __instance.NormalizedGrowthProgress; float normalizedGrowthProgress2 = Mathf.Clamp(normalizedGrowthProgress + num * stationSpeed, 0f, 1.1f); __instance.SetNormalizedGrowthProgress(normalizedGrowthProgress2); return false; } private static float GetAverageLightExposure(GrowContainer container, out float growSpeedMultiplier) { growSpeedMultiplier = 1f; UsableLightSource field = Utils.GetField<GrowContainer, UsableLightSource>("_lightSourceOverride", container); if ((Object)(object)field != (Object)null) { return field.GrowSpeedMultiplier; } float num = 0f; float num2 = default(float); for (int i = 0; i < ((GridItem)container).CoordinatePairs.Count; i++) { num += ((GridItem)container).OwnerGrid.GetTile(((GridItem)container).CoordinatePairs[i].coord2).LightExposureNode.GetTotalExposure(ref num2); growSpeedMultiplier += num2; } growSpeedMultiplier /= ((GridItem)container).CoordinatePairs.Count; return num / (float)((GridItem)container).CoordinatePairs.Count; } [HarmonyPatch(typeof(ShroomColony), "OnMinPass")] [HarmonyPrefix] public static bool OnMinPassPostfix(ShroomColony __instance) { if (NetworkSingleton<TimeManager>.Instance.IsEndOfDay && !Utils.Mod.plantsAlwaysGrowPresent) { return false; } float stationSpeed = Utils.Mod.GetStationSpeed("MushroomBed"); if (Mathf.Approximately(stationSpeed, 0f)) { return false; } float num = (float)Utils.CallMethod<ShroomColony>("GetCurrentGrowthRate", __instance); int num2 = (int)Utils.GetField<ShroomColony>("_growTime", __instance); float num3 = (float)num2 / stationSpeed; float num4 = Mathf.Clamp01(num / (num3 * 60f)); float num5 = Mathf.Clamp(__instance.GrowthProgress + num4, 0f, 1.1f) - __instance.GrowthProgress; Utils.CallMethod<ShroomColony>("ChangeGrowthPercentage", __instance, new object[1] { num5 }); return false; } } [HarmonyPatch] public class SpawnStationPatches { [HarmonyPatch(typeof(UseSpawnStationBehaviour), "RpcLogic___BeginWork_2166136261")] [HarmonyPrefix] public static bool RpcLogicBeginWorkPrefix(UseSpawnStationBehaviour __instance) { if ((bool)Utils.GetField<UseSpawnStationBehaviour>("_currentlyUsingStation", __instance)) { return false; } if (!__instance.IsStationReady(__instance.Station)) { return false; } Utils.SetField<UseSpawnStationBehaviour>("_currentlyUsingStation", __instance, true); if (InstanceFinder.IsServer) { __instance.Station.SetNPCUser(((NetworkBehaviour)((Behaviour)__instance).Npc).NetworkObject); } object value = Utils.StartCoroutine(SpawnStationCoroutine(__instance)); Utils.SetField<UseSpawnStationBehaviour>("_workRoutine", __instance, value); return false; } public static IEnumerator SpawnStationCoroutine(UseSpawnStationBehaviour behaviour) { float originalDuration = (float)Utils.GetField<UseSpawnStationBehaviour>("TaskDuration", behaviour); float workSpeed = Utils.GetStationWorkSpeed((GridItem)(object)behaviour.Station); float progress = 0f; float duration = Mathf.Max(0.1f, originalDuration / workSpeed); ((Behaviour)behaviour).Npc.SetAnimationBool("UsePackagingStation", true); while (progress < duration) { progress += Time.deltaTime; ((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(behaviour.Station.UIPoint.position, 0, true); yield return null; } if (InstanceFinder.IsServer && (Object)(object)behaviour.Station != (Object)null && behaviour.Station.DoesStationContainRequiredItems() && behaviour.Station.DoesStationHaveOutputSpace()) { SporeSyringeDefinition sporeSyringeDefinition = Utils.CastTo<SporeSyringeDefinition>((Il2CppObjectBase)(object)behaviour.Station.SyringeSlot.ItemInstance.Definition); behaviour.Station.SyringeSlot.ChangeQuantity(-1, false); behaviour.Station.GrainBagSlot.ChangeQuantity(-1, false); behaviour.Station.OutputSlot.AddItem(((ItemDefinition)sporeSyringeDefinition.SpawnDefinition).GetDefaultInstance(1), false); } Utils.CallMethod<UseSpawnStationBehaviour>("StopWork", behaviour); ((Behaviour)behaviour).Disable_Networked((NetworkConnection)null); } [HarmonyPatch(typeof(UseSpawnStationBehaviour), "StopWork")] [HarmonyPrefix] public static void StopWorkPrefix(UseSpawnStationBehaviour __instance) { object field = Utils.GetField<UseSpawnStationBehaviour>("_workRoutine", __instance); Utils.StopCoroutine(field); Utils.SetField<UseSpawnStationBehaviour>("_workRoutine", __instance, null); } } [HarmonyPatch] public class GrowContainerPatches { private enum EState { Idle, Walking, GrabbingSupplies, PerformingAction } private static Dictionary<Type, float> behaviourDurations = new Dictionary<Type, float> { { typeof(AddSoilToGrowContainerBehaviour), 15f }, { typeof(ApplyAdditiveToGrowContainerBehaviour), 10f }, { typeof(HarvestPotBehaviour), 10f }, { typeof(SowSeedInPotBehaviour), 10f }, { typeof(WaterPotBehaviour), 10f }, { typeof(ApplySpawnToMushroomBedBehaviour), 15f }, { typeof(HarvestMushroomBedBehaviour), 10f }, { typeof(MistMushroomBedBehaviour), 10f } }; private static List<Type> harvestBehaviours = new List<Type> { typeof(HarvestPotBehaviour), typeof(HarvestMushroomBedBehaviour) }; private static void PerformAction(GrowContainerBehaviour __instance) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown if (!__instance.AreTaskConditionsMetForContainer(Utils.GetProperty<GrowContainerBehaviour, GrowContainer>("_growContainer", __instance))) { ((Behaviour)__instance).Disable_Networked((NetworkConnection)null); return; } Utils.SetProperty<GrowContainerBehaviour>("_currentState", __instance, 3); object obj = Utils.StartCoroutine(PerformActionCoroutine(__instance)); Utils.SetField<GrowContainerBehaviour>("_performActionRoutine", __instance, (object)(Coroutine)obj); } private static float GetActionDuration(GrowContainerBehaviour behaviour) { Type type = Utils.GetType((Il2CppObjectBase)(object)behaviour); if (harvestBehaviours.Contains(type)) { return Botanist.IndividualHarvestTime * (float)GetQuantityToHarvest(behaviour); } if (behaviourDurations.ContainsKey(type)) { return behaviourDurations[type]; } Utils.Warn($"Couldn't find action duration for behaviour \"{((Object)behaviour).name}\" ({type.Name})"); return 10f; } private static int GetQuantityToHarvest(GrowContainerBehaviour behaviour) { if (Utils.Is<HarvestPotBehaviour>((Il2CppObjectBase)(object)behaviour)) { HarvestPotBehaviour target = Utils.CastTo<HarvestPotBehaviour>((Il2CppObjectBase)(object)behaviour); return (int)Utils.CallMethod<HarvestPotBehaviour>("GetQuantityToHarvest", target); } if (Utils.Is<HarvestMushroomBedBehaviour>((Il2CppObjectBase)(object)behaviour)) { HarvestMushroomBedBehaviour target2 = Utils.CastTo<HarvestMushroomBedBehaviour>((Il2CppObjectBase)(object)behaviour); return (int)Utils.CallMethod<HarvestMushroomBedBehaviour>("GetQuantityToHarvest", target2); } Utils.Warn("Couldn't get quantity to harvest from behaviour " + Utils.GetType((Il2CppObjectBase)(object)behaviour).Name); return 0; } private static IEnumerator PerformActionCoroutine(GrowContainerBehaviour behaviour) { Utils.CallMethod<GrowContainerBehaviour>("OnStartPerformAction", behaviour); GrowContainer growContainer = Utils.GetProperty<GrowContainerBehaviour, GrowContainer>("_growContainer", behaviour); float workSpeed = Utils.GetStationWorkSpeed((GridItem)(object)growContainer); float waitTime = GetActionDuration(behaviour) / workSpeed; Vector3 targetPosition = (Vector3)Utils.CallMethod<GrowContainerBehaviour>("GetGrowContainerLookPoint", behaviour); for (float i = 0f; i < waitTime; i += Time.deltaTime) { ((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(targetPosition, 0, false); yield return null; } if (!behaviour.AreTaskConditionsMetForContainer(growContainer)) { ((Behaviour)behaviour).Disable_Networked((NetworkConnection)null); yield break; } Utils.CallMethod<GrowContainerBehaviour>("OnStopPerformAction", behaviour); object[] args = new object[2] { growContainer, null }; bool taskRequiresItem = (bool)Utils.CallMethod<GrowContainerBehaviour>("DoesTaskRequireItem", behaviour, args); Il2CppStringArray suitableItemIDs = (Il2CppStringArray)args[1]; ItemSlot itemSlot = null; if (taskRequiresItem) { Botanist botanist = Utils.GetProperty<GrowContainerBehaviour, Botanist>("_botanist", behaviour); IItemSlotOwner slotOwner = Utils.ToInterface<IItemSlotOwner>((Il2CppObjectBase)(object)((NPC)botanist).Inventory); itemSlot = Utils.CallMethod<GrowContainerBehaviour, ItemSlot>("GetItemSlotContainingRequiredItem", behaviour, new object[2] { slotOwner, suitableItemIDs }); } ItemInstance usedItem = ((itemSlot != null) ? itemSlot.ItemInstance.GetCopy(1) : null); if ((bool)Utils.CallMethod<GrowContainerBehaviour>("CheckSuccess", behaviour, new object[1] { usedItem })) { Utils.CallMethod<GrowContainerBehaviour>("OnActionSuccess", behaviour, new object[1] { usedItem }); if (itemSlot != null && itemSlot.Quantity > 0) { itemSlot.ChangeQuantity(-1, false); } TrashItem trashPrefab = Utils.CallMethod<GrowContainerBehaviour, TrashItem>("GetTrashPrefab", behaviour, new object[1] { usedItem }); if ((Object)(object)trashPrefab != (Object)null) { NetworkSingleton<TrashManager>.Instance.CreateTrashItem(trashPrefab.ID, ((Component)((Behaviour)behaviour).Npc).transform.position + Vector3.up * 0.3f, Random.rotation, default(Vector3), "", false); } } object workRoutine = Utils.GetField<GrowContainerBehaviour>("_performActionRoutine", behaviour); Utils.StopCoroutine(workRoutine); Utils.SetField<GrowContainerBehaviour>("_performActionRoutine", behaviour, null); ((Behaviour)behaviour).Disable_Networked((NetworkConnection)null); } [HarmonyPatch(typeof(GrowContainerBehaviour), "StopAllRoutines")] [HarmonyPrefix] public static void StopAllRoutinesPrefix(GrowContainerBehaviour __instance) { object field = Utils.GetField<GrowContainerBehaviour>("_performActionRoutine", __instance); if (field != null) { Utils.CallMethod<GrowContainerBehaviour>("OnStopPerformAction", __instance); Utils.StopCoroutine(field); Utils.SetField<GrowContainerBehaviour>("_performActionRoutine", __instance, null); } } [HarmonyPatch(typeof(GrowContainerBehaviour), "OnActiveTick")] [HarmonyPrefix] public static bool OnActiveTickPrefix(GrowContainerBehaviour __instance) { if (!InstanceFinder.IsServer) { return false; } int num = (int)Utils.GetProperty<GrowContainerBehaviour>("_currentState", __instance); GrowContainer property = Utils.GetProperty<GrowContainerBehaviour, GrowContainer>("_growContainer", __instance); if (num == 0) { if ((Object)(object)property == (Object)null) { ((Behaviour)__instance).Disable_Networked((NetworkConnection)null); return false; } if ((bool)Utils.CallMethod<GrowContainerBehaviour>("IsRequiredItemInInventory", __instance, new object[1] { property })) { if ((bool)Utils.CallMethod<GrowContainerBehaviour>("IsAtGrowContainer", __instance)) { PerformAction(__instance); return false; } ITransitEntity val = Utils.ToInterface<ITransitEntity>((Il2CppObjectBase)(object)property); Utils.CallMethod<GrowContainerBehaviour>("WalkTo", __instance, new object[1] { val }); return false; } if ((bool)Utils.CallMethod<GrowContainerBehaviour>("DoSuppliesContainRequiredItem", __instance, new object[1] { property })) { if ((bool)Utils.CallMethod<GrowContainerBehaviour>("IsAtSupplies", __instance)) { Utils.CallMethod<GrowContainerBehaviour>("GrabRequiredItemFromSupplies", __instance); return false; } Botanist property2 = Utils.GetProperty<GrowContainerBehaviour, Botanist>("_botanist", __instance); Utils.CallMethod<GrowContainerBehaviour>("WalkTo", __instance, new object[1] { property2.GetSuppliesAsTransitEntity() }); return false; } ((Behaviour)__instance).Disable_Networked((NetworkConnection)null); } return false; } } [HarmonyPatch] public class ChemistryStationPatches { [HarmonyPatch(typeof(ChemistryStationCanvas), "Open")] [HarmonyPostfix] public static void CanvasOpenPostfix(ChemistryStationCanvas __instance, ChemistryStation station) { if (!((Object)(object)station != (Object)null)) { return; } float stationSpeed = Utils.GetStationSpeed((GridItem)(object)station); Enumerator<StationRecipe> enumerator = __instance.Recipes.GetEnumerator(); while (enumerator.MoveNext()) { StationRecipe current = enumerator.Current; Utils.ModRecipeTime(current, stationSpeed); } List<StationRecipeEntry> property = Utils.GetProperty<ChemistryStationCanvas, List<StationRecipeEntry>>("recipeEntries", __instance); Enumerator<StationRecipeEntry> enumerator2 = property.GetEnumerator(); while (enumerator2.MoveNext()) { StationRecipeEntry current2 = enumerator2.Current; Utils.ModRecipeTime(current2.Recipe, stationSpeed); int value = current2.Recipe.CookTime_Mins / 60; int num = current2.Recipe.CookTime_Mins % 60; ((TMP_Text)current2.CookingTimeLabel).text = $"{value}h"; if (num > 0) { TextMeshProUGUI cookingTimeLabel = current2.CookingTimeLabel; ((TMP_Text)cookingTimeLabel).text = ((TMP_Text)cookingTimeLabel).text + $" {num}m"; } } } [HarmonyPatch(typeof(StationRecipeEntry), "AssignRecipe")] [HarmonyPrefix] public static void AssignRecipePrefix(StationRecipeEntry __instance, StationRecipe recipe) { float stationSpeed = Utils.GetStationSpeed("ChemistryStation"); Utils.ModRecipeTime(recipe, stationSpeed); } [HarmonyPatch(typeof(StartChemistryStationBehaviour), "RpcLogic___StartCook_2166136261")] [HarmonyPrefix] public static bool Rpc_StartCookPrefix(StartChemistryStationBehaviour __instance) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown float stationSpeed = Utils.GetStationSpeed((GridItem)(object)__instance.targetStation); StationRecipe selectedRecipe = Utils.GetProperty<ChemistryStation, ChemistryStationConfiguration>("stationConfiguration", __instance.targetStation).Recipe.SelectedRecipe; Utils.ModRecipeTime(selectedRecipe, stationSpeed); if (Utils.GetField<StartChemistryStationBehaviour>("cookRoutine", __instance) != null) { return false; } if ((Object)(object)__instance.targetStation == (Object)null) { return false; } object obj = Utils.StartCoroutine(StartCookRoutine(__instance)); Utils.SetField<StartChemistryStationBehaviour>("cookRoutine", __instance, (object)(Coroutine)obj); return false; } private static IEnumerator StartCookRoutine(StartChemistryStationBehaviour behaviour) { float workSpeed = Utils.GetStationWorkSpeed((GridItem)(object)behaviour.targetStation); ((Behaviour)behaviour).Npc.Movement.FacePoint(((Component)behaviour.targetStation).transform.position, Mathf.Max(0.1f, 0.5f / workSpeed)); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 0.5f / workSpeed)); ((Behaviour)behaviour).Npc.SetAnimationBool_Networked((NetworkConnection)null, "UseChemistryStation", true); if (!(bool)Utils.CallMethod<StartChemistryStationBehaviour>("CanCookStart", behaviour)) { Utils.CallMethod<StartChemistryStationBehaviour>("StopCook", behaviour); ((Behaviour)behaviour).Deactivate_Networked((NetworkConnection)null); yield break; } behaviour.targetStation.SetNPCUser(((NetworkBehaviour)((Behaviour)behaviour).Npc).NetworkObject); Utils.CallMethod<StartChemistryStationBehaviour>("SetupBeaker", behaviour); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 1f / workSpeed)); StationRecipe recipe = Utils.GetProperty<ChemistryStation, ChemistryStationConfiguration>("stationConfiguration", behaviour.targetStation).Recipe.SelectedRecipe; float stationSpeed = Utils.GetStationSpeed((GridItem)(object)behaviour.targetStation); Utils.ModRecipeTime(recipe, stationSpeed); Beaker beaker = Utils.GetField<StartChemistryStationBehaviour, Beaker>("beaker", behaviour); Utils.CallMethod<StartChemistryStationBehaviour>("FillBeaker", behaviour, new object[2] { recipe, beaker }); yield return (object)new WaitForSeconds(Mathf.Max(0.1f, 20f / workSpeed)); List<ItemInstance> list = new List<ItemInstance>(); for (int i = 0; i < recipe.Ingredients.Count; i++) { Enumerator<ItemDefinition> enumerator = recipe.Ingredients[i].Items.GetEnumerator(); while (enumerator.MoveNext()) { ItemDefinition itemDefinition = enumerator.Current; StorableItemDefinition storableIngredientDef = Utils.CastTo<StorableItemDefinition>((Il2CppObjectBase)(object)itemDefinition); for (int j = 0; j < ((Il2CppArrayBase<ItemSlot>)(object)behaviour.targetStation.IngredientSlots).Length; j++) { if (((Il2CppArrayBase<ItemSlot>)(object)behaviour.targetStation.IngredientSlots)[j].ItemInstance != null && ((Il2CppArrayBase<ItemSlot>)(object)behaviour.targetStation.IngredientSlots)[j].ItemInstance.Definition.ID == ((ItemDefinition)storableIngredientDef).ID) { list.Add(((Il2CppArrayBase<ItemSlot>)(object)behaviour.targetStation.IngredientSlots)[j].ItemInstance.GetCopy(recipe.Ingredients[i].Quantity)); ((Il2CppArrayBase<ItemSlot>)(object)behaviour.targetStation.IngredientSlots)[j].ChangeQuantity(-recipe.Ingredients[i].Quantity, false); break; } } } } EQuality productQuality = recipe.CalculateQuality(list); behaviour.targetStation.SendCookOperation(new ChemistryCookOperation(recipe, productQuality, beaker.Container.LiquidColor, beaker.Fillable.LiquidContainer.CurrentLiquidLevel, 0)); ((StationItem)beaker).Destroy(); Utils.SetField<StartChemistryStationBehaviour>("beaker", behaviour, null); Utils.CallMethod<StartChemistryStationBehaviour>("StopCook", behaviour); ((Behaviour)behaviour).Deactivate_Networked((NetworkConnection)null); } [HarmonyPatch(typeof(StartChemistryStationBehaviour), "StopCook")] [HarmonyPrefix] public static void StopCookPrefix(StartChemistryStationBehaviour __instance) { object field = Utils.GetField<StartChemistryStationBehaviour>("cookRoutine", __instance); if (field != null) { Utils.StopCoroutine(field); Utils.SetField<StartChemistryStationBehaviour>("cookRoutine", __instance, null); } } [HarmonyPatch(typeof(Chemist), "GetChemistryStationsReadyToStart")] [HarmonyPostfix] public static void GetChemistryStationsReadyToStartPostfix(Chemist __instance, ref List<ChemistryStation> __result) { List<ChemistryStation> val = __result.FindAll(Utils.ToPredicate(delegate(ChemistryStation station) { StationRecipe selectedRecipe = Utils.GetProperty<ChemistryStation, ChemistryStationConfiguration>("stationConfiguration", station).Recipe.SelectedRecipe; return (bool)Utils.CallMethod<ChemistryStation>("DoesOutputHaveSpace", station, new object[1] { selectedRecipe }); })); __result = val; } [HarmonyPatch(typeof(StartChemistryStationBehaviour), "CanCookStart")] [HarmonyPostfix] public static void CanCookStartPostfix(StartChemistryStationBehaviour __instance, ref bool __result) { StationRecipe selectedRecipe = Utils.GetProperty<ChemistryStation, ChemistryStationConfiguration>("stationConfiguration", __instance.targetStation).Recipe.SelectedRecipe; __result = __result && (bool)Utils.CallMethod<ChemistryStation>("DoesOutputHaveSpace", __instance.targetStation, new object[1] { selectedRecipe }); } } [HarmonyPatch] public class CashPatches { [HarmonyPatch(typeof(ItemUIManager), "UpdateCashDragAmount")] [HarmonyPrefix] public static bool UpdateCashDragAmountPrefix(ItemUIManager __instance, CashInstance instance) { int stackLimit = Utils.Mod.GetStackLimit((EItemCategory)6); float[] array = new float[3] { 50f, 10f, 1f }; float[] array2 = new float[3] { 100f, 10f, 1f }; float num = 0f; if (GameInput.MouseScrollDelta > 0f) { for (int i = 0; i < array.Length; i++) { if (__instance.draggedCashAmount >= array2[i]) { num = array[i]; break; } } } else if (GameInput.MouseScrollDelta < 0f) { for (int j = 0; j < array.Length; j++) { if (__instance.draggedCashAmount > array2[j]) { num = 0f - array[j]; break; } } } if (num == 0f) { return false; } __instance.draggedCashAmount = Mathf.Clamp(__instance.draggedCashAmount + num, 1f, Mathf.Min(instance.Balance, (float)stackLimit)); return false; } [HarmonyPatch(typeof(ItemUIManager), "StartDragCash")] [HarmonyPrefix] public static bool StartDragCashPrefix(ItemUIManager __instance) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) int stackLimit = Utils.Mod.GetStackLimit((EItemCategory)6); CashInstance val = Utils.CastTo<CashInstance>((Il2CppObjectBase)(object)__instance.draggedSlot.assignedSlot.ItemInstance); __instance.draggedCashAmount = Mathf.Min(val.Balance, (float)stackLimit); __instance.draggedAmount = 1; if (GameInput.GetButtonDown((ButtonCode)1)) { __instance.draggedAmount = 1; __instance.draggedCashAmount = Mathf.Min(val.Balance, 100f); __instance.mouseOffset += new Vector2(-10f, -15f); __instance.customDragAmount = true; } if (__instance.draggedCashAmount <= 0f) { __instance.draggedSlot = null; return false; } if (GameInput.GetButton((ButtonCode)23) && __instance.QuickMoveEnabled) { List<ItemSlot> quickMoveSlots = __instance.GetQuickMoveSlots(__instance.draggedSlot.assignedSlot); if (quickMoveSlots.Count > 0) { Debug.Log(Object.op_Implicit("Quick-moving " + __instance.draggedAmount + " items...")); float draggedCashAmount = __instance.draggedCashAmount; float num = 0f; for (int i = 0; i < quickMoveSlots.Count; i++) { if (!(num < (float)__instance.draggedAmount)) { break; } ItemSlot val2 = quickMoveSlots[i]; if (val2.ItemInstance != null) { CashInstance val3 = Utils.CastTo<CashInstance>((Il2CppObjectBase)(object)val2.ItemInstance); if (val3 != null) { float num2 = ((!Utils.Is<CashSlot>((Il2CppObjectBase)(object)val2)) ? Mathf.Min(draggedCashAmount, (float)stackLimit - val3.Balance) : Mathf.Min(draggedCashAmount, float.MaxValue - val3.Balance)); val3.ChangeBalance(num2); val2.ReplicateStoredInstance(); num += num2; } } else { CashInstance val4 = Utils.CastTo<CashInstance>((Il2CppObjectBase)(object)Registry.GetItem("cash").GetDefaultInstance(1)); val4.SetBalance(__instance.draggedCashAmount, false); val2.SetStoredItem((ItemInstance)(object)val4, false); num += __instance.draggedCashAmount; } } if (num >= val.Balance) { __instance.draggedSlot.assignedSlot.ClearStoredInstance(false); } else { val.ChangeBalance(0f - num); __instance.draggedSlot.assignedSlot.ReplicateStoredInstance(); } } if (__instance.onItemMoved != null) { __instance.onItemMoved.Invoke(); } __instance.draggedSlot = null; return false; } if (__instance.onDragStart != null) { __instance.onDragStart.Invoke(); } if (__instance.draggedSlot.assignedSlot != PlayerSingleton<PlayerInventory>.Instance.cashSlot) { __instance.CashSlotHintAnim.Play(); } __instance.tempIcon = __instance.draggedSlot.DuplicateIcon(((Component)Singleton<HUD>.Instance).transform, __instance.draggedAmount); ((TMP_Text)((Component)((Transform)__instance.tempIcon).Find("Balance")).GetComponent<TextMeshProUGUI>()).text = MoneyManager.FormatAmount(__instance.draggedCashAmount, false, false); __instance.draggedSlot.IsBeingDragged = true; if (__instance.draggedCashAmount >= val.Balance) { __instance.draggedSlot.SetVisible(false); return false; } Utils.CastTo<ItemUI_Cash>((Il2CppObjectBase)(object)__instance.draggedSlot.ItemUI).SetDisplayedBalance(val.Balance - __instance.draggedCashAmount); return false; } [HarmonyPatch(typeof(ItemUIManager), "EndCashDrag")] [HarmonyPrefix] public static bool EndCashDragPrefix(ItemUIManager __instance) { int stackLimit = Utils.Mod.GetStackLimit((EItemCategory)6); CashInstance val = null; if ((Object)(object)__instance.draggedSlot != (Object)null && __instance.draggedSlot.assignedSlot != null) { val = ((Il2CppObjectBase)__instance.draggedSlot.assignedSlot.ItemInstance).Cast<CashInstance>(); } __instance.CashSlotHintAnim.Stop(); __instance.CashSlotHintAnimCanvasGroup.alpha = 0f; if (__instance.CanDragFromSlot(__instance.draggedSlot) && (Object)(object)__instance.HoveredSlot != (Object)null && __instance.CanCashBeDraggedIntoSlot(__instance.HoveredSlot) && !__instance.HoveredSlot.assignedSlot.IsLocked && !__instance.HoveredSlot.assignedSlot.IsAddLocked && __instance.HoveredSlot.assignedSlot.DoesItemMatchHardFilters(__instance.draggedSlot.assignedSlot.ItemInstance)) { if (new Func<HotbarSlot>(((Il2CppObjectBase)__instance.HoveredSlot.assignedSlot).TryCast<HotbarSlot>) != null && new Func<CashSlot>(((Il2CppObjectBase)__instance.HoveredSlot.assignedSlot).TryCast<CashSlot>) == null) { __instance.HoveredSlot = (ItemSlotUI)(object)((Component)Singleton<HUD>.Instance.cashSlotUI).GetComponent<CashSlotUI>(); } float num = Mathf.Min(__instance.draggedCashAmount, val.Balance); if (num > 0f) { float num2 = num; if (__instance.HoveredSlot.assignedSlot.ItemInstance != null) { CashInstance val2 = ((Il2CppObjectBase)__instance.HoveredSlot.assignedSlot.ItemInstance).TryCast<CashInstance>(); num2 = ((!Utils.Is<CashSlot>((Il2CppObjectBase)(object)__instance.HoveredSlot.assignedSlot)) ? Mathf.Min(num, (float)stackLimit - val2.Balance) : Mathf.Min(num, float.MaxValue - val2.Balance)); val2.ChangeBalance(num2); __instance.HoveredSlot.assignedSlot.ReplicateStoredInstance(); } else { CashInstance val3 = ((Il2CppObjectBase)Registry.GetItem("cash").GetDefaultInstance(1)).Cast<CashInstance>(); val3.SetBalance(num2, false); __instance.HoveredSlot.assignedSlot.SetStoredItem((ItemInstance)(object)val3, false); } if (num2 >= val.Balance) { __instance.draggedSlot.assignedSlot.ClearStoredInstance(false); } else { val.ChangeBalance(0f - num2); __instance.draggedSlot.assignedSlot.ReplicateStoredInstance(); } } } __instance.draggedSlot.SetVisible(true); __instance.draggedSlot.UpdateUI(); __instance.draggedSlot.IsBeingDragged = false; __instance.draggedSlot = null; Object.Destroy((Object)(object)((Component)__instance.tempIcon).gameObject); Singleton<CursorManager>.Instance.SetCursorAppearance((ECursorType)0); return false; } } [HarmonyPatch] public class NPCMovementPatches { [HarmonyPatch(typeof(NPCMovement), "Awake")] [HarmonyPostfix] public static void AwakePostfix(NPCMovement __instance) { __instance.Agent.stoppingDistance = 0.1f; } [HarmonyPatch(typeof(NPCMovement), "CanGetTo", new Type[] { typeof(ITransitEntity), typeof(float) })] [HarmonyPrefix] public static void CanGetToPrefix(NPCMovement __instance, ITransitEntity entity, ref float proximityReq) { if (entity != null && Utils.Is<MushroomSpawnStation>((Il2CppObjectBase)(object)entity) && proximityReq < 0.8f) { proximityReq = 0.8f; } } } [HarmonyPatch] public class SetDestinationPatches { [HarmonyTargetMethod] public static MethodBase TargetMethod() { return AccessTools.FirstMethod(typeof(NPCMovement), (Func<MethodInfo, bool>)((MethodInfo method) => method.Name == "SetDestination" && method.GetParameters().Length == 5)); } [HarmonyPatch] [HarmonyPrefix] public static void SetDestinationPrefix(NPCMovement __instance, ref float successThreshold) { float num = 1f; NPC field = Utils.GetField<NPCMovement, NPC>("npc", __instance); if (Utils.Is<Employee>((Il2CppObjectBase)(object)field)) { num = Utils.Mod.employeeAnimation.GetEntry<float>("employeeWalkAcceleration").Value; } __instance.MoveSpeedMultiplier = num; if (num > 1f) { __instance.Agent.acceleration = 20f * Mathf.Pow(num, 5f); __instance.Agent.angularSpeed = 720f * Mathf.Pow(num, 5f); } if (successThreshold > 0.4f) { successThreshold = 0.4f; } } } }