Decompiled source of FasterMixing v1.1.1

FasterMixing.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using FasterMixing;
using HarmonyLib;
using MelonLoader;
using Newtonsoft.Json;
using ScheduleOne.ObjectScripts;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(MachineTime), "FasterMixing", "1.1.0", "Zlatan9798", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("FasterMixing")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FasterMixing")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("39af96f2-e7fb-4838-8fa0-fb02b42da503")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FasterMixing;

public class MachineTime : MelonMod
{
	public class Settings
	{
		public int MixTimePerItem { get; set; }

		public bool InstantMixing { get; set; }

		public int MixTimeForAnything { get; set; }
	}

	[HarmonyPatch(typeof(MixingStation), "GetMixTimeForCurrentOperation")]
	private class Patching
	{
		private static void Postfix(ref int __result, MixingStation __instance)
		{
			if (__instance.CurrentMixOperation != null)
			{
				if (Modsettings.MixTimePerItem <= 0)
				{
					MelonLogger.Msg("Tried to put mixtime per item less or equal to 0, changing the value to instant mix");
					Modsettings.MixTimePerItem = 1;
					Modsettings.InstantMixing = true;
				}
				if (Modsettings.InstantMixing)
				{
					__result = 1;
				}
				if (Modsettings.MixTimeForAnything > 0 && !Modsettings.InstantMixing)
				{
					__result = Modsettings.MixTimeForAnything;
					return;
				}
				__result = Modsettings.MixTimePerItem * __instance.CurrentMixOperation.Quantity;
				MelonLogger.Msg($"Changed mix time to {__result}.");
			}
		}
	}

	public static Settings Modsettings;

	public override void OnInitializeMelon()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		LoadSettings();
		MelonLogger.Msg("Faster Mixing loaded!");
		Harmony val = new Harmony("zlatan.FasterMixing");
		val.PatchAll();
	}

	private void LoadSettings()
	{
		try
		{
			string path = Path.Combine(Directory.modDirectory, "configFasterMixing.json");
			if (!File.Exists(path))
			{
				Settings settings = new Settings
				{
					MixTimePerItem = 1,
					InstantMixing = false,
					MixTimeForAnything = 0
				};
				File.WriteAllText(path, JsonConvert.SerializeObject((object)settings, (Formatting)1));
				MelonLogger.Msg("No settings file found. Created one with default settings.");
			}
			string text = File.ReadAllText(path);
			Modsettings = JsonConvert.DeserializeObject<Settings>(text);
		}
		catch (Exception arg)
		{
			MelonLogger.Msg($"Error loading the settings from json: {arg}");
		}
	}
}
public class Directory
{
	public static string modDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}