Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BetterTeleporter v1.2.2
BepInEx/plugins/BetterTeleporter.dll
Decompiled 2 years agousing 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BetterTeleporter")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Better Teleporters for Lethal Company")] [assembly: AssemblyFileVersion("1.2.2.0")] [assembly: AssemblyInformationalVersion("1.2.2")] [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")] 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 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<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"); 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); 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(); } } } } [HarmonyPatch(typeof(PlayerControllerB))] public class ConfigSync { [HarmonyPatch("ConnectClientToPlayerObject")] [HarmonyPostfix] public static void InitializeLocalPlayer() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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)); RequestConfigSync(); } public static void RequestConfigSync() { //IL_003c: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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); } } public static void OnReceiveConfigSync(ulong clientId, FastBufferReader reader) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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."); } } } } 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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown MethodInfo method = ((object)player).GetType().GetMethod("SetSpecialGrabAnimationBool", BindingFlags.Instance | BindingFlags.NonPublic); string[] source = ConfigSettings.keepListItems; if (inverse) { source = ConfigSettings.keepListItemsInverse; } 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())) { 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>(); ShipTeleporter[] array2 = array; foreach (ShipTeleporter obj in array2) { cooldownProp.SetValue(obj, 0f); } } } }