using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalNetworkAPI;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("TerminalDisplaySync")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("TerminalDisplaySync")]
[assembly: AssemblyTitle("TerminalDisplaySync")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TerminalDisplaySync
{
internal class Networking
{
[PublicNetworkVariable]
public static LethalNetworkVariable<string> TerminalText = new LethalNetworkVariable<string>("terminaltext");
public static LethalServerMessage<string> TerminalServerMessage = new LethalServerMessage<string>("terminaltextmessage", (Action<string, ulong>)null);
public static LethalClientMessage<string> TerminalClientMessage = new LethalClientMessage<string>("terminaltextmessage", (Action<string>)null, (Action<string, ulong>)null);
internal static void Init()
{
TerminalText.OnValueChanged += OnTerminalTextChange;
TerminalServerMessage.OnReceived += OnTerminalTextMessageReceived;
}
private static void OnTerminalTextMessageReceived(string newText, ulong clientId)
{
if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
{
Plugin.logger.LogInfo((object)("Received new terminal text from client: " + newText));
TerminalText.Value = newText;
}
}
private static void OnTerminalTextChange(string newText)
{
Plugin.logger.LogInfo((object)("Received new terminal text: " + newText));
TerminalPatches.TerminalInstance.currentNode.clearPreviousText = true;
TerminalPatches.TerminalInstance.textAdded = 0;
TerminalPatches.TerminalInstance.currentText = newText;
TerminalPatches.TerminalInstance.screenText.text = newText;
TerminalPatches.TerminalInstance.screenText.caretPosition = 0;
}
}
[HarmonyPatch(typeof(Terminal))]
public class TerminalPatches
{
public static Terminal TerminalInstance;
[HarmonyPatch(typeof(Terminal), "Start")]
[HarmonyPostfix]
private static void StartPostfix(Terminal __instance)
{
if (((NetworkBehaviour)__instance).IsHost)
{
__instance.LoadNewNode(__instance.terminalNodes.specialNodes.First());
}
TerminalInstance = __instance;
}
[HarmonyPatch(typeof(Terminal), "LoadNewNode")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void LoadNewNodePostfix(Terminal __instance, TerminalNode node)
{
TerminalInstance = __instance;
Networking.TerminalClientMessage.SendServer(__instance.currentText);
Plugin.logger.LogInfo((object)("Sent new terminal text: " + __instance.currentText));
}
}
[BepInPlugin("TerminalDisplaySync", "TerminalDisplaySync", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource logger;
internal static Harmony harmony = new Harmony("TerminalDisplaySync");
private void Awake()
{
logger = ((BaseUnityPlugin)this).Logger;
harmony.PatchAll();
Networking.Init();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TerminalDisplaySync is loaded!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "TerminalDisplaySync";
public const string PLUGIN_NAME = "TerminalDisplaySync";
public const string PLUGIN_VERSION = "0.0.1";
}
}