Decompiled source of DeliveryDash v1.0.1

DeliveryTracker.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using DeliveryTracker;
using HarmonyLib;
using Il2CppScheduleOne.Delivery;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Property;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
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(DeliveryMod), "DeliveryMod", "1.0.0", "Hyde", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("DeliveryTracker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DeliveryTracker")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("08fcf83a-cc73-4b21-bcf5-2e561870cd2a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DeliveryTracker;

public class DeliveryMod : MelonMod
{
	[HarmonyPatch(typeof(DeliveryManager), "SendDelivery")]
	private class SendDeliveryHook
	{
		private static void Prefix(DeliveryInstance delivery)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			if (delivery != null)
			{
				if (currentDelivery != null && (int)currentDelivery.Status > 0)
				{
					hasLoggedDelivery = false;
				}
				if (!hasLoggedDelivery && (int)delivery.Status == 0)
				{
					currentDelivery = delivery;
					hasLoggedDelivery = true;
				}
			}
		}
	}

	public static DeliveryInstance currentDelivery;

	private static bool hasLoggedDelivery;

	public override void OnInitializeMelon()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		((MelonBase)this).OnInitializeMelon();
		try
		{
			Harmony val = new Harmony("com.hyde.deliverymod");
			val.PatchAll();
			MelonLogger.Msg("DeliveryMod initialized and hooked.");
		}
		catch (Exception arg)
		{
			MelonLogger.Error($"[DeliveryMod] Failed to patch: {arg}");
		}
	}

	public override void OnUpdate()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Invalid comparison between Unknown and I4
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Invalid comparison between Unknown and I4
		((MelonBase)this).OnUpdate();
		try
		{
			if (currentDelivery != null && (int)currentDelivery.Status > 0)
			{
				currentDelivery = null;
			}
			if (currentDelivery != null)
			{
				return;
			}
			DeliveryManager instance = NetworkSingleton<DeliveryManager>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			FieldInfo field = ((object)instance).GetType().GetField("Deliveries", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field == null || !(field.GetValue(instance) is List<DeliveryInstance> val))
			{
				return;
			}
			Enumerator<DeliveryInstance> enumerator = val.GetEnumerator();
			while (enumerator.MoveNext())
			{
				DeliveryInstance current = enumerator.Current;
				if (current != null && (int)current.Status == 0)
				{
					currentDelivery = current;
					break;
				}
			}
		}
		catch (Exception arg)
		{
			MelonLogger.Error($"[DeliveryMod] Error in OnUpdate: {arg}");
		}
	}

	public override void OnGUI()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Invalid comparison between Unknown and I4
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Expected O, but got Unknown
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		((MelonBase)this).OnGUI();
		if (currentDelivery != null && (int)currentDelivery.Status == 0)
		{
			Property destination = currentDelivery.Destination;
			string arg = ((destination != null) ? ((Object)destination).ToString() : null) ?? "Unknown";
			int timeUntilArrival = currentDelivery.TimeUntilArrival;
			GUIStyle val = new GUIStyle();
			val.fontSize = 20;
			val.normal.textColor = Color.white;
			val.alignment = (TextAnchor)4;
			string text = $"Delivery to: {arg}\nTime: {timeUntilArrival} min";
			Vector2 val2 = val.CalcSize(new GUIContent(text));
			float num = Mathf.Min(val2.x, (float)(Screen.width - 40));
			float num2 = val2.y + 20f;
			float num3 = ((float)Screen.width - num) / 2f;
			float num4 = (float)Screen.height - num2 - 20f;
			GUI.Label(new Rect(num3, num4, num, num2), text, val);
		}
	}
}