Decompiled source of AutomaticDeliveryUnloads v0.2.0

Mods/AutomaticDeliveryUnloads.dll

Decompiled 6 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using FishNet;
using HarmonyLib;
using LoadingDockRouteFix;
using MelonLoader;
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(LoadingDockRouteFixMod), "Loading Dock Route Fix", "0.1.0", "You", null)]
[assembly: MelonGame(null, "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AutomaticDeliveryUnloads")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c5e45fe185c4cfc17df992a286109003188c8d8f")]
[assembly: AssemblyProduct("AutomaticDeliveryUnloads")]
[assembly: AssemblyTitle("AutomaticDeliveryUnloads")]
[assembly: NeutralResourcesLanguage("en-US")]
[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 LoadingDockRouteFix
{
	public class LoadingDockRouteFixMod : MelonMod
	{
		private static Harmony _harmony;

		public override void OnInitializeMelon()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_harmony = new Harmony("schedule1.loadingdock.routefix");
			_harmony.PatchAll(typeof(Patches).Assembly);
			MelonLogger.Msg("Loading Dock Route Fix loaded.");
		}
	}
	internal static class Patches
	{
		[HarmonyPatch(typeof(LoadingDock), "SetStaticOccupant")]
		private static class LoadingDock_SetStaticOccupant_Patch
		{
			private static void Postfix(LoadingDock __instance, LandVehicle vehicle)
			{
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0176: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (!InstanceFinder.IsServer || (Object)(object)__instance == (Object)null)
					{
						return;
					}
					LoadingDock val = __instance;
					if (val.InputSlots == null)
					{
						List<ItemSlot> list2 = (val.InputSlots = new List<ItemSlot>());
					}
					val = __instance;
					if (val.OutputSlots == null)
					{
						List<ItemSlot> list2 = (val.OutputSlots = new List<ItemSlot>());
					}
					__instance.InputSlots.Clear();
					__instance.OutputSlots.Clear();
					if ((Object)(object)vehicle != (Object)null && (Object)(object)vehicle.Storage != (Object)null && vehicle.Storage.ItemSlots != null)
					{
						__instance.OutputSlots.AddRange(vehicle.Storage.ItemSlots);
						if (__instance.accessPoints != null && __instance.accessPoints.Length != 0 && (Object)(object)__instance.accessPoints[0] != (Object)null)
						{
							Vector3 position = ((Component)vehicle).transform.position - ((Component)vehicle).transform.forward * (vehicle.BoundingBoxDimensions.z / 2f + 0.6f);
							__instance.accessPoints[0].position = position;
							__instance.accessPoints[0].rotation = Quaternion.LookRotation(((Component)vehicle).transform.forward, Vector3.up);
							Vector3 localPosition = __instance.accessPoints[0].localPosition;
							__instance.accessPoints[0].localPosition = new Vector3(localPosition.x, 0f, localPosition.z);
						}
						bool flag = false;
					}
					else
					{
						bool flag2 = false;
					}
					__instance.IsAcceptingItems = false;
				}
				catch (Exception arg)
				{
					MelonLogger.Error($"[DockFix] SetStaticOccupant postfix exception: {arg}");
				}
			}
		}

		[HarmonyPatch(typeof(LoadingDock), "Awake")]
		private static class LoadingDock_Awake_Patch
		{
			private static void Postfix(LoadingDock __instance)
			{
				try
				{
					if (!((Object)(object)__instance == (Object)null))
					{
						__instance.IsAcceptingItems = false;
					}
				}
				catch
				{
				}
			}
		}

		private const bool DEBUG_LOG = false;
	}
}