using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
using TerminalApi;
using TerminalApi.Classes;
using TerminalCommander.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Terminal Commander")]
[assembly: AssemblyDescription("Terminal Commander is a mod for Lethal Company designed to enhance your terminal operation experience by introducing convenient hotkeys. This mod simplifies various tasks, allowing you to manage turrets, landmines, player views, and communication more efficiently.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Tronal")]
[assembly: AssemblyProduct("Terminal Commander")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a339852b-b956-4a52-89e6-21f22b77c5cc")]
[assembly: AssemblyFileVersion("1.9.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.9.0.0")]
namespace TerminalCommander
{
public class AudioManager
{
public AudioClip jammerAudio = null;
public AudioClip emergencyAudio = null;
public AudioClip errorAudio = null;
private string jammerPath = Path.Combine(Paths.BepInExRootPath, "plugins", "TerminalCommander.Audio", "jammer.wav");
private string errorPath = Path.Combine(Paths.BepInExRootPath, "plugins", "TerminalCommander.Audio", "error.wav");
private string emergencyPath = Path.Combine(Paths.BepInExRootPath, "plugins", "TerminalCommander.Audio", "emergency.wav");
public void LoadAudio()
{
Debug.Log((object)("Loading " + jammerPath));
LoadAudio(AudioItem.Jammer);
Debug.Log((object)("Loading " + errorPath));
LoadAudio(AudioItem.Error);
Debug.Log((object)("Loading " + emergencyPath));
LoadAudio(AudioItem.Emergency);
}
private async void LoadAudio(AudioItem t)
{
UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip(getAudioPath(t), (AudioType)20);
try
{
uwr.SendWebRequest();
while (!uwr.isDone)
{
}
if (uwr.error != null)
{
Debug.LogError((object)uwr.error);
return;
}
switch (t)
{
case AudioItem.Jammer:
jammerAudio = DownloadHandlerAudioClip.GetContent(uwr);
break;
case AudioItem.Emergency:
emergencyAudio = DownloadHandlerAudioClip.GetContent(uwr);
break;
case AudioItem.Error:
errorAudio = DownloadHandlerAudioClip.GetContent(uwr);
break;
}
}
finally
{
((IDisposable)uwr)?.Dispose();
}
}
private string getAudioPath(AudioItem t)
{
return t switch
{
AudioItem.Jammer => jammerPath,
AudioItem.Emergency => emergencyPath,
AudioItem.Error => errorPath,
_ => null,
};
}
}
public enum AudioItem
{
Jammer,
Emergency,
Error
}
[Serializable]
public class TerminalCommanderConfiguration
{
public bool SyncHost { get; set; } = true;
public bool AllowJamming { get; set; } = true;
public bool AllowBigDoors { get; set; } = true;
public bool AllowEmergencyTeleporter { get; set; } = true;
public int JammingCoolDown { get; set; } = 0;
public int BigDoorsCoolDown { get; set; } = 0;
public KeyCode JammingKey { get; set; } = (KeyCode)106;
public KeyCode DoorKey { get; set; } = (KeyCode)100;
public KeyCode SwitchKey { get; set; } = (KeyCode)115;
public KeyCode MonitorKey { get; set; } = (KeyCode)109;
public KeyCode TransmitKey { get; set; } = (KeyCode)116;
public KeyCode TeleportKey { get; set; } = (KeyCode)119;
public KeyCode InverseTeleportKey { get; set; } = (KeyCode)105;
public KeyCode EmergencyTeleportKey { get; set; } = (KeyCode)101;
public void Set_Configs(Commander c)
{
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: 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_023e: Unknown result type (might be due to invalid IL or missing references)
SyncHost = ((BaseUnityPlugin)c).Config.Bind<bool>("Gameplay", "Sync Host", true, "If true, host gameplay settings will sync with clients using Terminal Commander.").Value;
AllowJamming = ((BaseUnityPlugin)c).Config.Bind<bool>("Gameplay", "Allow jamming", true, "If false, removes turret and mine jamming ability.").Value;
AllowBigDoors = ((BaseUnityPlugin)c).Config.Bind<bool>("Gameplay", "Allow door control", true, "If false, removes ability to operate facility powered doors.").Value;
AllowEmergencyTeleporter = ((BaseUnityPlugin)c).Config.Bind<bool>("Gameplay", "Allow emergency teleport (experimental)", true, "If false, removes ability to emergency teleport everyone back to the ship.").Value;
JammingCoolDown = ((BaseUnityPlugin)c).Config.Bind<int>("Gameplay", "Jamming cool down", 0, "Cool down time in seconds before the same player can send another jamming signal.").Value;
BigDoorsCoolDown = ((BaseUnityPlugin)c).Config.Bind<int>("Gameplay", "Door control cool down", 0, "Cool down time in seconds before the same player can send another command to open / close all doors.").Value;
if (JammingCoolDown > 255)
{
JammingCoolDown = 255;
}
if (BigDoorsCoolDown > 255)
{
JammingCoolDown = 255;
}
JammingKey = ((BaseUnityPlugin)c).Config.Bind<KeyCode>("Key Binds", "Jamming (Ctrl+)", (KeyCode)106, (ConfigDescription)null).Value;
DoorKey = ((BaseUnityPlugin)c).Config.Bind<KeyCode>("Key Binds", "Open/Close facility doors (Ctrl+)", (KeyCode)100, (ConfigDescription)null).Value;
SwitchKey = ((BaseUnityPlugin)c).Config.Bind<KeyCode>("Key Binds", "Play switch on monitor (Ctrl+)", (KeyCode)115, (ConfigDescription)null).Value;
MonitorKey = ((BaseUnityPlugin)c).Config.Bind<KeyCode>("Key Binds", "Turn on/off monitor (Ctrl+)", (KeyCode)109, (ConfigDescription)null).Value;
TransmitKey = ((BaseUnityPlugin)c).Config.Bind<KeyCode>("Key Binds", "Start transmission (Ctrl+)", (KeyCode)116, (ConfigDescription)null).Value;
TeleportKey = ((BaseUnityPlugin)c).Config.Bind<KeyCode>("Key Binds", "Teleport (Ctrl+)", (KeyCode)119, (ConfigDescription)null).Value;
InverseTeleportKey = ((BaseUnityPlugin)c).Config.Bind<KeyCode>("Key Binds", "Inverse Teleport (Ctrl+)", (KeyCode)105, (ConfigDescription)null).Value;
EmergencyTeleportKey = ((BaseUnityPlugin)c).Config.Bind<KeyCode>("Key Binds", "Emergency Teleport (Ctrl+)", (KeyCode)101, (ConfigDescription)null).Value;
}
public void Set_Configs(string hostConfigString)
{
Regex regex = new Regex("tsync[0,1][0,1][0,1]:\\d+:\\d+");
if (regex.IsMatch(hostConfigString))
{
string[] array = hostConfigString.Replace("tsync", "").Split(new char[1] { ':' });
AllowJamming = Convert.ToBoolean(Convert.ToInt16(array[0][0].ToString()));
AllowBigDoors = Convert.ToBoolean(Convert.ToInt16(array[0][1].ToString()));
AllowEmergencyTeleporter = Convert.ToBoolean(Convert.ToInt16(array[0][2].ToString()));
JammingCoolDown = Convert.ToInt32(array[1]);
BigDoorsCoolDown = Convert.ToInt32(array[2]);
}
}
public string SyncMessage()
{
int num = (AllowJamming ? 1 : 0);
int num2 = (AllowBigDoors ? 1 : 0);
int num3 = (AllowEmergencyTeleporter ? 1 : 0);
return $"tsync{num}{num2}{num3}:{JammingCoolDown}:{BigDoorsCoolDown}";
}
}
[BepInPlugin("Tronald.TerminalCommander", "TerminalCommander", "1.9.0")]
public class Commander : BaseUnityPlugin
{
public const string modGUID = "Tronald.TerminalCommander";
public const string modName = "TerminalCommander";
public const string modVersion = "1.9.0";
private readonly Harmony harmony = new Harmony("Tronald.TerminalCommander");
private static Commander instance;
public TerminalCommanderConfiguration Configs = new TerminalCommanderConfiguration();
public bool StartOfRound = true;
public DateTime LastJamEvent = default(DateTime);
public DateTime LastDoorEvent = default(DateTime);
public bool EmergencyTPUsed = false;
internal ManualLogSource log;
public AudioManager Audio;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
log = Logger.CreateLogSource("Tronald.TerminalCommander");
log.LogInfo((object)"TerminalCommander is loaded!");
Configs.Set_Configs(this);
TerminalHotkeys.SetSource(this);
TerminalCommands.SetSource(this);
RoundManagerPatch.SetSource(this);
ChatManagerPatch.SetSource(this);
Audio = new AudioManager();
Audio.LoadAudio();
harmony.PatchAll(typeof(Commander));
harmony.PatchAll(typeof(TerminalHotkeys));
harmony.PatchAll(typeof(TerminalCommands));
harmony.PatchAll(typeof(RoundManagerPatch));
harmony.PatchAll(typeof(ChatManagerPatch));
}
}
}
namespace TerminalCommander.Patches
{
[HarmonyPatch(typeof(HUDManager))]
internal class ChatManagerPatch
{
private static ManualLogSource logSource;
private static Commander commanderSource;
public static string EmergencyTpMessage = "Emergency Teleport Started...";
public static void SetSource(Commander source)
{
commanderSource = source;
logSource = commanderSource.log;
}
[HarmonyPatch("AddChatMessage")]
[HarmonyPostfix]
private static void SyncConfigs(string chatMessage, string nameOfUserWhoTyped = "")
{
try
{
if (nameOfUserWhoTyped == "" && chatMessage.StartsWith("tsync") && !((NetworkBehaviour)RoundManager.Instance).IsHost)
{
logSource.LogInfo((object)("Syncing host configurations " + chatMessage));
commanderSource.Configs.Set_Configs(chatMessage.Trim());
}
if (nameOfUserWhoTyped == "" && chatMessage == EmergencyTpMessage)
{
logSource.LogInfo((object)"Setting emergency TP used.");
commanderSource.EmergencyTPUsed = true;
}
}
catch (Exception ex)
{
logSource.LogError((object)("Sync Config Error: " + ex.Message));
}
}
}
internal class EmergencyTeleporter : MonoBehaviour
{
public void StartTeleporter(Commander commanderSource, Terminal terminal, ShipTeleporter teleporter)
{
((MonoBehaviour)this).StartCoroutine(Teleport(commanderSource, terminal, teleporter));
}
private IEnumerator Teleport(Commander commanderSource, Terminal terminal, ShipTeleporter teleporter)
{
commanderSource.log.LogInfo((object)$"Gathering radar targets {StartOfRound.Instance.mapScreen.radarTargets.Count}");
List<PlayerControllerB> tped = new List<PlayerControllerB>();
terminal.terminalAudio.PlayOneShot(commanderSource.Audio.emergencyAudio);
for (int pcount = 0; pcount < StartOfRound.Instance.mapScreen.radarTargets.Count; pcount++)
{
StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(pcount);
yield return (object)new WaitForSeconds(0.035f);
PlayerControllerB player = StartOfRound.Instance.mapScreen.targetedPlayer;
if (!tped.Contains(player))
{
commanderSource.log.LogInfo((object)$"TP {player.playerUsername} - {!player.isInHangarShipRoom} {!player.isInElevator}");
if (!player.isInHangarShipRoom && !player.isInElevator)
{
teleporter.PressTeleportButtonOnLocalClient();
}
tped.Add(player);
yield return (object)new WaitForSeconds(5f);
}
}
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch
{
private static ManualLogSource logSource;
private static Commander commanderSource;
public static void SetSource(Commander source)
{
commanderSource = source;
logSource = commanderSource.log;
}
[HarmonyPatch("SetLevelObjectVariables")]
[HarmonyPostfix]
private static void ResetVariable()
{
try
{
if (commanderSource.Configs.SyncHost)
{
commanderSource.StartOfRound = true;
commanderSource.LastJamEvent = default(DateTime);
commanderSource.LastDoorEvent = default(DateTime);
commanderSource.EmergencyTPUsed = false;
if (((NetworkBehaviour)RoundManager.Instance).IsHost)
{
HUDManager.Instance.AddTextToChatOnServer(commanderSource.Configs.SyncMessage(), -1);
}
}
}
catch (Exception ex)
{
logSource.LogError((object)("ROUND MANAGER ERROR: " + ex.Message));
}
}
}
[HarmonyPatch(typeof(Terminal))]
internal class TerminalCommands
{
private static ManualLogSource logSource;
private static Commander commanderSource;
public static void SetSource(Commander source)
{
commanderSource = source;
logSource = commanderSource.log;
SetCommands();
}
private static void SetCommands()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
CommandInfo val = new CommandInfo();
val.Category = "help";
val.Description = "View the Terminal Commander hotkeys and commands.";
val.DisplayTextSupplier = OnHotKeyHelpCommand;
TerminalApi.AddCommand("Commander", val, (string)null, true);
val = new CommandInfo();
val.Category = "Commander";
val.DisplayTextSupplier = TeleportCommand;
TerminalApi.AddCommand("tp", val, (string)null, true);
val = new CommandInfo();
val.Category = "Commander";
val.DisplayTextSupplier = InverseTeleportCommand;
TerminalApi.AddCommand("itp", val, (string)null, true);
val = new CommandInfo();
val.Category = "Commander";
val.DisplayTextSupplier = EmergencyTeleportCommand;
TerminalApi.AddCommand("etp", val, (string)null, true);
}
private static string OnHotKeyHelpCommand()
{
return "HOTKEYS\n\n>Ctrl+D\nOpen / close all doors.\n\n>Ctrl+J\nJam all turrets and land mines.\n\n>Ctrl+M\nTurn monitor on and off.\n\n>Ctrl+S\nQuickly switch players on the monitor.\n\n>Ctrl+T\nBegin a signal transmission command.\n\nCOMMANDS\n\n>TP\nTeleport currently viewed player on monitor.\n\n>ITP\nActivate inverse teleporter.\n\n>ETP\nStart emergency teleport (experimental).\n\n";
}
public static string TeleportCommand()
{
ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
Terminal val = FindActiveObject<Terminal>();
if (array != null && array.Length != 0)
{
ShipTeleporter[] array2 = array;
foreach (ShipTeleporter val2 in array2)
{
if (!val2.isInverseTeleporter)
{
val2.PressTeleportButtonOnLocalClient();
return "Teleporting...\n\n";
}
}
}
val.terminalAudio.PlayOneShot(commanderSource.Audio.errorAudio);
return "Nuh uh, no teleporter\n\n";
}
public static string InverseTeleportCommand()
{
Terminal val = FindActiveObject<Terminal>();
ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
if (array != null && array.Length != 0)
{
ShipTeleporter[] array2 = array;
foreach (ShipTeleporter val2 in array2)
{
if (val2.isInverseTeleporter)
{
if (!StartOfRound.Instance.shipHasLanded)
{
return "Cannot inverse teleport until ship has fully landed and stabilized.\n\n";
}
FieldInfo field = ((object)val2).GetType().GetField("cooldownTime", BindingFlags.Instance | BindingFlags.NonPublic);
float num = (float)field.GetValue(val2);
if (num > 0f)
{
return $"Cooldown time for inverse teleporter: {Math.Round(num)} seconds.\n\n";
}
val2.PressTeleportButtonOnLocalClient();
return "Teleporting...\n\n";
}
}
}
val.terminalAudio.PlayOneShot(commanderSource.Audio.errorAudio);
return "Nuh uh, no inverse teleporter\n\n";
}
public static string EntranceTeleportCommand()
{
EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
if (array == null || array.Length == 0)
{
return "No inverse teleporter detected.\n\n";
}
EntranceTeleport val = array[0];
val.TeleportPlayer();
return "Teleporting...\n\n";
}
public static string EmergencyTeleportCommand()
{
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
Terminal val = FindActiveObject<Terminal>();
ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
if (array != null && array.Length != 0)
{
ShipTeleporter[] array2 = array;
foreach (ShipTeleporter val2 in array2)
{
if (!val2.isInverseTeleporter)
{
if (!StartOfRound.Instance.shipHasLanded)
{
val.terminalAudio.PlayOneShot(commanderSource.Audio.errorAudio);
return "Cannot emergency teleport until ship has fully landed and stabilized.\n\n";
}
if (commanderSource.EmergencyTPUsed)
{
val.terminalAudio.PlayOneShot(commanderSource.Audio.errorAudio);
return "Emergency teleport cannot be used again today.\n\n";
}
EmergencyTeleporter emergencyTeleporter = new GameObject().AddComponent<EmergencyTeleporter>();
emergencyTeleporter.StartTeleporter(commanderSource, val, val2);
HUDManager.Instance.AddTextToChatOnServer(ChatManagerPatch.EmergencyTpMessage, -1);
return "Emergency teleporting all players...\n\n";
}
}
}
val.terminalAudio.PlayOneShot(commanderSource.Audio.errorAudio);
return "Nuh uh, no teleporter\n\n";
}
private static T FindActiveObject<T>() where T : Object
{
T[] array = Object.FindObjectsOfType<T>();
if (array.Length != 0)
{
return array[0];
}
return default(T);
}
}
[HarmonyPatch(typeof(Terminal))]
internal class TerminalHotkeys
{
private static string turretName = "turretscript";
private static string landmineName = "landmine";
private static string doorName = "bigdoor";
private static bool openDoors = true;
private static ManualLogSource logSource;
private static Commander commanderSource;
public static void SetSource(Commander source)
{
commanderSource = source;
logSource = commanderSource.log;
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void HotKeyPatch(ref bool ___terminalInUse, ref TMP_InputField ___screenText)
{
//IL_0063: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: 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)
try
{
if ((___terminalInUse && UnityInput.Current.GetKey((KeyCode)306)) || UnityInput.Current.GetKey((KeyCode)305))
{
Terminal val = FindActiveObject<Terminal>();
if ((Object)(object)val == (Object)null)
{
logSource.LogInfo((object)"TerminalCommander ERROR: Terminal could not be found.");
}
if (UnityInput.Current.GetKeyDown(commanderSource.Configs.SwitchKey))
{
SwitchPlayer(val);
}
else if (UnityInput.Current.GetKeyDown(commanderSource.Configs.TransmitKey))
{
Transmission(val, ___screenText);
}
else if (UnityInput.Current.GetKeyDown(commanderSource.Configs.DoorKey))
{
OperateBigDoors(val);
}
else if (UnityInput.Current.GetKeyDown(commanderSource.Configs.JammingKey))
{
JamTurrentMines(val);
}
else if (UnityInput.Current.GetKeyDown(commanderSource.Configs.MonitorKey))
{
ViewMonitor(val);
}
else if (UnityInput.Current.GetKeyDown(commanderSource.Configs.TeleportKey))
{
SetTerminalText(val, TerminalCommands.TeleportCommand());
}
else if (UnityInput.Current.GetKeyDown(commanderSource.Configs.InverseTeleportKey))
{
SetTerminalText(val, TerminalCommands.InverseTeleportCommand());
}
else if (UnityInput.Current.GetKeyDown(commanderSource.Configs.EmergencyTeleportKey))
{
SetTerminalText(val, TerminalCommands.EmergencyTeleportCommand());
}
}
}
catch (Exception ex)
{
logSource.LogError((object)(ex.Message ?? ""));
}
}
private static void SwitchPlayer(Terminal t)
{
string text = "switch";
TMP_InputField screenText = t.screenText;
screenText.text += text;
t.textAdded = text.Length;
t.OnSubmit();
}
private static void Transmission(Terminal t, TMP_InputField ___screenText)
{
___screenText.text += "transmit ";
}
private static void OperateBigDoors(Terminal t)
{
DateTime dateTime = DateTime.Now.AddSeconds(-commanderSource.Configs.BigDoorsCoolDown);
if (!commanderSource.Configs.AllowBigDoors)
{
SetTerminalText(t, "This command has been disabled by the company.\n\n");
t.terminalAudio.PlayOneShot(commanderSource.Audio.errorAudio);
return;
}
if (dateTime < commanderSource.LastDoorEvent)
{
SetTerminalText(t, $"Door signal cool down time remaining: {Math.Round((commanderSource.LastDoorEvent - dateTime).TotalSeconds)} seconds.\n\n");
t.terminalAudio.PlayOneShot(commanderSource.Audio.errorAudio);
return;
}
TerminalAccessibleObject[] source = (from x in Object.FindObjectsOfType<TerminalAccessibleObject>()
select (x)).ToArray();
List<string> list = new List<string>();
foreach (TerminalAccessibleObject item in source.Where((TerminalAccessibleObject x) => ((Object)x).name.ToLower().Contains(doorName)))
{
if (!item.isBigDoor)
{
return;
}
list.Add(item.objectCode);
item.SetDoorLocalClient(openDoors);
}
if (openDoors || commanderSource.StartOfRound)
{
SetTerminalText(t, "Opening all doors\n\n");
openDoors = false;
commanderSource.StartOfRound = false;
}
else
{
SetTerminalText(t, "Closing all doors\n\n");
openDoors = true;
}
t.terminalAudio.PlayOneShot(t.codeBroadcastSFX, 1f);
t.codeBroadcastAnimator.SetTrigger("display");
commanderSource.LastDoorEvent = DateTime.Now;
logSource.LogInfo((object)string.Format("{0} TerminalAccessibleObjects Called: Count{1} - ({2})", "TerminalCommander", source.Count(), string.Join(", ", list)));
}
private static void JamTurrentMines(Terminal t)
{
DateTime dateTime = DateTime.Now.AddSeconds(-commanderSource.Configs.JammingCoolDown);
if (!commanderSource.Configs.AllowJamming)
{
SetTerminalText(t, "This command has been disabled by the company.\n\n");
t.terminalAudio.PlayOneShot(commanderSource.Audio.errorAudio);
return;
}
if (dateTime < commanderSource.LastJamEvent)
{
SetTerminalText(t, $"Jammer cool down time remaining: {Math.Round((commanderSource.LastJamEvent - dateTime).TotalSeconds)} seconds.\n\n");
t.terminalAudio.PlayOneShot(commanderSource.Audio.errorAudio);
return;
}
TerminalAccessibleObject[] source = (from x in Object.FindObjectsOfType<TerminalAccessibleObject>()
select (x)).ToArray();
List<string> list = new List<string>();
foreach (TerminalAccessibleObject item in source.Where((TerminalAccessibleObject x) => ((Object)x).name.ToLower() == turretName || ((Object)x).name.ToLower() == landmineName))
{
list.Add(item.objectCode);
item.CallFunctionFromTerminal();
}
SetTerminalText(t, "Jamming turrets and land mines\n\n");
t.terminalAudio.PlayOneShot(commanderSource.Audio.jammerAudio);
t.terminalAudio.PlayOneShot(t.codeBroadcastSFX, 1f);
t.codeBroadcastAnimator.SetTrigger("display");
commanderSource.LastJamEvent = DateTime.Now;
logSource.LogInfo((object)string.Format("{0} TerminalAccessibleObjects Called: Count{1} - ({2})", "TerminalCommander", source.Count(), string.Join(", ", list)));
}
private static void ViewMonitor(Terminal t)
{
string text = "view monitor";
TMP_InputField screenText = t.screenText;
screenText.text += text;
t.textAdded = text.Length;
t.OnSubmit();
}
private static void SetTerminalText(Terminal t, string s)
{
TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
val.clearPreviousText = true;
val.acceptAnything = false;
val.displayText = s;
t.LoadNewNode(val);
t.screenText.ActivateInputField();
((Selectable)t.screenText).Select();
}
private static T FindActiveObject<T>() where T : Object
{
T[] array = Object.FindObjectsOfType<T>();
if (array.Length != 0)
{
return array[0];
}
return default(T);
}
}
}