Decompiled source of BetterTeleporterLethalThings v1.1.0

BepInEx/plugins/BetterTeleporter.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BetterTeleporter.Config;
using BetterTeleporter.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[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("BetterTeleporter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Better Teleporters for Lethal Company")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2+6f19cf163f211303c2d14af744a1a73efc7d0d4d")]
[assembly: AssemblyProduct("BetterTeleporter")]
[assembly: AssemblyTitle("BetterTeleporter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.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 BetterTeleporter
{
	[BepInPlugin("BetterTeleporter", "BetterTeleporter", "1.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("BetterTeleporter");

		internal static ManualLogSource log;

		public static Plugin instance { get; private set; }

		private void Awake()
		{
			instance = this;
			log = ((BaseUnityPlugin)this).Logger;
			ConfigSettings.Bind();
			harmony.PatchAll(typeof(ConfigSync));
			harmony.PatchAll(typeof(ShipTeleporterPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			log.LogInfo((object)"Plugin BetterTeleporter is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BetterTeleporter";

		public const string PLUGIN_NAME = "BetterTeleporter";

		public const string PLUGIN_VERSION = "1.2.2";
	}
}
namespace BetterTeleporter.Config
{
	public static class ConfigSettings
	{
		public static int cooldownAmmount;

		public static int cooldownAmmountInverse;

		public static bool cooldownEnd;

		public static string[] keepListItems;

		public static string[] keepListItemsInverse;

		public static string[] keepListLethalThingsItems;

		public static bool doDrainItems;

		public static float drainItemsPercent;

		public static ConfigEntry<int> cooldown;

		public static ConfigEntry<int> cooldownInverse;

		public static ConfigEntry<bool> cooldownEndDay;

		public static ConfigEntry<string> keepList;

		public static ConfigEntry<string> keepListInverse;

		public static ConfigEntry<string> keepListLethalThings;

		public static ConfigEntry<bool> doDrain;

		public static ConfigEntry<float> drainPercent;

		public static void Bind()
		{
			cooldown = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("General", "Cooldown", 10, "Number of seconds between teleporter uses");
			cooldownInverse = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("General", "CooldownInverse", 210, "Number of seconds between teleporter uses");
			cooldownEndDay = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("General", "CooldownEndsOnNewDay", true, "true/false if cooldown should end on new day");
			keepList = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("General", "KeepItemList", "KeyItem,FlashlightItem,WalkieTalkie", "Comma-seperated list of items to be kept when teleported");
			keepListInverse = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("General", "KeepItemListInverse", "KeyItem,FlashlightItem,WalkieTalkie,RadarBoosterItem", "Comma-seperated list of items to be kept when teleported with inverse teleporter");
			keepListLethalThings = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("General", "KeepItemListLethalThings", "PouchyBelt", "Comma-seperated list of items to be kept when teleported with inverse and normal teleporter, but with LethalThings Items");
			doDrain = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("General", "DrainItem", true, "true/false if items should drain battery charge");
			drainPercent = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("General", "DrainPercent", 0.5f, "The percentage (as float 0 to 1) of total charge that battery items lose when teleporting");
			cooldownAmmount = cooldown.Value;
			cooldownAmmountInverse = cooldownInverse.Value;
			cooldownEnd = cooldownEndDay.Value;
			SetKeepList(keepList.Value);
			SetKeepList(keepListInverse.Value, inverse: true);
			SetKeepListLethalThings(keepListLethalThings.Value);
			doDrainItems = doDrain.Value;
			drainItemsPercent = drainPercent.Value;
		}

		public static void SetKeepList(string list, bool inverse = false)
		{
			if (inverse)
			{
				keepListItemsInverse = list.Split(',');
				for (int i = 0; i < keepListItemsInverse.Length; i++)
				{
					keepListItemsInverse[i] = keepListItemsInverse[i].Trim();
				}
			}
			else
			{
				keepListItems = list.Split(',');
				for (int j = 0; j < keepListItems.Length; j++)
				{
					keepListItems[j] = keepListItems[j].Trim();
				}
			}
		}

		public static void SetKeepListLethalThings(string list)
		{
			keepListLethalThingsItems = list.Split(',');
			for (int i = 0; i < keepListLethalThingsItems.Length; i++)
			{
				keepListLethalThingsItems[i] = keepListLethalThingsItems[i].Trim();
				keepListLethalThingsItems[i] = "LethalThings." + keepListLethalThingsItems[i];
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class ConfigSync
	{
		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void InitializeLocalPlayer()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (NetworkManager.Singleton.IsServer)
			{
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterTeleporterConfigSync", new HandleNamedMessageDelegate(OnReceiveConfigSyncRequest));
				return;
			}
			NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterTeleporterReceiveConfigSync", new HandleNamedMessageDelegate(OnReceiveConfigSync));
			NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterTeleporterReceiveConfigSync_KeepList", new HandleNamedMessageDelegate(OnReceiveConfigSync_KeepList));
			NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterTeleporterReceiveConfigSync_KeepListInverse", new HandleNamedMessageDelegate(OnReceiveConfigSync_KeepListInverse));
			NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterTeleporterReceiveConfigSync_KeepListLethalThings", new HandleNamedMessageDelegate(OnReceiveConfigSync_KeepListLethalThings));
			RequestConfigSync();
		}

		public static void RequestConfigSync()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsClient)
			{
				Plugin.log.LogInfo((object)"Sending config sync request to server.");
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterTeleporterConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			else
			{
				Plugin.log.LogWarning((object)"Failed to send config sync request.");
			}
		}

		public static void OnReceiveConfigSyncRequest(ulong clientId, FastBufferReader reader)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				Plugin.log.LogInfo((object)("Receiving sync request from client with id: " + clientId + ". Sending config sync to client."));
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(14, (Allocator)2, -1);
				int value = ConfigSettings.cooldown.Value;
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref value, default(ForPrimitives));
				value = ConfigSettings.cooldownInverse.Value;
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref value, default(ForPrimitives));
				bool value2 = ConfigSettings.cooldownEndDay.Value;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref value2, default(ForPrimitives));
				value2 = ConfigSettings.doDrain.Value;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref value2, default(ForPrimitives));
				float value3 = ConfigSettings.drainPercent.Value;
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref value3, default(ForPrimitives));
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterTeleporterReceiveConfigSync", clientId, val, (NetworkDelivery)3);
				FastBufferWriter val2 = default(FastBufferWriter);
				((FastBufferWriter)(ref val2))..ctor(ConfigSettings.keepList.Value.Length * 2, (Allocator)2, -1);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ConfigSettings.keepList.Value, true);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterTeleporterReceiveConfigSync_KeepList", clientId, val2, (NetworkDelivery)3);
				FastBufferWriter val3 = default(FastBufferWriter);
				((FastBufferWriter)(ref val3))..ctor(ConfigSettings.keepListInverse.Value.Length * 2, (Allocator)2, -1);
				((FastBufferWriter)(ref val3)).WriteValueSafe(ConfigSettings.keepListInverse.Value, true);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterTeleporterReceiveConfigSync_KeepListInverse", clientId, val3, (NetworkDelivery)3);
				FastBufferWriter val4 = default(FastBufferWriter);
				((FastBufferWriter)(ref val4))..ctor(ConfigSettings.keepListLethalThings.Value.Length * 2, (Allocator)2, -1);
				((FastBufferWriter)(ref val4)).WriteValueSafe(ConfigSettings.keepListLethalThings.Value, true);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterTeleporterReceiveConfigSync_KeepListLethalThings", clientId, val4, (NetworkDelivery)3);
			}
		}

		public static void OnReceiveConfigSync(ulong clientId, FastBufferReader reader)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			FastBufferReader val = reader;
			if (((FastBufferReader)(ref val)).TryBeginRead(4))
			{
				Plugin.log.LogInfo((object)"Receiving sync from server.");
				val = reader;
				int num = default(int);
				((FastBufferReader)(ref val)).ReadValueSafe<int>(ref num, default(ForPrimitives));
				ConfigSettings.cooldownAmmount = num;
				Plugin.log.LogInfo((object)$"Recieved 'cooldownAmmount = {num}");
				val = reader;
				int num2 = default(int);
				((FastBufferReader)(ref val)).ReadValueSafe<int>(ref num2, default(ForPrimitives));
				ConfigSettings.cooldownAmmountInverse = num2;
				Plugin.log.LogInfo((object)$"Recieved 'cooldownAmmountInverse = {num2}");
				val = reader;
				bool flag = default(bool);
				((FastBufferReader)(ref val)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ConfigSettings.cooldownEnd = flag;
				Plugin.log.LogInfo((object)$"Recieved 'cooldownEnd = {flag}");
				val = reader;
				bool flag2 = default(bool);
				((FastBufferReader)(ref val)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				ConfigSettings.doDrainItems = flag2;
				Plugin.log.LogInfo((object)$"Recieved 'doDrainItems = {flag2}");
				val = reader;
				float num3 = default(float);
				((FastBufferReader)(ref val)).ReadValueSafe<float>(ref num3, default(ForPrimitives));
				ConfigSettings.drainItemsPercent = num3;
				Plugin.log.LogInfo((object)$"Recieved 'drainItemsPercent = {num3}");
			}
			else
			{
				Plugin.log.LogWarning((object)"Error receiving config sync from server.");
			}
		}

		public static void OnReceiveConfigSync_KeepList(ulong clientId, FastBufferReader reader)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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)
			FastBufferReader val = reader;
			if (((FastBufferReader)(ref val)).TryBeginRead(4))
			{
				Plugin.log.LogInfo((object)"Receiving sync from server.");
				val = reader;
				string text = default(string);
				((FastBufferReader)(ref val)).ReadValueSafe(ref text, true);
				ConfigSettings.SetKeepList(text);
				Plugin.log.LogInfo((object)("Recieved 'keepList = " + text));
			}
			else
			{
				Plugin.log.LogWarning((object)"Error receiving keepList config sync from server.");
			}
		}

		public static void OnReceiveConfigSync_KeepListInverse(ulong clientId, FastBufferReader reader)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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)
			FastBufferReader val = reader;
			if (((FastBufferReader)(ref val)).TryBeginRead(4))
			{
				Plugin.log.LogInfo((object)"Receiving sync from server.");
				val = reader;
				string text = default(string);
				((FastBufferReader)(ref val)).ReadValueSafe(ref text, true);
				ConfigSettings.SetKeepList(text, inverse: true);
				Plugin.log.LogInfo((object)("Recieved 'keepListInverse = " + text));
			}
			else
			{
				Plugin.log.LogWarning((object)"Error receiving keepListInverse config sync from server.");
			}
		}

		public static void OnReceiveConfigSync_KeepListLethalThings(ulong clientId, FastBufferReader reader)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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)
			FastBufferReader val = reader;
			if (((FastBufferReader)(ref val)).TryBeginRead(4))
			{
				Plugin.log.LogInfo((object)"Receiving sync from server.");
				val = reader;
				string text = default(string);
				((FastBufferReader)(ref val)).ReadValueSafe(ref text, true);
				ConfigSettings.SetKeepListLethalThings(text);
				Plugin.log.LogInfo((object)("Recieved 'keepListLethalThings = " + text));
			}
			else
			{
				Plugin.log.LogWarning((object)"Error receiving keepListLethalThings config sync from server.");
			}
		}
	}
}
namespace BetterTeleporter.Patches
{
	[HarmonyPatch(typeof(ShipTeleporter))]
	public class ShipTeleporterPatch
	{
		private static readonly CodeMatch[] inverseTeleporterPatchIlMatch = (CodeMatch[])(object)new CodeMatch[4]
		{
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 1L)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 0L)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, originalMethodInfo)), (string)null)
		};

		private static readonly CodeMatch[] teleporterPatchIlMatch = (CodeMatch[])(object)new CodeMatch[5]
		{
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdarg(i, (int?)0)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 1L)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 0L)), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, originalMethodInfo)), (string)null)
		};

		private static readonly MethodInfo originalMethodInfo = typeof(PlayerControllerB).GetMethod("DropAllHeldItems", BindingFlags.Instance | BindingFlags.Public);

		private static readonly MethodInfo replaceMethodInfo = typeof(ShipTeleporterPatch).GetMethod("DropSomeItems", BindingFlags.Static | BindingFlags.NonPublic);

		[HarmonyTranspiler]
		[HarmonyPatch("TeleportPlayerOutWithInverseTeleporter")]
		public static IEnumerable<CodeInstruction> InverseTeleporterDropAllButHeldItem(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.Start();
			val.MatchForward(false, inverseTeleporterPatchIlMatch);
			val.Advance(1);
			val.RemoveInstructionsWithOffsets(0, 2);
			val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldc_I4_0, (object)1)
			});
			val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldc_I4_1, (object)1)
			});
			val.Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Callvirt, (object)replaceMethodInfo)
			});
			Plugin.log.LogInfo((object)"Patched 'ShipTeleporterPatch.TeleportPlayerOutWithInverseTeleporter'");
			return val.Instructions();
		}

		[HarmonyTranspiler]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static IEnumerable<CodeInstruction> TeleporterDropAllButHeldItem(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.End();
			val.MatchBack(false, teleporterPatchIlMatch);
			val.Advance(2);
			val.RemoveInstructionsWithOffsets(0, 2);
			val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldc_I4_0, (object)0)
			});
			val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldc_I4_1, (object)1)
			});
			val.Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Callvirt, (object)replaceMethodInfo)
			});
			Plugin.log.LogInfo((object)"Patched 'ShipTeleporterPatch.beamUpPlayer'");
			return val.Instructions();
		}

		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		private static void Awake(ref bool ___isInverseTeleporter, ref float ___cooldownAmount)
		{
			if (___isInverseTeleporter)
			{
				___cooldownAmount = ConfigSettings.cooldownAmmountInverse;
			}
			else
			{
				___cooldownAmount = ConfigSettings.cooldownAmmount;
			}
		}

		private static void DropSomeItems(PlayerControllerB player, bool inverse = false, bool itemsFall = true)
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			MethodInfo method = ((object)player).GetType().GetMethod("SetSpecialGrabAnimationBool", BindingFlags.Instance | BindingFlags.NonPublic);
			string[] source = ConfigSettings.keepListItems;
			if (inverse)
			{
				source = ConfigSettings.keepListItemsInverse;
			}
			string[] keepListLethalThingsItems = ConfigSettings.keepListLethalThingsItems;
			float num = 1f;
			bool twoHanded = false;
			for (int i = 0; i < player.ItemSlots.Length; i++)
			{
				GrabbableObject val = player.ItemSlots[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (source.Contains(((object)val).GetType().ToString()) || keepListLethalThingsItems.Contains<string>(((object)val).GetType().FullName))
				{
					if (val.insertedBattery != null && ConfigSettings.doDrainItems)
					{
						float num2 = val.insertedBattery.charge - val.insertedBattery.charge * ConfigSettings.drainItemsPercent;
						if (num2 < 0f)
						{
							num2 = 0f;
						}
						val.insertedBattery = new Battery(num2 != 0f, num2);
						val.SyncBatteryServerRpc((int)(num2 * 100f));
					}
					num += Mathf.Clamp(val.itemProperties.weight - 1f, 0f, 10f);
					continue;
				}
				if (itemsFall)
				{
					val.parentObject = null;
					val.heldByPlayerOnServer = false;
					if (player.isInElevator)
					{
						((Component)val).transform.SetParent(player.playersManager.elevatorTransform, true);
					}
					else
					{
						((Component)val).transform.SetParent(player.playersManager.propsContainer, true);
					}
					player.SetItemInElevator(player.isInHangarShipRoom, player.isInElevator, val);
					val.EnablePhysics(true);
					val.EnableItemMeshes(true);
					((Component)val).transform.localScale = val.originalScale;
					val.isHeld = false;
					val.isPocketed = false;
					val.startFallingPosition = ((Component)val).transform.parent.InverseTransformPoint(((Component)val).transform.position);
					val.FallToGround(true);
					val.fallTime = Random.Range(-0.3f, 0.05f);
					if (((NetworkBehaviour)player).IsOwner)
					{
						val.DiscardItemOnClient();
					}
					else if (!val.itemProperties.syncDiscardFunction)
					{
						val.playerHeldBy = null;
					}
				}
				if (((NetworkBehaviour)player).IsOwner)
				{
					((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled = false;
					((Behaviour)HUDManager.Instance.itemSlotIcons[i]).enabled = false;
					HUDManager.Instance.ClearControlTips();
					player.activatingItem = false;
				}
				player.ItemSlots[i] = null;
			}
			GrabbableObject val2 = player.ItemSlots[player.currentItemSlot];
			if ((Object)(object)val2 == (Object)null)
			{
				player.isHoldingObject = false;
				if ((Object)(object)player.currentlyHeldObjectServer != (Object)null)
				{
					method.Invoke(player, new object[2] { false, player.currentlyHeldObjectServer });
				}
				player.playerBodyAnimator.SetBool("cancelHolding", true);
				player.playerBodyAnimator.SetTrigger("Throw");
			}
			else
			{
				twoHanded = val2.itemProperties.twoHanded;
			}
			player.twoHanded = twoHanded;
			player.carryWeight = num;
			player.currentlyHeldObjectServer = val2;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		private static readonly FieldInfo cooldownProp = typeof(ShipTeleporter).GetField("cooldownTime", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch("StartGame")]
		[HarmonyPostfix]
		private static void StartGame()
		{
			if (ConfigSettings.cooldownEnd)
			{
				ResetCooldown();
			}
		}

		[HarmonyPatch("EndOfGame")]
		[HarmonyPostfix]
		private static void EndOfGame()
		{
			if (ConfigSettings.cooldownEnd)
			{
				ResetCooldown();
			}
		}

		[HarmonyPatch("EndOfGameClientRpc")]
		[HarmonyPostfix]
		private static void EndOfGameClientRpc()
		{
			if (ConfigSettings.cooldownEnd)
			{
				ResetCooldown();
			}
		}

		private static void ResetCooldown()
		{
			ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
			foreach (ShipTeleporter obj in array)
			{
				cooldownProp.SetValue(obj, 0f);
			}
		}
	}
}