Decompiled source of InputDock v1.0.0

InputDock-IL2CPP.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppScheduleOne.Delivery;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Vehicles;
using Il2CppSystem.Collections.Generic;
using InputDock;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::InputDock.InputDock), "InputDock", "1.0", "k073l", null)]
[assembly: MelonColor(1, 255, 215, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("InputDock-IL2CPP")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InputDock-IL2CPP")]
[assembly: AssemblyTitle("InputDock-IL2CPP")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace InputDock;

public static class BuildInfo
{
	public const string Name = "InputDock";

	public const string Description = "Fixes dock behavior allowing item input.";

	public const string Author = "k073l";

	public const string Version = "1.0";
}
public class InputDock : MelonMod
{
	[HarmonyPatch(typeof(LoadingDock), "SetOccupant")]
	public class SetOccupantPatch
	{
		private static readonly MethodInfo SetDynamicOccupantMethod = AccessTools.PropertySetter(typeof(LoadingDock), "DynamicOccupant");

		public static bool Prefix(LoadingDock __instance, LandVehicle occupant)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			bool flag = true;
			LandVehicle val = (LandVehicle)AccessTools.PropertyGetter(typeof(LoadingDock), "StaticOccupant").Invoke(__instance, null);
			if ((Object)(object)val != (Object)null)
			{
				flag = false;
			}
			LandVehicle val2 = (LandVehicle)AccessTools.PropertyGetter(typeof(LoadingDock), "DynamicOccupant").Invoke(__instance, null);
			if ((Object)(object)occupant != (Object)(object)val2)
			{
				MelonLogger.Msg("Loading dock " + ((Object)__instance).name + " is " + (((Object)(object)occupant == (Object)null) ? "empty" : "occupied") + ".");
				SetDynamicOccupantMethod.Invoke(__instance, new object[1] { occupant });
				__instance.InputSlots.Clear();
				__instance.OutputSlots.Clear();
				if ((Object)(object)occupant != (Object)null)
				{
					List<ItemSlot> itemSlots = occupant.Storage.ItemSlots;
					Enumerator<ItemSlot> enumerator = itemSlots.GetEnumerator();
					while (enumerator.MoveNext())
					{
						ItemSlot current = enumerator.Current;
						if (!flag)
						{
							__instance.OutputSlots.Add(current);
						}
						else
						{
							__instance.InputSlots.Add(current);
						}
						if (TakeFromOwned.Value)
						{
							__instance.OutputSlots.Add(current);
						}
					}
					if (flag)
					{
						MelonLogger.Msg($"Loading dock {((Object)__instance).name} has been fixed to allow item input ({itemSlots.Count} slots).");
					}
					MelonLogger.Msg($"Dock {((Object)__instance).name} at {__instance.ParentProperty.PropertyName} has {__instance.InputSlots.Count} input, {__instance.OutputSlots.Count} output slots.");
				}
			}
			return false;
		}
	}

	private static Instance MelonLogger { get; set; }

	private static MelonPreferences_Category Category { get; set; }

	private static MelonPreferences_Entry<bool> TakeFromOwned { get; set; }

	public override void OnInitializeMelon()
	{
		MelonLogger = ((MelonBase)this).LoggerInstance;
		MelonLogger.Msg("InputDock initialized");
		Category = MelonPreferences.CreateCategory("InputDock", "InputDock");
		TakeFromOwned = Category.CreateEntry<bool>("TakeFromOwned", true, "Should employees take items from owned vehicles?", (string)null, false, false, (ValueValidator)null, (string)null);
	}
}

InputDock-Mono.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using InputDock;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using ScheduleOne.Delivery;
using ScheduleOne.ItemFramework;
using ScheduleOne.Vehicles;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::InputDock.InputDock), "InputDock", "1.0", "k073l", null)]
[assembly: MelonColor(1, 255, 215, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("InputDock-Mono")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InputDock-Mono")]
[assembly: AssemblyTitle("InputDock-Mono")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 InputDock
{
	public static class BuildInfo
	{
		public const string Name = "InputDock";

		public const string Description = "Fixes dock behavior allowing item input.";

		public const string Author = "k073l";

		public const string Version = "1.0";
	}
	public class InputDock : MelonMod
	{
		[HarmonyPatch(typeof(LoadingDock), "SetOccupant")]
		public class SetOccupantPatch
		{
			private static readonly MethodInfo SetDynamicOccupantMethod = AccessTools.PropertySetter(typeof(LoadingDock), "DynamicOccupant");

			public static bool Prefix(LoadingDock __instance, LandVehicle occupant)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Expected O, but got Unknown
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Expected O, but got Unknown
				bool flag = true;
				LandVehicle val = (LandVehicle)AccessTools.PropertyGetter(typeof(LoadingDock), "StaticOccupant").Invoke(__instance, null);
				if ((Object)(object)val != (Object)null)
				{
					flag = false;
				}
				LandVehicle val2 = (LandVehicle)AccessTools.PropertyGetter(typeof(LoadingDock), "DynamicOccupant").Invoke(__instance, null);
				if ((Object)(object)occupant != (Object)(object)val2)
				{
					MelonLogger.Msg("Loading dock " + ((Object)__instance).name + " is " + (((Object)(object)occupant == (Object)null) ? "empty" : "occupied") + ".");
					SetDynamicOccupantMethod.Invoke(__instance, new object[1] { occupant });
					__instance.InputSlots.Clear();
					__instance.OutputSlots.Clear();
					if ((Object)(object)occupant != (Object)null)
					{
						List<ItemSlot> itemSlots = occupant.Storage.ItemSlots;
						foreach (ItemSlot item in itemSlots)
						{
							if (!flag)
							{
								__instance.OutputSlots.Add(item);
							}
							else
							{
								__instance.InputSlots.Add(item);
							}
							if (TakeFromOwned.Value)
							{
								__instance.OutputSlots.Add(item);
							}
						}
						if (flag)
						{
							MelonLogger.Msg($"Loading dock {((Object)__instance).name} has been fixed to allow item input ({itemSlots.Count} slots).");
						}
						MelonLogger.Msg($"Dock {((Object)__instance).name} at {__instance.ParentProperty.PropertyName} has {__instance.InputSlots.Count} input, {__instance.OutputSlots.Count} output slots.");
					}
				}
				return false;
			}
		}

		private static Instance MelonLogger { get; set; }

		private static MelonPreferences_Category Category { get; set; }

		private static MelonPreferences_Entry<bool> TakeFromOwned { get; set; }

		public override void OnInitializeMelon()
		{
			MelonLogger = ((MelonBase)this).LoggerInstance;
			MelonLogger.Msg("InputDock initialized");
			Category = MelonPreferences.CreateCategory("InputDock", "InputDock");
			TakeFromOwned = Category.CreateEntry<bool>("TakeFromOwned", true, "Should employees take items from owned vehicles?", (string)null, false, false, (ValueValidator)null, (string)null);
		}
	}
}