Decompiled source of Quick Kiosk v1.0.3

BepInEx/plugins/Quick_Kiosk.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Quick_Kiosk")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Quick_Kiosk")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c40d28b9-911b-445e-8624-51760bdd8ffa")]
[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 KioskAscentQuickSelect;

[BepInPlugin("sol.kiosk.ascentquickselect", "Kiosk Ascent Quick Select", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	private Harmony _harmony;

	private void Awake()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		_harmony = new Harmony("sol.kiosk.ascentquickselect");
		_harmony.PatchAll();
		Log.LogInfo((object)"Kiosk Ascent Quick Select loaded.");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
[HarmonyPatch(typeof(BoardingPass), "OnOpen")]
internal static class BoardingPass_OnOpen_Patch
{
	private static readonly FieldInfo AscentIndexField = AccessTools.Field(typeof(BoardingPass), "ascentIndex");

	private static readonly FieldInfo BackingAscentIndexField = AccessTools.Field(typeof(BoardingPass), "_ascentIndex");

	private static readonly MethodInfo UpdateAscentMethod = AccessTools.Method(typeof(BoardingPass), "UpdateAscent", (Type[])null, (Type[])null);

	[HarmonyPostfix]
	private static void Postfix(BoardingPass __instance)
	{
		try
		{
			((MonoBehaviour)__instance).CancelInvoke("StartGame");
			int? requestedAscentIndex = GetRequestedAscentIndex();
			if (requestedAscentIndex.HasValue)
			{
				int value = requestedAscentIndex.Value;
				SetAscentIndex(__instance, value);
				UpdateAscentMethod?.Invoke(__instance, null);
				Plugin.Log.LogInfo((object)$"Auto-start ascent index requested: {value}");
				((MonoBehaviour)__instance).Invoke("StartGame", 0.1f);
			}
		}
		catch (Exception arg)
		{
			Plugin.Log.LogError((object)$"BoardingPass OnOpen postfix failed: {arg}");
		}
	}

	private static int? GetRequestedAscentIndex()
	{
		if (Input.GetKey((KeyCode)96))
		{
			return 0;
		}
		if (IsPressed((KeyCode)49, (KeyCode)257))
		{
			return 1;
		}
		if (IsPressed((KeyCode)50, (KeyCode)258))
		{
			return 2;
		}
		if (IsPressed((KeyCode)51, (KeyCode)259))
		{
			return 3;
		}
		if (IsPressed((KeyCode)52, (KeyCode)260))
		{
			return 4;
		}
		if (IsPressed((KeyCode)53, (KeyCode)261))
		{
			return 5;
		}
		if (IsPressed((KeyCode)54, (KeyCode)262))
		{
			return 6;
		}
		if (IsPressed((KeyCode)55, (KeyCode)263))
		{
			return 7;
		}
		if (IsPressed((KeyCode)56, (KeyCode)264))
		{
			return -1;
		}
		return null;
	}

	private static bool IsPressed(KeyCode alpha, KeyCode keypad)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		return Input.GetKey(alpha) || Input.GetKey(keypad);
	}

	private static void SetAscentIndex(BoardingPass instance, int value)
	{
		if (AscentIndexField != null)
		{
			AscentIndexField.SetValue(instance, value);
		}
		if (BackingAscentIndexField != null)
		{
			BackingAscentIndexField.SetValue(instance, value);
		}
	}
}