Decompiled source of fastStart v0.1.0

plugins/com.github.hubor.fastStart.dll

Decompiled 5 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.hubor.fastStart")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("com.github.hubor.fastStart")]
[assembly: AssemblyTitle("fastStart")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace fastStart
{
	[BepInPlugin("com.hubor.fastStart", "Start From Anywhere Mod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static int _lastKnownDifficulty = 1;

		private bool _isRestarting;

		private Harmony _harmony;

		internal static ManualLogSource Log { get; private set; } = null;


		private void Awake()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + ((BaseUnityPlugin)this).Info.Metadata.GUID + " is loaded!"));
			SceneManager.sceneLoaded += OnSceneLoaded;
			_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			_harmony.PatchAll();
			Log.LogInfo((object)"Harmony patches applied.");
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			_harmony.UnpatchSelf();
		}

		private void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (!(name == "Title"))
			{
				if (Input.GetKeyDown((KeyCode)286))
				{
					OpenStartMenu();
				}
				if (Input.GetKeyDown((KeyCode)287))
				{
					Log.LogInfo((object)"F6 key pressed! Initiating restart sequence...");
					_isRestarting = true;
					PhotonNetwork.LoadLevel("Airport");
				}
			}
		}

		private void OpenStartMenu()
		{
			Log.LogInfo((object)"F5 key pressed! Attempting to open the start game menu...");
			AirportCheckInKiosk val = Object.FindObjectOfType<AirportCheckInKiosk>();
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)"Could not find an Airport Kiosk in the current scene.");
				return;
			}
			Character val2 = null;
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (((MonoBehaviourPun)allCharacter).photonView.IsMine)
				{
					val2 = allCharacter;
					break;
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				Log.LogError((object)"Could not find the local player's Character object.");
				return;
			}
			Log.LogInfo((object)"Found Kiosk and Player. Opening the boarding pass UI...");
			val.Interact_CastFinished(val2);
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			Log.LogInfo((object)("A new scene was loaded: " + ((Scene)(ref scene)).name));
			if (_isRestarting && ((Scene)(ref scene)).name == "Airport")
			{
				Log.LogInfo((object)"Airport scene loaded as part of restart sequence. Finding kiosk to start game...");
				_isRestarting = false;
				AirportCheckInKiosk val = Object.FindObjectOfType<AirportCheckInKiosk>();
				if ((Object)(object)val != (Object)null)
				{
					int lastKnownDifficulty = _lastKnownDifficulty;
					Log.LogInfo((object)$"Found Kiosk. Requesting game start with last known difficulty: {lastKnownDifficulty}...");
					val.StartGame(lastKnownDifficulty);
				}
				else
				{
					Log.LogError((object)"Restart failed: Could not find Airport Kiosk after loading the scene.");
				}
			}
		}
	}
	[HarmonyPatch(typeof(AirportCheckInKiosk))]
	public static class AirportCheckInKiosk_Patch
	{
		[HarmonyPatch("StartGame")]
		[HarmonyPrefix]
		public static void LogAndStoreDifficultyPatch(int ascent)
		{
			Plugin.Log.LogInfo((object)$"--- GAME STARTING --- Difficulty (Ascent): {ascent}");
			Plugin._lastKnownDifficulty = ascent;
			Plugin.Log.LogInfo((object)$"Saved difficulty {ascent} for next restart.");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}