Decompiled source of SharedInverseTeleporter v1.3.3

SharedInverseTeleporter.dll

Decompiled 11 months 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 UnityEngine;

[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("SharedInverseTeleporter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Teleports everyone using the inverse teleporter to the same place.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SharedInverseTeleporter")]
[assembly: AssemblyTitle("SharedInverseTeleporter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SharedInverseTeleporter
{
	[BepInPlugin("SharedInverseTeleporter", "SharedInverseTeleporter", "1.0.0")]
	[BepInProcess("Lethal Company.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource log;

		private readonly Harmony harmony = new Harmony("SharedInverseTeleporter");

		public static Plugin instance { get; private set; }

		private void Awake()
		{
			instance = this;
			log = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			log.LogInfo((object)"Plugin SharedInverseTeleporter is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SharedInverseTeleporter";

		public const string PLUGIN_NAME = "SharedInverseTeleporter";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace SharedInverseTeleporter.patches
{
	[HarmonyPatch]
	internal class SharedInverseTeleporter
	{
		private static Random _random = new Random(0);

		private static Vector3 _teleportPos;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ShipTeleporter), "TeleportPlayerOutWithInverseTeleporter")]
		public static void TeleportPlayerOutWithInverseTeleporter(int playerObj, ref Vector3 teleportPos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			teleportPos = _teleportPos;
			Plugin.log.LogInfo((object)$"Teleporting player {playerObj} to {_teleportPos}");
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ShipTeleporter), "beamOutPlayer")]
		public static void SetTeleportPosition(bool ___isInverseTeleporter)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (___isInverseTeleporter)
			{
				int num = _random.Next(0, RoundManager.Instance.insideAINodes.Length);
				_teleportPos = RoundManager.Instance.insideAINodes[num].transform.position;
				Plugin.log.LogInfo((object)$"Set teleport position to {_teleportPos}");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ShipTeleporter), "Awake")]
		private static void Awake(ShipTeleporter __instance)
		{
			if (__instance.isInverseTeleporter)
			{
				__instance.cooldownAmount = 10f;
				Plugin.log.LogInfo((object)"Reduced the cooldown of the inverse teleporter to 10 seconds.");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")]
		public static void GenerateNewLevelClientRpc(int randomSeed)
		{
			_random = new Random(randomSeed);
			Plugin.log.LogInfo((object)$"Initialized a new random number generator with seed {randomSeed}");
		}
	}
}