Decompiled source of RestrictedTakeoff v1.0.1

RestrictedTakeoff.dll

Decompiled 6 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using LC_API.GameInterfaceAPI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RestrictedTakeoff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RestrictedTakeoff")]
[assembly: AssemblyTitle("RestrictedTakeoff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RestrictedTakeoff;

[BepInPlugin("net.devante.restrictedtakeoff", "RestrictedTakeoff", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(StartMatchLever))]
	internal class StartMatchLeverPatch
	{
		[HarmonyPatch("BeginHoldingInteractOnLever")]
		[HarmonyPostfix]
		private static void LeverPatch(ref StartMatchLever __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)GameState.ShipState != 1)
			{
				__instance.triggerScript.timeToHold = 0.5f;
			}
			else if (!__instance.hasDisplayedTimeWarning && !(StartOfRound.Instance.currentLevel.PlanetName == "71 Gordion"))
			{
				HUDManager.Instance.DisplayTip("ERROR!", "Ship is unable to leave manually, but it will automatically leave at midnight.", true, false, "RT_Warn1");
				__instance.hasDisplayedTimeWarning = true;
				__instance.triggerScript.timeToHold = 1000f;
			}
		}
	}

	private readonly Harmony harmony = new Harmony("net.devante.restrictedtakeoff");

	public void Awake()
	{
		harmony.PatchAll();
		sendLogger("Plugin loaded. Original idea by retrotsunami", "info");
	}

	public void sendLogger(string msg, string type)
	{
		switch (type)
		{
		case "error":
			((BaseUnityPlugin)this).Logger.LogError((object)msg);
			break;
		case "info":
			((BaseUnityPlugin)this).Logger.LogInfo((object)msg);
			break;
		case "debug":
			((BaseUnityPlugin)this).Logger.LogDebug((object)msg);
			break;
		case "warning":
			((BaseUnityPlugin)this).Logger.LogWarning((object)msg);
			break;
		}
	}
}