Decompiled source of ShipLeaveTeleport v0.0.1

ShipLeaveTeleport.dll

Decompiled 10 months ago
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;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ShipLeaveTeleport")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShipLeaveTeleport")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("127E8838-FF9B-4F0A-8B67-272199E64A54")]
[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 ShipLeaveTeleport;

[BepInPlugin("ShipLeaveTeleport", "Ship Leave Teleport", "0.0.1")]
public class ShipLeaveTeleport : BaseUnityPlugin
{
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRound_Patches
	{
		[HarmonyPatch("ShipLeave")]
		[HarmonyPrefix]
		public static void ShipLeave(StartOfRound __instance)
		{
			WasOnShipWhenLeave = GameNetworkManager.Instance.localPlayerController.isInElevator;
		}
	}

	[HarmonyPatch(typeof(ElevatorAnimationEvents))]
	public class ElevatorAnimationEvents_Patches
	{
		[HarmonyPatch("ElevatorFullyRunning")]
		[HarmonyPrefix]
		public static void ElevatorFullyRunning(ElevatorAnimationEvents __instance)
		{
			if (!GameNetworkManager.Instance.localPlayerController.isInElevator && WasOnShipWhenLeave)
			{
				GameNetworkManager.Instance.localPlayerController.isInElevator = WasOnShipWhenLeave;
				WasOnShipWhenLeave = false;
			}
		}
	}

	private const string ID = "ShipLeaveTeleport";

	private const string NAME = "Ship Leave Teleport";

	private const string VERSION = "0.0.1";

	private static Harmony _Harmony;

	private static ManualLogSource _Log;

	private static bool WasOnShipWhenLeave;

	private void Awake()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		_Log = ((BaseUnityPlugin)this).Logger;
		_Harmony = new Harmony("ShipLeaveTeleport");
		_Harmony.PatchAll();
		_Log.LogInfo((object)"The plugin was initialized!");
	}
}