Decompiled source of TeleporterItems v1.0.3

TeleporterItems.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TeleporterItems.patch;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("TeleporterItems")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TeleporterItems")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5e21fa35-9f97-42b8-b795-306db0c8bee9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TeleporterItems
{
	[BepInPlugin("kerotein.TeleporterItems", "TeleporterItems", "1.0.3")]
	public class TeleporterItems : BaseUnityPlugin
	{
		private const string MOD_NAME = "TeleporterItems";

		private const string AUTHOR_NAME = "kerotein";

		private const string MOD_GUID = "kerotein.TeleporterItems";

		private const string MOD_VERSION = "1.0.3";

		private static readonly Harmony harmony = new Harmony("TeleporterItems");

		internal static ManualLogSource ManualLogSource;

		private static TeleporterItems Instance;

		internal void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				ManualLogSource = Logger.CreateLogSource("TeleporterItems");
			}
			ManualLogSource.LogInfo((object)"TeleporterItems loaded");
			harmony.PatchAll(typeof(TeleportInPatch));
		}
	}
}
namespace TeleporterItems.patch
{
	internal class TeleportInPatch : MonoBehaviour
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(ShipTeleporter), "TeleportPlayerOutWithInverseTeleporter")]
		internal static bool TeleportPlayerOutWithInverseTeleporterPatch(int playerObj, ref Vector3 teleportPos, ShipTeleporter __instance)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			Type typeFromHandle = typeof(ShipTeleporter);
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObj];
			if (val.isPlayerDead)
			{
				MethodInfo method = typeFromHandle.GetMethod("teleportBodyOut", BindingFlags.Instance | BindingFlags.NonPublic);
				((MonoBehaviour)__instance).StartCoroutine((IEnumerator)method.Invoke(__instance, new object[2] { playerObj, teleportPos }));
				return false;
			}
			MethodInfo method2 = typeFromHandle.GetMethod("SpikeTrapsReactToInverseTeleport", BindingFlags.Instance | BindingFlags.NonPublic);
			MethodInfo method3 = typeFromHandle.GetMethod("SetCaveReverb", BindingFlags.Instance | BindingFlags.NonPublic);
			MethodInfo method4 = typeFromHandle.GetMethod("SetPlayerTeleporterId", BindingFlags.Instance | BindingFlags.NonPublic);
			method2.Invoke(__instance, null);
			method3.Invoke(__instance, new object[1] { val });
			method4.Invoke(__instance, new object[2] { val, -1 });
			if (Object.op_Implicit((Object)(object)Object.FindObjectOfType<AudioReverbPresets>()))
			{
				Object.FindObjectOfType<AudioReverbPresets>().audioPresets[2].ChangeAudioReverbForPlayer(val);
			}
			val.isInElevator = false;
			val.isInHangarShipRoom = false;
			val.isInsideFactory = true;
			val.averageVelocity = 0f;
			val.velocityLastFrame = Vector3.zero;
			val.TeleportPlayer(teleportPos, false, 0f, false, true);
			val.beamOutParticle.Play();
			__instance.shipTeleporterAudio.PlayOneShot(__instance.teleporterBeamUpSFX);
			val.movementAudio.PlayOneShot(__instance.teleporterBeamUpSFX);
			if ((Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				Debug.Log((object)"Teleporter shaking camera");
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			return false;
		}
	}
}