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 Teleporter Overdrive v1.0.0
BepInEx/plugins/TeleporterOverdrive/TeleporterOverdrive.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; 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("TeleporterOverdrive")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+2a5857aa52c5ff771dde80749832475f791acf64")] [assembly: AssemblyProduct("TeleporterOverdrive")] [assembly: AssemblyTitle("TeleporterOverdrive")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 TeleporterOverdrive { internal static class ConfigMenu { [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void Register() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(Plugin.RelayCost, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(Plugin.ExtractionCost, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(Plugin.ChargeSeconds, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(Plugin.CooldownSeconds, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(Plugin.EffectsVolume, false)); ConfigEntry<bool>[] array = new ConfigEntry<bool>[5] { Plugin.RelayEnabled, Plugin.ExtractionEnabled, Plugin.SoundEnabled, Plugin.VisualsEnabled, Plugin.CameraShake }; for (int i = 0; i < array.Length; i++) { LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(array[i], false)); } } } internal readonly struct DropPose { internal readonly Vector3 Player; internal readonly Vector3 Hand; internal readonly Vector3 HandRotation; internal readonly Vector3 Eye; internal readonly Vector3 EyeRotation; internal DropPose(Vector3 player, Vector3 hand, Vector3 handRotation, Vector3 eye, Vector3 eyeRotation) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0020: Unknown result type (might be due to invalid IL or missing references) Player = player; Hand = hand; HandRotation = handRotation; Eye = eye; EyeRotation = eyeRotation; } internal static DropPose Capture(PlayerControllerB player) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) return new DropPose(((Component)player).transform.position, player.localItemHolder.position, player.localItemHolder.eulerAngles, player.playerEye.position, player.playerEye.eulerAngles); } internal bool ValidNear(Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0028: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (Finite(Player) && Finite(Hand) && Finite(Eye) && Finite(HandRotation) && Finite(EyeRotation) && Vector3.Distance(Player, position) < 12f && Vector3.Distance(Hand, Player) < 8f) { return Vector3.Distance(Eye, Player) < 8f; } return false; } private static bool Finite(Vector3 value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(value.x) && !float.IsInfinity(value.x) && !float.IsNaN(value.y) && !float.IsInfinity(value.y) && !float.IsNaN(value.z)) { return !float.IsInfinity(value.z); } return false; } } internal static class InventoryTransit { private static readonly MethodInfo DropOne = AccessTools.Method(typeof(PlayerControllerB), "DropHeldItem", (Type[])null, (Type[])null); private static readonly MethodInfo GrabAnimation = AccessTools.Method(typeof(PlayerControllerB), "SetSpecialGrabAnimationBool", (Type[])null, (Type[])null); internal static void ValidateHooks() { if (DropOne == null || DropOne.GetParameters().Length != 10 || GrabAnimation == null) { throw new NotSupportedException("This game version has an unsupported inventory API; no teleporter upgrade was enabled."); } } internal static ulong Id(GrabbableObject? item) { if (!((Object)(object)item != (Object)null) || !((Object)(object)((NetworkBehaviour)item).NetworkObject != (Object)null) || !((NetworkBehaviour)item).NetworkObject.IsSpawned) { return ulong.MaxValue; } return ((NetworkBehaviour)item).NetworkObjectId; } internal static GrabbableObject? Held(PlayerControllerB player) { GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; if (!player.isHoldingObject || (Object)(object)currentlyHeldObjectServer == (Object)null || !currentlyHeldObjectServer.isHeld || currentlyHeldObjectServer.isPocketed || (Object)(object)currentlyHeldObjectServer.playerHeldBy != (Object)(object)player) { return null; } if (player.currentItemSlot == 50) { if (!((Object)(object)player.ItemOnlySlot == (Object)(object)currentlyHeldObjectServer)) { return null; } return currentlyHeldObjectServer; } if (player.currentItemSlot < 0 || player.currentItemSlot >= player.ItemSlots.Length || !((Object)(object)player.ItemSlots[player.currentItemSlot] == (Object)(object)currentlyHeldObjectServer)) { return null; } return currentlyHeldObjectServer; } internal static LightKind Kind(GrabbableObject? item) { if (!(item is FlashlightItem) || (Object)(object)item.itemProperties == (Object)null) { return LightKind.None; } string text = item.itemProperties.itemName.Replace("-", "").Replace(" ", "").ToLowerInvariant(); if (!(text == "proflashlight")) { if (!(text == "flashlight")) { return LightKind.None; } return LightKind.Flashlight; } return LightKind.ProFlashlight; } internal static GrabbableObject? Flashlight(PlayerControllerB player) { int num = player.ItemSlots.Length; LightKind[] array = new LightKind[num + 1]; for (int i = 0; i < num; i++) { array[i] = Kind(player.ItemSlots[i]); } array[num] = Kind(player.ItemOnlySlot); int held = (((Object)(object)Held(player) == (Object)null) ? (-1) : ((player.currentItemSlot == 50) ? num : player.currentItemSlot)); int num2 = Rules.FlashlightSlot(array, held); if (num2 >= 0) { if (num2 != num) { return player.ItemSlots[num2]; } return player.ItemOnlySlot; } return null; } internal static bool Contains(PlayerControllerB player, GrabbableObject item) { if (Array.IndexOf(player.ItemSlots, item) < 0) { return (Object)(object)player.ItemOnlySlot == (Object)(object)item; } return true; } internal static string RetentionError(GrabbableObject? item) { BeltBagItem val = (BeltBagItem)(object)((item is BeltBagItem) ? item : null); if (val == null || val.objectsInBag.Count <= 0) { return string.Empty; } return "Empty the held belt bag first, or hold a different item. Priority extraction preserves one item, not a bag of items."; } internal static void DropExcept(PlayerControllerB player, GrabbableObject? keep, DropPose pose) { if ((Object)(object)keep != (Object)null && !Contains(player, keep)) { throw new InvalidOperationException("Retained item left this player's inventory."); } GrabbableObject val = Held(player); bool flag = (Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)keep; if (flag) { GrabAnimation.Invoke(player, new object[2] { false, val }); } GrabbableObject[] array = (GrabbableObject[])player.ItemSlots.Clone(); foreach (GrabbableObject val2 in array) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2 == (Object)(object)keep) { continue; } Drop(player, val2, pose); for (int j = 0; j < player.ItemSlots.Length; j++) { if ((Object)(object)player.ItemSlots[j] == (Object)(object)val2) { player.ItemSlots[j] = null; if (((NetworkBehaviour)player).IsOwner && (Object)(object)HUDManager.Instance != (Object)null && j < HUDManager.Instance.itemSlotIcons.Length) { ((Behaviour)HUDManager.Instance.itemSlotIcons[j]).enabled = false; } } } } if ((Object)(object)player.ItemOnlySlot != (Object)null && (Object)(object)player.ItemOnlySlot != (Object)(object)keep) { Drop(player, player.ItemOnlySlot, pose); player.ItemOnlySlot = null; if (((NetworkBehaviour)player).IsOwner && (Object)(object)HUDManager.Instance != (Object)null) { ((Behaviour)HUDManager.Instance.itemOnlySlotIcon).enabled = false; } } if (flag || (Object)(object)val == (Object)null) { player.currentlyHeldObjectServer = null; player.isHoldingObject = false; player.twoHanded = false; player.twoHandedAnimation = false; player.activatingItem = false; player.playerBodyAnimator.SetBool("cancelHolding", true); if (((NetworkBehaviour)player).IsOwner && (Object)(object)HUDManager.Instance != (Object)null) { ((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled = false; HUDManager.Instance.ClearControlTips(); } } player.carryWeight = (((Object)(object)keep == (Object)null) ? 1f : (1f + Mathf.Clamp(keep.itemProperties.weight - 1f, 0f, 10f))); if (!((NetworkBehaviour)player).IsOwner) { return; } StartOfRound.Instance.SendChangedWeightEvent(); try { if ((Object)(object)keep != (Object)null && (Object)(object)val == (Object)(object)keep) { keep.SetControlTipsForItem(); } Type type = AccessTools.TypeByName("ReservedItemSlotCore.Patches.HUDPatcher"); if (type != null) { AccessTools.Method(type, "UpdateUI", (Type[])null, (Type[])null)?.Invoke(null, null); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Inventory UI refresh unavailable: " + ex.Message)); } } private static void Drop(PlayerControllerB player, GrabbableObject item, DropPose pose) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) DropOne.Invoke(player, new object[10] { item, true, false, pose.Player, pose.Hand, pose.HandRotation, pose.Eye, pose.EyeRotation, player.isInHangarShipRoom, player.isInElevator }); } internal static void MoveRetainedItem(PlayerControllerB player, GrabbableObject? item, bool intoShip) { if ((Object)(object)item == (Object)null) { return; } player.SetItemInElevator(intoShip, intoShip, item); item.isInFactory = !intoShip; FlashlightItem val = (FlashlightItem)(object)((item is FlashlightItem) ? item : null); if (val == null || Kind((GrabbableObject?)(object)val) == LightKind.None) { return; } try { player.ChangeHelmetLight(val.flashlightTypeID, ((GrabbableObject)val).isBeingUsed && (!((NetworkBehaviour)player).IsOwner || ((GrabbableObject)val).isPocketed)); if (((GrabbableObject)val).isPocketed) { player.pocketedFlashlight = (GrabbableObject)(object)val; } if (((NetworkBehaviour)player).IsOwner) { val.usingPlayerHelmetLight = ((GrabbableObject)val).isPocketed && ((GrabbableObject)val).isBeingUsed; val.SwitchFlashlight(((GrabbableObject)val).isBeingUsed); if (((GrabbableObject)val).isPocketed) { ((Behaviour)val.flashlightBulb).enabled = false; ((Behaviour)val.flashlightBulbGlow).enabled = false; } val.PocketFlashlightServerRpc(((GrabbableObject)val).isBeingUsed); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Retained flashlight light refresh unavailable: " + ex.Message)); } } } public sealed class OverdriveRuntime : MonoBehaviour { internal static OverdriveRuntime Instance = null; internal static bool HasState; internal static bool RelayOwned; internal static bool RelayAllowed = true; internal static bool ExtractionAllowed = true; internal static bool CrewReady; internal static int RelayPrice = 650; internal static int ExtractPrice = 500; internal static float ChargeTime = 6f; internal static float CooldownTime = 45f; private const string RequestName = "TeleporterOverdrive.Request.v1"; private const string StateName = "TeleporterOverdrive.State.v1"; private const string EventName = "TeleporterOverdrive.Event.v1"; private const string ReplyName = "TeleporterOverdrive.Reply.v1"; private const string SaveKey = "TeleporterOverdrive.InverseFlashlightRelay.v1"; private readonly HashSet<ulong> compatible = new HashSet<ulong>(); private readonly Dictionary<ulong, int> requestIds = new Dictionary<ulong, int>(); private readonly Dictionary<ulong, double> lastOrder = new Dictionary<ulong, double>(); private NetworkManager? network; private StartOfRound? session; private Terminal? terminal; private ShipTeleporter? extractionPad; private ExtractionTicket? ticket; private bool listening; private bool initialized; private float sessionSince; private float nextHello; private float nextBroadcast; private float nextDiscovery; private int requestId; private int sequence; private int lastCommit = -1; private ShipTeleporter[] teleporters = Array.Empty<ShipTeleporter>(); private bool remoteBusy; internal static bool RelayActive { get { if (HasState && RelayOwned && RelayAllowed) { return CrewReady; } return false; } } internal bool Busy { get { if (!((Object)(object)network != (Object)null) || !network.IsServer) { return remoteBusy; } return ticket != null; } } private double Now { get { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)network == (Object)null)) { NetworkTime serverTime = network.ServerTime; return ((NetworkTime)(ref serverTime)).Time; } return Time.realtimeSinceStartupAsDouble; } } private bool Landed { get { if ((Object)(object)session != (Object)null && session.shipHasLanded && !session.inShipPhase && !session.shipIsLeaving && !session.travellingToNewLevel) { return !session.beganLoadingNewLevel; } return false; } } private void Awake() { Instance = this; } private unsafe void Update() { //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) TerminalCommands.Flush(); NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { if (listening) { Unbind(); ResetSession(); } listening = false; return; } if ((Object)(object)network != (Object)(object)singleton || !listening) { Bind(singleton); } listening = true; if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } if ((Object)(object)session != (Object)(object)StartOfRound.Instance) { ResetSession(); session = StartOfRound.Instance; sessionSince = Time.realtimeSinceStartup; compatible.Add(singleton.LocalClientId); } if ((Object)(object)terminal == (Object)null) { terminal = Object.FindObjectOfType<Terminal>(); } if (Time.realtimeSinceStartup >= nextDiscovery) { nextDiscovery = Time.realtimeSinceStartup + 1f; teleporters = Object.FindObjectsOfType<ShipTeleporter>(); } if (singleton.IsServer) { if (!initialized && (Object)(object)terminal != (Object)null && (Object)(object)TimeOfDay.Instance != (Object)null && Time.realtimeSinceStartup - sessionSince > 2f) { initialized = true; LoadOwnership(); HasState = true; } if (initialized) { ReadHostConfig(); CrewReady = AllClientsReady(); UpdateExtraction(); if (Time.realtimeSinceStartup >= nextBroadcast) { nextBroadcast = Time.realtimeSinceStartup + 1f; SendState(); } } } else if (Time.realtimeSinceStartup >= nextHello) { nextHello = Time.realtimeSinceStartup + (float)((!HasState) ? 1 : 4); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { byte b = 0; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); int num = 1; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("TeleporterOverdrive.Request.v1", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } } private void ReadHostConfig() { RelayPrice = Rules.Cost(Plugin.RelayCost.Value); ExtractPrice = Rules.Cost(Plugin.ExtractionCost.Value); RelayAllowed = Plugin.RelayEnabled.Value; ExtractionAllowed = Plugin.ExtractionEnabled.Value; ChargeTime = Rules.Seconds(Plugin.ChargeSeconds.Value, 6f, 3f, 15f); CooldownTime = Rules.Seconds(Plugin.CooldownSeconds.Value, 45f, 10f, 300f); } private bool AllClientsReady() { if ((Object)(object)network == (Object)null || !network.IsServer) { return false; } foreach (ulong connectedClientsId in network.ConnectedClientsIds) { if (!compatible.Contains(connectedClientsId)) { return false; } } return true; } private void Bind(NetworkManager value) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown Unbind(); network = value; value.CustomMessagingManager.RegisterNamedMessageHandler("TeleporterOverdrive.Request.v1", new HandleNamedMessageDelegate(ReceiveRequest)); value.CustomMessagingManager.RegisterNamedMessageHandler("TeleporterOverdrive.State.v1", new HandleNamedMessageDelegate(ReceiveState)); value.CustomMessagingManager.RegisterNamedMessageHandler("TeleporterOverdrive.Event.v1", new HandleNamedMessageDelegate(ReceiveEvent)); value.CustomMessagingManager.RegisterNamedMessageHandler("TeleporterOverdrive.Reply.v1", new HandleNamedMessageDelegate(ReceiveReply)); value.OnClientDisconnectCallback += Disconnected; } private void Unbind() { if ((Object)(object)network == (Object)null) { return; } network.OnClientDisconnectCallback -= Disconnected; if (network.CustomMessagingManager != null) { string[] array = new string[4] { "TeleporterOverdrive.Request.v1", "TeleporterOverdrive.State.v1", "TeleporterOverdrive.Event.v1", "TeleporterOverdrive.Reply.v1" }; foreach (string text in array) { network.CustomMessagingManager.UnregisterNamedMessageHandler(text); } } } private void ResetSession() { HasState = (RelayOwned = (CrewReady = (initialized = (remoteBusy = false)))); ticket = null; extractionPad = null; terminal = null; session = null; compatible.Clear(); requestIds.Clear(); lastOrder.Clear(); nextHello = (nextDiscovery = (nextBroadcast = 0f)); lastCommit = -1; teleporters = Array.Empty<ShipTeleporter>(); TransitEffects.Reset(); } private void OnDestroy() { Cancel("Session ended.", refund: true); Unbind(); TransitEffects.CancelPriority(); } private void Disconnected(ulong id) { compatible.Remove(id); requestIds.Remove(id); lastOrder.Remove(id); if ((Object)(object)network != (Object)null && network.IsServer) { ExtractionTicket? extractionTicket = ticket; if (extractionTicket != null && extractionTicket.Target == id) { Cancel("The target disconnected.", refund: true); } } } internal ShipTeleporter? FindTeleporter(bool inverse) { ShipTeleporter[] array = teleporters; foreach (ShipTeleporter val in array) { if ((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled && val.isInverseTeleporter == inverse && (Object)(object)((NetworkBehaviour)val).NetworkObject != (Object)null && ((NetworkBehaviour)val).NetworkObject.IsSpawned) { return val; } } return null; } internal static PlayerControllerB? Player(ulong id) { if ((Object)(object)StartOfRound.Instance == (Object)null) { return null; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.actualClientId == id && val.isPlayerControlled) { return val; } } return null; } private static bool ValidTarget(PlayerControllerB? target) { if ((Object)(object)target != (Object)null && target.isPlayerControlled && !target.isPlayerDead && (Object)(object)target.redirectToEnemy == (Object)null && !target.isInHangarShipRoom) { return !target.isInElevator; } return false; } private bool AtTerminal(PlayerControllerB? buyer) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)buyer != (Object)null && !buyer.isPlayerDead && buyer.isInHangarShipRoom && (Object)(object)terminal != (Object)null) { return Vector3.Distance(((Component)buyer).transform.position, ((Component)terminal).transform.position) < 6f; } return false; } internal unsafe void Request(byte action, int quote, ulong target) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)network == (Object)null || !network.IsListening || !HasState) { TerminalCommands.Report("Waiting for the host."); return; } int id = ++requestId; if (network.IsServer) { Order(network.LocalClientId, id, action, quote, target); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1); try { byte b = 1; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref id, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref action, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref quote, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref target, default(ForPrimitives)); network.CustomMessagingManager.SendNamedMessage("TeleporterOverdrive.Request.v1", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void ReceiveRequest(ulong sender, FastBufferReader reader) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)network == (Object)null || !network.IsServer || ((FastBufferReader)(ref reader)).Length > 256 || !network.ConnectedClients.ContainsKey(sender)) { return; } try { byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); if (b == 0) { int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); if (num == 1) { compatible.Add(sender); if (initialized) { SendState(sender); } } } else if (compatible.Contains(sender)) { switch (b) { case 1: { int id2 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref id2, default(ForPrimitives)); byte action = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref action, default(ForPrimitives)); int quote = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref quote, default(ForPrimitives)); ulong targetId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref targetId, default(ForPrimitives)); Order(sender, id2, action, quote, targetId); break; } case 2: { int id = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref id, default(ForPrimitives)); ulong keptId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref keptId, default(ForPrimitives)); DropPose pose = ReadPose(ref reader); Commit(sender, id, keptId, pose); break; } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Ignored invalid teleporter request: " + ex.Message)); } } private void Order(ulong sender, int id, byte action, int quote, ulong targetId) { //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)network == (Object)null || !network.IsServer || (action != 1 && action != 2) || id <= 0 || (requestIds.TryGetValue(sender, out var value) && id <= value)) { return; } requestIds[sender] = id; if (lastOrder.TryGetValue(sender, out var value2) && Now - value2 < 0.4) { return; } lastOrder[sender] = Now; ReadHostConfig(); CrewReady = AllClientsReady(); PlayerControllerB buyer = Player(sender); PlayerControllerB val = Player(targetId); ShipTeleporter val2 = FindTeleporter(action == 1); int credits = ((!((Object)(object)terminal == (Object)null)) ? terminal.groupCredits : 0); string text = ((action == 1) ? Rules.PurchaseError(initialized && CrewReady, RelayAllowed, AtTerminal(buyer), (Object)(object)val2 != (Object)null, RelayOwned, quote, RelayPrice, credits) : Rules.ExtractionError(initialized && CrewReady, ExtractionAllowed, AtTerminal(buyer), (Object)(object)val2 != (Object)null, Landed, Busy, (Object)(object)val2 != (Object)null && TeleporterPatches.Cooldown(val2) > 0f, ValidTarget(val), (Object)(object)session != (Object)null && (Object)(object)session.mapScreen.targetedPlayer == (Object)(object)val, quote, ExtractPrice, credits)); if (text.Length != 0) { Reply(sender, text); return; } if (action == 2 && (Object)(object)val != (Object)null) { text = InventoryTransit.RetentionError(InventoryTransit.Held(val)); if (text.Length != 0) { Reply(sender, text); return; } } if ((Object)(object)terminal == (Object)null) { return; } if (action == 1) { try { if ((Object)(object)session != (Object)null && !session.isChallengeFile) { ES3File val3 = new ES3File(GameNetworkManager.Instance.currentSaveFileName); val3.Save<bool>("TeleporterOverdrive.InverseFlashlightRelay.v1", true); val3.Save<int>("GroupCredits", terminal.groupCredits - RelayPrice); val3.Sync(); } } catch (Exception ex) { Reply(sender, "Could not save the upgrade. No credits spent."); Plugin.Log.LogError((object)ex); return; } RelayOwned = true; ChangeCredits(-RelayPrice); Reply(sender, "INVERSE FLASHLIGHT RELAY INSTALLED\nOne standard/pro flashlight can now pass through the inverse teleporter. Permanent for this save."); SendState(); } else { extractionPad = val2; ticket = new ExtractionTicket(++sequence, sender, targetId, ExtractPrice, Now, ChargeTime, CooldownTime); ChangeCredits(-ticket.Paid); Reply(sender, "PRIORITY EXTRACTION AUTHORIZED\nTarget: " + val.playerUsername + "\n$" + ticket.Paid + " reserved. Keep the desired item in your hands. Target lock is charging."); StartPriority(ticket.Id, targetId, ticket.Started, ticket.ChargeSeconds); SendState(); Plugin.Log.LogInfo((object)("Priority extraction " + ticket.Id + " charging for player " + targetId + "; reserved " + ticket.Paid + " credits.")); } } private void ChangeCredits(int amount) { if (!((Object)(object)terminal == (Object)null)) { terminal.groupCredits = (int)Math.Max(0L, Math.Min(1000000000L, (long)terminal.groupCredits + (long)amount)); terminal.SyncGroupCreditsClientRpc(terminal.groupCredits, terminal.numberOfItemsInDropship); } } private unsafe void UpdateExtraction() { //IL_00b7: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) ExtractionTicket extractionTicket = ticket; if (extractionTicket == null) { return; } if (!Landed || (Object)(object)extractionPad == (Object)null || !((Behaviour)extractionPad).isActiveAndEnabled || !ValidTarget(Player(extractionTicket.Target)) || !CrewReady) { Cancel("Target or teleporter unavailable before extraction.", refund: true); } else if (extractionTicket.TimedOut(Now)) { Cancel("The target did not acknowledge extraction in time.", refund: true); } else { if (!extractionTicket.Prepare(Now)) { return; } if (extractionTicket.Target != network.LocalClientId) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { byte b = 1; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref extractionTicket.Id, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref extractionTicket.Target, default(ForPrimitives)); network.CustomMessagingManager.SendNamedMessage("TeleporterOverdrive.Event.v1", extractionTicket.Target, val, (NetworkDelivery)3); return; } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } PrepareLocal(extractionTicket.Id, extractionTicket.Target); } } private unsafe void PrepareLocal(int id, ulong targetId) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)network == (Object)null || network.LocalClientId != targetId) { return; } PlayerControllerB val = Player(targetId); if (!ValidTarget(val)) { return; } ulong keptId = InventoryTransit.Id(InventoryTransit.Held(val)); DropPose pose = DropPose.Capture(val); if (network.IsServer) { Commit(targetId, id, keptId, pose); return; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(128, (Allocator)2, -1); try { byte b = 2; ((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref id, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref keptId, default(ForPrimitives)); WritePose(val2, pose); network.CustomMessagingManager.SendNamedMessage("TeleporterOverdrive.Request.v1", 0uL, val2, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } } private unsafe void Commit(ulong sender, int id, ulong keptId, DropPose pose) { //IL_0083: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: 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) ExtractionTicket extractionTicket = ticket; if ((Object)(object)network == (Object)null || !network.IsServer || extractionTicket == null || extractionTicket.Id != id || extractionTicket.Target != sender || extractionTicket.Phase != ExtractionPhase.AwaitingOwner) { return; } PlayerControllerB val = Player(sender); if (!Landed || !AllClientsReady() || !ValidTarget(val) || (Object)(object)extractionPad == (Object)null || !((Behaviour)extractionPad).isActiveAndEnabled || !pose.ValidNear(((Component)val).transform.position) || InventoryTransit.Id(InventoryTransit.Held(val)) != keptId) { Cancel("The target or held item changed during the final lock. Try again.", refund: true); return; } string text = InventoryTransit.RetentionError(InventoryTransit.Held(val)); if (text.Length != 0) { Cancel(text, refund: true); return; } if (!extractionTicket.Complete(id, sender, Now)) { Cancel("The extraction acknowledgement arrived too late.", refund: true); return; } Vector3 position = extractionPad.teleporterPosition.position; ticket = null; TeleporterPatches.SetCooldown(extractionPad, extractionTicket.CooldownSeconds); FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(160, (Allocator)2, -1); try { byte b = 2; ((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref id, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref sender, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref keptId, default(ForPrimitives)); WritePose(val2, pose); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref position); ((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref extractionTicket.CooldownSeconds, default(ForPrimitives)); network.CustomMessagingManager.SendNamedMessageToAll("TeleporterOverdrive.Event.v1", val2, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } Execute(id, sender, keptId, pose, position, extractionTicket.CooldownSeconds); Reply(extractionTicket.Buyer, "EXTRACTION COMPLETE\n$" + extractionTicket.Paid + " spent. Only the actively held item was retained."); SendState(); } private void Execute(int id, ulong targetId, ulong keptId, DropPose pose, Vector3 destination, float cooldown) { //IL_00b2: 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_00e5: Unknown result type (might be due to invalid IL or missing references) if (id <= lastCommit) { return; } lastCommit = id; remoteBusy = false; PlayerControllerB val = Player(targetId); if ((Object)(object)val == (Object)null || val.isPlayerDead) { TransitEffects.CancelPriority(); return; } GrabbableObject val2 = null; if (keptId != ulong.MaxValue && (Object)(object)network != (Object)null && network.SpawnManager.SpawnedObjects.TryGetValue(keptId, out var value)) { val2 = ((Component)value).GetComponent<GrabbableObject>(); if ((Object)(object)val2 != (Object)null && !InventoryTransit.Contains(val, val2)) { val2 = null; } } try { InventoryTransit.DropExcept(val, val2, pose); val.isInElevator = true; val.isInHangarShipRoom = true; val.isInsideFactory = false; val.shipTeleporterId = -1; val.averageVelocity = 0f; val.velocityLastFrame = Vector3.zero; AudioReverbPresets val3 = Object.FindObjectOfType<AudioReverbPresets>(); if ((Object)(object)val3 != (Object)null && val3.audioPresets.Length > 3) { val3.audioPresets[3].ChangeAudioReverbForPlayer(val); } val.TeleportPlayer(destination, true, 160f, false, true); InventoryTransit.MoveRetainedItem(val, val2, intoShip: true); if (((NetworkBehaviour)val).IsOwner && (Object)(object)TimeOfDay.Instance != (Object)null) { TimeOfDay.Instance.SetInsideLightingDimness(false, true); } ShipTeleporter val4 = FindTeleporter(inverse: false); if ((Object)(object)val4 != (Object)null) { TeleporterPatches.SetCooldown(val4, cooldown); } TransitEffects.Arrive(val, val4); Plugin.Log.LogInfo((object)("Priority extraction " + id + " completed for player " + targetId + "; retained object " + keptId + ".")); } catch (Exception ex) { Plugin.Log.LogError((object)("Extraction execution failed: " + ex)); TransitEffects.CancelPriority(); } } private void StartPriority(int id, ulong targetId, double started, double duration) { remoteBusy = true; TransitEffects.Priority(id, Player(targetId), FindTeleporter(inverse: false), Math.Max(0.0, Now - started), duration); } private unsafe void Cancel(string reason, bool refund) { //IL_005c: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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) ExtractionTicket extractionTicket = ticket; if (extractionTicket != null && !((Object)(object)network == (Object)null) && network.IsServer) { ticket = null; int amount = extractionTicket.Cancel(); if (refund) { ChangeCredits(amount); } TransitEffects.CancelPriority(); remoteBusy = false; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { byte b = 3; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref extractionTicket.Id, default(ForPrimitives)); network.CustomMessagingManager.SendNamedMessageToAll("TeleporterOverdrive.Event.v1", val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } Reply(extractionTicket.Buyer, reason + (refund ? ("\nRefunded $" + amount + ".") : "\nOrder cancelled.")); SendState(); } } private unsafe void Reply(ulong buyer, string message) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)network == (Object)null) { return; } if (buyer == network.LocalClientId) { TerminalCommands.Report(message); } else if (network.ConnectedClients.ContainsKey(buyer)) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4096, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe(message, false); network.CustomMessagingManager.SendNamedMessage("TeleporterOverdrive.Reply.v1", buyer, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } } private void ReceiveReply(ulong sender, FastBufferReader reader) { if ((Object)(object)network == (Object)null || network.IsServer || sender != 0L || ((FastBufferReader)(ref reader)).Length > 4096) { return; } try { string message = default(string); ((FastBufferReader)(ref reader)).ReadValueSafe(ref message, false); TerminalCommands.Report(message); } catch (Exception ex) { Plugin.Log.LogWarning((object)ex.Message); } } private unsafe void SendState(ulong? destination = null) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00b8: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)network == (Object)null || !network.IsServer || !initialized) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1); try { int num = 1; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref RelayOwned, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref RelayAllowed, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref ExtractionAllowed, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref CrewReady, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref RelayPrice, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref ExtractPrice, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref ChargeTime, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref CooldownTime, default(ForPrimitives)); bool flag = ticket != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); num = ticket?.Id ?? (-1); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ulong num2 = (ulong)(((long?)ticket?.Target) ?? (-1L)); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref num2, default(ForPrimitives)); double num3 = ticket?.Started ?? 0.0; ((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref num3, default(ForPrimitives)); num3 = ticket?.ChargeSeconds ?? 0.0; ((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref num3, default(ForPrimitives)); if (destination.HasValue) { network.CustomMessagingManager.SendNamedMessage("TeleporterOverdrive.State.v1", destination.Value, val, (NetworkDelivery)3); } else { network.CustomMessagingManager.SendNamedMessageToAll("TeleporterOverdrive.State.v1", val, (NetworkDelivery)3); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void ReceiveState(ulong sender, FastBufferReader reader) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)network == (Object)null || network.IsServer || sender != 0L || ((FastBufferReader)(ref reader)).Length > 128) { return; } try { int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); if (num == 1) { ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref RelayOwned, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref RelayAllowed, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref ExtractionAllowed, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref CrewReady, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref RelayPrice, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref ExtractPrice, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref ChargeTime, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref CooldownTime, default(ForPrimitives)); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); ulong targetId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref targetId, default(ForPrimitives)); double started = default(double); ((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref started, default(ForPrimitives)); double duration = default(double); ((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref duration, default(ForPrimitives)); HasState = true; remoteBusy = flag; if (flag && num2 > lastCommit) { StartPriority(num2, targetId, started, duration); } else if (!flag) { TransitEffects.CancelPriority(); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Invalid host upgrade state: " + ex.Message)); } } private void ReceiveEvent(ulong sender, FastBufferReader reader) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)network == (Object)null || network.IsServer || sender != 0L || ((FastBufferReader)(ref reader)).Length > 256) { return; } try { byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); int id = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref id, default(ForPrimitives)); switch (b) { case 1: { ulong targetId2 = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref targetId2, default(ForPrimitives)); PrepareLocal(id, targetId2); break; } case 2: { ulong targetId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref targetId, default(ForPrimitives)); ulong keptId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref keptId, default(ForPrimitives)); DropPose pose = ReadPose(ref reader); Vector3 destination = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref destination); float cooldown = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref cooldown, default(ForPrimitives)); Execute(id, targetId, keptId, pose, destination, cooldown); break; } case 3: remoteBusy = false; TransitEffects.CancelPriority(); break; } } catch (Exception ex) { Plugin.Log.LogError((object)("Teleporter event failed: " + ex)); } } private static void WritePose(FastBufferWriter writer, DropPose pose) { ((FastBufferWriter)(ref writer)).WriteValueSafe(ref pose.Player); ((FastBufferWriter)(ref writer)).WriteValueSafe(ref pose.Hand); ((FastBufferWriter)(ref writer)).WriteValueSafe(ref pose.HandRotation); ((FastBufferWriter)(ref writer)).WriteValueSafe(ref pose.Eye); ((FastBufferWriter)(ref writer)).WriteValueSafe(ref pose.EyeRotation); } private static DropPose ReadPose(ref FastBufferReader reader) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_002c: Unknown result type (might be due to invalid IL or missing references) Vector3 player = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref player); Vector3 hand = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref hand); Vector3 handRotation = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref handRotation); Vector3 eye = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref eye); Vector3 eyeRotation = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref eyeRotation); return new DropPose(player, hand, handRotation, eye, eyeRotation); } private void LoadOwnership() { if ((Object)(object)session != (Object)null && session.isChallengeFile) { RelayOwned = false; return; } try { RelayOwned = ES3.Load<bool>("TeleporterOverdrive.InverseFlashlightRelay.v1", GameNetworkManager.Instance.currentSaveFileName, false); } catch (Exception ex) { RelayOwned = false; Plugin.Log.LogWarning((object)("Could not load relay ownership: " + ex.Message)); } } private static void SaveOwnership(bool value) { if ((Object)(object)StartOfRound.Instance != (Object)null && !StartOfRound.Instance.isChallengeFile) { ES3.Save<bool>("TeleporterOverdrive.InverseFlashlightRelay.v1", value, GameNetworkManager.Instance.currentSaveFileName); } } internal void BeforeSave() { if ((Object)(object)network == (Object)null || !network.IsServer || !initialized) { return; } Cancel("Session is being saved.", refund: true); try { SaveOwnership(RelayOwned); } catch (Exception ex) { Plugin.Log.LogWarning((object)ex.Message); } } internal void ResetCampaign() { if (!((Object)(object)network == (Object)null) && network.IsServer) { Cancel("The company reset this ship.", refund: false); RelayOwned = false; try { SaveOwnership(value: false); } catch (Exception ex) { Plugin.Log.LogWarning((object)ex.Message); } SendState(); } } } [HarmonyPatch] internal static class CampaignLifecycle { [HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")] [HarmonyPrefix] private static void Save() { if ((Object)(object)OverdriveRuntime.Instance != (Object)null) { OverdriveRuntime.Instance.BeforeSave(); } } [HarmonyPatch(typeof(GameNetworkManager), "ResetSavedGameValues")] [HarmonyPostfix] private static void Reset() { if ((Object)(object)OverdriveRuntime.Instance != (Object)null) { OverdriveRuntime.Instance.ResetCampaign(); } } } [BepInPlugin("sockpoop.teleporteroverdrive", "Teleporter Overdrive", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "sockpoop.teleporteroverdrive"; public const string Name = "Teleporter Overdrive"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<int> RelayCost; internal static ConfigEntry<int> ExtractionCost; internal static ConfigEntry<float> ChargeSeconds; internal static ConfigEntry<float> CooldownSeconds; internal static ConfigEntry<float> EffectsVolume; internal static ConfigEntry<bool> RelayEnabled; internal static ConfigEntry<bool> ExtractionEnabled; internal static ConfigEntry<bool> SoundEnabled; internal static ConfigEntry<bool> VisualsEnabled; internal static ConfigEntry<bool> CameraShake; private Harmony? harmony; private void Awake() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; RelayCost = ((BaseUnityPlugin)this).Config.Bind<int>("Host prices", "InverseFlashlightUpgradeCost", 650, new ConfigDescription("One-time price for this save. Requires an installed inverse teleporter. Host setting.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100000), Array.Empty<object>())); ExtractionCost = ((BaseUnityPlugin)this).Config.Bind<int>("Host prices", "PriorityExtractionCost", 500, new ConfigDescription("Credits per confirmed extraction. Requires a regular teleporter. Refunded if cancelled before commitment. Host setting.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100000), Array.Empty<object>())); RelayEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Host rules", "InverseFlashlightUpgradeEnabled", true, "Enable the purchasable flashlight relay. Disabling suspends its benefit without deleting ownership."); ExtractionEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Host rules", "PriorityExtractionEnabled", true, "Enable paid priority extraction through the terminal."); ChargeSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Host rules", "ExtractionChargeSeconds", 6f, new ConfigDescription("Target-lock buildup before extracting. The target remains vulnerable. Host setting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 15f), Array.Empty<object>())); CooldownSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Host rules", "ExtractionCooldownSeconds", 45f, new ConfigDescription("Regular teleporter cooldown after priority extraction. Host setting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 300f), Array.Empty<object>())); EffectsVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Local effects", "Volume", 0.65f, new ConfigDescription("Local volume of original capacitor, warning, and arrival sounds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); SoundEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Local effects", "SoundEffects", true, "Play the additional upgrade effects."); VisualsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Local effects", "VisualEffects", true, "Show smooth charging rings and the arrival light burst."); CameraShake = ((BaseUnityPlugin)this).Config.Bind<bool>("Local effects", "CameraShake", true, "Brief camera shake near the ship pad and for the extracted player."); InventoryTransit.ValidateHooks(); harmony = new Harmony("sockpoop.teleporteroverdrive"); harmony.PatchAll(typeof(TeleporterPatches)); harmony.PatchAll(typeof(TerminalCommands)); harmony.PatchAll(typeof(CampaignLifecycle)); ((Component)this).gameObject.AddComponent<OverdriveRuntime>(); if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig")) { try { ConfigMenu.Register(); } catch (Exception ex) { Log.LogWarning((object)("Optional config menu unavailable: " + ex.Message)); } } Log.LogInfo((object)"Teleporter Overdrive loaded. Terminal: TELEPORTER UPGRADES, FLASHLIGHT RELAY, PRIORITY EXTRACT. All players need this mod."); } private void OnDestroy() { Harmony? obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } internal enum LightKind { None, Flashlight, ProFlashlight } internal enum ExtractionPhase { Charging, AwaitingOwner, Completed, Cancelled } internal static class Rules { internal const ulong NoItem = ulong.MaxValue; internal const int Protocol = 1; internal const double ReplyTimeout = 8.0; internal static int Cost(int value) { return Math.Max(0, Math.Min(100000, value)); } internal static float Seconds(float value, float fallback, float minimum, float maximum) { if (!float.IsNaN(value) && !float.IsInfinity(value)) { return Math.Max(minimum, Math.Min(maximum, value)); } return fallback; } internal static int FlashlightSlot(LightKind[] inventory, int held) { if (held >= 0 && held < inventory.Length && inventory[held] != LightKind.None) { return held; } for (int i = 0; i < inventory.Length; i++) { if (inventory[i] == LightKind.ProFlashlight) { return i; } } for (int j = 0; j < inventory.Length; j++) { if (inventory[j] == LightKind.Flashlight) { return j; } } return -1; } internal static string PurchaseError(bool ready, bool enabled, bool buyerAtTerminal, bool inverseInstalled, bool purchased, int quote, int price, int credits) { if (!ready) { return "Waiting for compatible Teleporter Overdrive installations on every player."; } if (!enabled) { return "The host disabled the inverse flashlight upgrade."; } if (!buyerAtTerminal) { return "A living crew member must use the ship terminal."; } if (!inverseInstalled) { return "Install an Inverse Teleporter before purchasing the flashlight relay."; } if (purchased) { return "The Inverse Flashlight Relay is already installed for this save."; } if (quote != price) { return "The host changed the price. Request a new quote."; } if (credits < price) { return "Not enough group credits."; } return string.Empty; } internal static string ExtractionError(bool ready, bool enabled, bool buyerAtTerminal, bool teleporterInstalled, bool landed, bool busy, bool coolingDown, bool validTarget, bool sameTarget, int quote, int price, int credits) { if (!ready) { return "Waiting for compatible Teleporter Overdrive installations on every player."; } if (!enabled) { return "The host disabled priority extraction."; } if (!buyerAtTerminal) { return "A living crew member must use the ship terminal."; } if (!teleporterInstalled) { return "Install a regular Teleporter before ordering priority extraction."; } if (!landed) { return "Priority extraction is only available while the ship is landed."; } if (busy) { return "A priority extraction is already charging."; } if (coolingDown) { return "The teleporter is recharging. Try again when its cooldown ends."; } if (!validTarget) { return "Select a living crew member outside the ship on the radar monitor."; } if (!sameTarget) { return "The radar target changed. Request a new quote."; } if (quote != price) { return "The host changed the price. Request a new quote."; } if (credits < price) { return "Not enough group credits."; } return string.Empty; } } internal sealed class ExtractionTicket { internal readonly int Id; internal readonly ulong Buyer; internal readonly ulong Target; internal readonly int Paid; internal readonly double Started; internal readonly double ChargeSeconds; internal readonly float CooldownSeconds; internal ExtractionPhase Phase { get; private set; } internal ExtractionTicket(int id, ulong buyer, ulong target, int paid, double started, double charge, float cooldown) { Id = id; Buyer = buyer; Target = target; Paid = Rules.Cost(paid); Started = started; ChargeSeconds = charge; CooldownSeconds = cooldown; } internal bool Prepare(double now) { if (Phase != ExtractionPhase.Charging || now < Started + ChargeSeconds) { return false; } Phase = ExtractionPhase.AwaitingOwner; return true; } internal bool TimedOut(double now) { if (Phase == ExtractionPhase.AwaitingOwner) { return now > Started + ChargeSeconds + 8.0; } return false; } internal bool Complete(int id, ulong sender, double now) { if (Phase != ExtractionPhase.AwaitingOwner || id != Id || sender != Target || TimedOut(now)) { return false; } Phase = ExtractionPhase.Completed; return true; } internal int Cancel() { if (Phase == ExtractionPhase.Completed || Phase == ExtractionPhase.Cancelled) { return 0; } Phase = ExtractionPhase.Cancelled; return Paid; } } internal static class Soundscape { internal const int SampleRate = 24000; internal static float[] Charge(double duration, bool inverse) { duration = Math.Max(1.0, Math.Min(15.0, duration)); float[] array = new float[(int)(24000.0 * duration)]; double num = 0.0; double num2 = 0.0; double num3 = 0.0; uint num4 = 1897840862u; for (int i = 0; i < array.Length; i++) { double num5 = (double)i / 24000.0; double num6 = num5 / duration; num += Math.PI * 2.0 * (inverse ? (120.0 + 520.0 * num6 * num6) : (65.0 + 760.0 * num6 * num6 * num6)) / 24000.0; num2 += Math.PI * 2.0 * (42.0 + 26.0 * num6) / 24000.0; num4 = num4 * 1664525 + 1013904223; double num7 = (double)num4 / 4294967295.0 * 2.0 - 1.0; num3 += 0.09 * (num7 - num3); double num8 = 0.15 * Math.Sin(num2) + 0.08 * Math.Sin(num2 * 1.997); double num9 = (0.05 + 0.15 * num6) * (Math.Sin(num) + 0.3 * Math.Sin(num * 2.01)); double num10 = num3 * (0.3 + 0.9 * num6); double num11 = (inverse ? 0.0 : (0.09 * Math.Sin(Math.PI * 870.0 * num5) * Math.Pow(0.5 + 0.5 * Math.Sin(6.911503837897546 * num5), 4.0))); double num12 = Math.Min(1.0, num5 / 0.12) * Math.Min(1.0, (duration - num5) / 0.08); array[i] = (float)(Math.Tanh((num8 + num9 + num10 + num11) * 1.25) * 0.72 * num12); } array[0] = (array[^1] = 0f); return array; } internal static float[] Arrival() { float[] array = new float[43200]; uint num = 45131u; double num2 = 0.0; double num3 = 0.0; for (int i = 0; i < array.Length; i++) { double num4 = (double)i / 24000.0; num = num * 1664525 + 1013904223; num2 += 0.16 * ((double)num / 4294967295.0 * 2.0 - 1.0 - num2); num3 += Math.PI * 2.0 * (42.0 + 125.0 * Math.Exp((0.0 - num4) * 10.0)) / 24000.0; double num5 = 0.45 * Math.Sin(num3) * Math.Exp((0.0 - num4) * 3.5); double num6 = num2 * 1.4 * Math.Exp((0.0 - num4) * 7.0); double num7 = 0.12 * Math.Sin(Math.PI * 1480.0 * num4) * Math.Exp((0.0 - num4) * 4.0); double num8 = Math.Min(1.0, num4 / 0.008) * Math.Min(1.0, (1.8 - num4) / 0.12); array[i] = (float)(Math.Tanh(num5 + num6 + num7) * 0.8 * num8); } array[0] = (array[^1] = 0f); return array; } } [HarmonyPatch] internal static class TeleporterPatches { internal sealed class InverseScope { internal readonly PlayerControllerB Player; internal readonly GrabbableObject? Kept; internal InverseScope(PlayerControllerB player) { Player = player; Kept = InventoryTransit.Flashlight(player); } } private static readonly FieldInfo CooldownField = AccessTools.Field(typeof(ShipTeleporter), "cooldownTime"); [ThreadStatic] private static InverseScope? inverse; internal static float Cooldown(ShipTeleporter teleporter) { return (float)CooldownField.GetValue(teleporter); } internal static void SetCooldown(ShipTeleporter teleporter, float seconds) { CooldownField.SetValue(teleporter, seconds); teleporter.buttonTrigger.interactable = false; } [HarmonyPatch(typeof(ShipTeleporter), "TeleportPlayerOutWithInverseTeleporter")] [HarmonyPrefix] private static void InverseBegin(int playerObj, out InverseScope? __state) { __state = inverse; inverse = null; if (OverdriveRuntime.RelayActive && !((Object)(object)StartOfRound.Instance == (Object)null)) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; if (playerObj >= 0 && playerObj < allPlayerScripts.Length && !((Object)(object)allPlayerScripts[playerObj] == (Object)null) && !allPlayerScripts[playerObj].isPlayerDead) { inverse = new InverseScope(allPlayerScripts[playerObj]); } } } [HarmonyPatch(typeof(ShipTeleporter), "TeleportPlayerOutWithInverseTeleporter")] [HarmonyPostfix] private static void InverseFinished() { if (inverse != null) { InventoryTransit.MoveRetainedItem(inverse.Player, inverse.Kept, intoShip: false); } } [HarmonyPatch(typeof(ShipTeleporter), "TeleportPlayerOutWithInverseTeleporter")] [HarmonyFinalizer] private static Exception? InverseEnd(Exception? __exception, InverseScope? __state) { inverse = __state; return __exception; } [HarmonyPatch(typeof(PlayerControllerB), "DropAllHeldItems")] [HarmonyPrefix] [HarmonyPriority(800)] private static bool SelectiveInverseDrop(PlayerControllerB __instance, bool itemsFall, bool disconnecting) { if (inverse == null || (Object)(object)inverse.Player != (Object)(object)__instance || disconnecting || !itemsFall || __instance.isPlayerDead) { return true; } InventoryTransit.DropExcept(__instance, inverse.Kept, DropPose.Capture(__instance)); return false; } [HarmonyPatch(typeof(ShipTeleporter), "PressTeleportButtonServerRpc")] [HarmonyPrefix] private static bool PreventConcurrentUse(ShipTeleporter __instance) { if (!__instance.isInverseTeleporter && !((Object)(object)OverdriveRuntime.Instance == (Object)null)) { return !OverdriveRuntime.Instance.Busy; } return true; } [HarmonyPatch(typeof(ShipTeleporter), "Update")] [HarmonyPostfix] private static void ChargingButton(ShipTeleporter __instance) { if (!__instance.isInverseTeleporter && !((Object)(object)OverdriveRuntime.Instance == (Object)null) && OverdriveRuntime.Instance.Busy) { SetCooldown(__instance, Math.Max(0.2f, Cooldown(__instance))); __instance.buttonTrigger.disabledHoverTip = "[Priority extraction charging]"; } } [HarmonyPatch(typeof(ShipTeleporter), "PressButtonEffects")] [HarmonyPostfix] private static void EnhancedInverse(ShipTeleporter __instance) { if (__instance.isInverseTeleporter && OverdriveRuntime.RelayActive && !((Object)(object)StartOfRound.Instance == (Object)null) && !StartOfRound.Instance.inShipPhase && !((Object)(object)RoundManager.Instance == (Object)null) && !RoundManager.Instance.dungeonIsGenerating && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap) { TransitEffects.Inverse(__instance); } } } [HarmonyPatch] internal static class TerminalCommands { private const string OrderEvent = "TeleporterOverdrive.Order"; private static Terminal? terminal; private static TerminalNode? quoteNode; private static byte action; private static int quotedPrice; private static ulong target; private static string? reply; internal static string Normalize(string value) { return Regex.Replace(value.Trim().ToLowerInvariant(), "\\s+", " "); } internal static byte ParseAction(string value) { switch (value) { default: return 0; case "priority extract": case "extract": case "priority extraction": return 2; case "flashlight relay": case "buy flashlight relay": case "inverse upgrade": return 1; } } private static TerminalNode Node(string title, string text, string terminalEvent = "") { TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)obj).name = "TeleporterOverdrive." + title; obj.displayText = text + "\n\n"; obj.clearPreviousText = true; obj.maxCharactersToType = 60; obj.terminalEvent = terminalEvent; return obj; } [HarmonyPatch(typeof(Terminal), "Awake")] [HarmonyPostfix] private static void Awake(Terminal __instance) { terminal = __instance; quoteNode = null; reply = null; } [HarmonyPatch(typeof(Terminal), "TextPostProcess")] [HarmonyPrefix] private static void Store(ref string modifiedDisplayText) { if (modifiedDisplayText.Contains("[buyableItemsList]")) { modifiedDisplayText = modifiedDisplayText + "\nTELEPORTER OVERDRIVE\n* Inverse Flashlight Relay // " + (OverdriveRuntime.RelayOwned ? "INSTALLED" : ("$" + OverdriveRuntime.RelayPrice + " permanent upgrade")) + "\n Type FLASHLIGHT RELAY\n* Priority Extraction // $" + OverdriveRuntime.ExtractPrice + " per use\n Type PRIORITY EXTRACT\n"; } } [HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")] [HarmonyPrefix] private static bool Parse(Terminal __instance, ref TerminalNode __result) { terminal = __instance; string text = __instance.screenText.text; int num = Math.Max(0, Math.Min(__instance.textAdded, text.Length)); string text2 = Normalize(text.Substring(text.Length - num)); if ((Object)(object)quoteNode != (Object)null && (Object)(object)__instance.currentNode == (Object)(object)quoteNode) { switch (text2) { case "confirm": case "c": quoteNode = null; __result = Node("Pending", "Contacting teleporter control...", "TeleporterOverdrive.Order"); return false; case "deny": case "d": case "cancel": quoteNode = null; __result = Node("Cancelled", "Order cancelled. No credits spent."); return false; } } switch (text2) { case "teleporter upgrades": case "overdrive": case "teleporter overdrive": __result = Node("Help", "TELEPORTER OVERDRIVE\n\nFLASHLIGHT RELAY: $" + OverdriveRuntime.RelayPrice + " once per save. Requires an inverse teleporter. Keep one standard/pro flashlight, including from a reserved slot. Every other item stays behind.\n\nPRIORITY EXTRACT: $" + OverdriveRuntime.ExtractPrice + " each time. Requires a regular teleporter. Select a living crew member on the radar, then confirm the order. Only their actively held item at extraction is saved. Pocketed items stay behind.\n\nThe target remains vulnerable while charging. Interrupted orders refund before extraction commits."); return false; default: { byte b = ParseAction(text2); if (b == 0) { return true; } if (!OverdriveRuntime.HasState) { __result = Node("Syncing", "Waiting for the host's upgrade settings."); return false; } action = b; quotedPrice = ((action == 1) ? OverdriveRuntime.RelayPrice : OverdriveRuntime.ExtractPrice); PlayerControllerB val = StartOfRound.Instance?.mapScreen?.targetedPlayer; target = (((Object)(object)val == (Object)null) ? ulong.MaxValue : val.actualClientId); string text3 = ((action == 1) ? ("INVERSE FLASHLIGHT RELAY\n\nPermanent for this save: $" + quotedPrice + "\nRequires an installed Inverse Teleporter.\nPreserves ONE standard or pro flashlight. All other inventory is dropped.\n") : ("PRIORITY EXTRACTION\n\nTarget: " + (((Object)(object)val == (Object)null) ? "NO CREW TARGET" : val.playerUsername) + "\nOne extraction: $" + quotedPrice + "\nCharge: " + OverdriveRuntime.ChargeTime.ToString("0.0") + " seconds\nKeep: ONLY the item in their hands when extraction commits. All pocketed items stay behind.\n\nThe target is locked when confirmed. They remain vulnerable while charging.\n")); quoteNode = Node("Confirm", text3 + "\nSpend group credits? CONFIRM or DENY."); __result = quoteNode; return false; } } } [HarmonyPatch(typeof(Terminal), "RunTerminalEvents")] [HarmonyPostfix] private static void Events(TerminalNode node) { if (node.terminalEvent == "TeleporterOverdrive.Order") { OverdriveRuntime.Instance.Request(action, quotedPrice, target); } } internal static void Report(string message) { reply = message; } internal static void Flush() { if (reply != null) { string text = reply; reply = null; if ((Object)(object)terminal != (Object)null && (Object)(object)terminal.currentNode != (Object)null && ((Object)terminal.currentNode).name.StartsWith("TeleporterOverdrive.", StringComparison.Ordinal)) { terminal.LoadNewNode(Node("Result", text)); } else if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip("Teleporter Overdrive", text, false, false, "LC_Tip1"); } } } } internal static class TransitEffects { private static readonly List<TransitField> priority = new List<TransitField>(); private static int playingId = -1; internal static void Priority(int id, PlayerControllerB? target, ShipTeleporter? pad, double elapsed, double duration) { if (playingId != id) { CancelPriority(); playingId = id; if ((Object)(object)pad != (Object)null) { Spawn(pad.teleporterPosition, inverse: false, arrival: false, duration, elapsed); } if ((Object)(object)target != (Object)null) { Spawn(((Component)target).transform, inverse: false, arrival: false, duration, elapsed, 0.65f); Tip(target, "PRIORITY EXTRACTION", "Keep the desired item in your hands. The ship is locking onto you."); } } } internal static void CancelPriority() { foreach (TransitField item in priority) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)((Component)item).gameObject); } } priority.Clear(); } internal static void Reset() { CancelPriority(); playingId = -1; } internal static void Inverse(ShipTeleporter pad) { Spawn(pad.teleportOutPosition, inverse: true, arrival: false, 5.0, 0.0); } internal static void Arrive(PlayerControllerB target, ShipTeleporter? pad) { CancelPriority(); Spawn(((Object)(object)pad != (Object)null) ? pad.teleporterPosition : ((Component)target).transform, inverse: false, arrival: true, 1.8, 0.0); Tip(target, "EXTRACTION COMPLETE", "Held item secured. Welcome aboard."); } private static void Spawn(Transform anchor, bool inverse, bool arrival, double duration, double elapsed, float radius = 1.1f) { try { TransitField item = TransitField.Create(anchor, inverse, arrival, duration, elapsed, radius); if (!inverse && !arrival) { priority.Add(item); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Optional teleporter effect unavailable: " + ex.Message)); } } private static void Tip(PlayerControllerB target, string title, string message) { try { if (((NetworkBehaviour)target).IsOwner && (Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip(title, message, false, false, "LC_Tip1"); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Teleporter notification unavailable: " + ex.Message)); } } } internal sealed class TransitField : MonoBehaviour { private readonly List<LineRenderer> rings = new List<LineRenderer>(); private Material? material; private AudioSource? audioSource; private AudioClip? clip; private Light? lightSource; private double started; private double duration; private bool arrival; private bool inverse; private bool shook; private float radius; private float gain; private Color color; internal static TransitField Create(Transform anchor, bool inverse, bool arrival, double duration, double elapsed, float radius = 1.1f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown GameObject val = new GameObject("TeleporterOverdrive.Field"); try { val.transform.SetParent(anchor, false); TransitField transitField = val.AddComponent<TransitField>(); transitField.Setup(inverse, arrival, duration, elapsed, radius); return transitField; } catch { Object.Destroy((Object)(object)val); throw; } } private void Setup(bool isInverse, bool isArrival, double length, double elapsed, float fieldRadius) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) inverse = isInverse; arrival = isArrival; radius = fieldRadius; gain = ((fieldRadius < 1f) ? 0.7f : 1f); duration = length; started = Time.realtimeSinceStartupAsDouble - elapsed; color = (inverse ? new Color(0.12f, 0.8f, 1f) : new Color(1f, 0.6f, 0.12f)); Shader val = Shader.Find("HDRP/Unlit") ?? Shader.Find("HDRP/Lit") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default"); if ((Object)(object)val != (Object)null) { material = new Material(val) { name = "Overdrive field glow" }; if (material.HasProperty("_UnlitColor")) { material.SetColor("_UnlitColor", color * 2f); } if (material.HasProperty("_Color")) { material.SetColor("_Color", color); } if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", color); } if (material.HasProperty("_EmissiveColor")) { material.SetColor("_EmissiveColor", color * 4f); } for (int i = 0; i < 3; i++) { LineRenderer val2 = new GameObject("Capacitor ring " + i).AddComponent<LineRenderer>(); ((Component)val2).transform.SetParent(((Component)this).transform, false); val2.useWorldSpace = false; val2.loop = true; ((Renderer)val2).sharedMaterial = material; val2.widthMultiplier = (arrival ? 0.065f : 0.025f); val2.positionCount = 96; Color startColor = (val2.endColor = color); val2.startColor = startColor; for (int j = 0; j < 96; j++) { float num = (float)j * (float)Math.PI * 2f / 96f; val2.SetPosition(j, new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num))); } rings.Add(val2); } } lightSource = ((Component)this).gameObject.AddComponent<Light>(); lightSource.type = (LightType)2; lightSource.color = color; lightSource.range = 5f; lightSource.intensity = 0f; if (elapsed < duration && Plugin.SoundEnabled.Value) { float[] array = (arrival ? Soundscape.Arrival() : Soundscape.Charge(duration, inverse)); clip = AudioClip.Create("Overdrive " + (arrival ? "discharge" : "capacitor"), array.Length, 1, 24000, false); clip.SetData(array, 0); audioSource = ((Component)this).gameObject.AddComponent<AudioSource>(); audioSource.clip = clip; audioSource.spatialBlend = 1f; audioSource.rolloffMode = (AudioRolloffMode)0; audioSource.minDistance = 2f; audioSource.maxDistance = (arrival ? 40 : 25); audioSource.volume = Plugin.EffectsVolume.Value * gain; audioSource.time = (float)Math.Max(0.0, Math.Min(elapsed, (double)clip.length - 0.02)); audioSource.Play(); } } private void Update() { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) double num = Time.realtimeSinceStartupAsDouble - started; float num2 = Mathf.Clamp01((float)(num / Math.Max(0.1, duration))); bool value = Plugin.VisualsEnabled.Value; for (int i = 0; i < rings.Count; i++) { LineRenderer obj = rings[i]; ((Renderer)obj).enabled = value; float num3 = (arrival ? (radius * (1f + num2 * 2f)) : (radius * (1f - num2 * 0.25f + 0.04f * Mathf.Sin((float)num * 4f + (float)i)))); ((Component)obj).transform.localScale = Vector3.one * num3; ((Component)obj).transform.localPosition = new Vector3(0f, 0.12f + (arrival ? ((float)i * 0.4f) : Mathf.Repeat(num2 * 1.6f + (float)i * 0.55f, 1.7f)), 0f); obj.widthMultiplier = (arrival ? (0.07f * (1f - num2)) : (0.018f + num2 * 0.025f)); } if ((Object)(object)lightSource != (Object)null) { lightSource.intensity = ((!value) ? 0f : (arrival ? (3f * (1f - num2) * (1f - num2)) : (0.2f + 0.8f * num2))); } if ((Object)(object)audioSource != (Object)null) { audioSource.volume = (Plugin.SoundEnabled.Value ? (Plugin.EffectsVolume.Value * gain) : 0f); } PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance == (Object)null) ? null : GameNetworkManager.Instance.localPlayerController); if (!shook && Plugin.CameraShake.Value && (Object)(object)val != (Object)null && (Object)(object)HUDManager.Instance != (Object)null && Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) < 8f && (arrival || num2 >= 0.85f)) { shook = true; HUDManager.Instance.ShakeCamera((ScreenShakeType)(arrival ? 1 : 0)); } if (num > duration + ((arrival || inverse) ? 0.0 : 8.0)) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void OnDestroy() { if ((Object)(object)audioSource != (Object)null) { audioSource.Stop(); } if ((Object)(object)clip != (Object)null) { Object.Destroy((Object)(object)clip); } if ((Object)(object)material != (Object)null) { Object.Destroy((Object)(object)material); } } } }