Decompiled source of TerminalSay v1.0.0

TerminalSay.dll

Decompiled 7 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TerminalSay.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TerminalSay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TerminalSay")]
[assembly: AssemblyTitle("TerminalSay")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace TerminalSay
{
	[BepInPlugin("Toocanzs.TerminalSay", "TerminalSay", "1.0.0")]
	public class TerminalSay : BaseUnityPlugin
	{
		private const string modGUID = "Toocanzs.TerminalSay";

		private readonly Harmony harmony = new Harmony("Toocanzs.TerminalSay");

		private void Awake()
		{
			harmony.PatchAll(typeof(TerminalPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Toocanzs' TerminalSay activated.");
		}
	}
}
namespace TerminalSay.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		private static ManualLogSource logSource = Logger.CreateLogSource("TerminalSay");

		[HarmonyPatch("ParsePlayerSentence")]
		[HarmonyPrefix]
		private static void ParsePlayerSentence(ref Terminal __instance)
		{
			string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
			logSource.LogInfo((object)("Wrote `" + text + "` in terminal"));
			string[] array = text.Split(" ", StringSplitOptions.RemoveEmptyEntries);
			if (array.Length != 0 && array[0].ToLower() == "say" && text.Length > "say ".Length)
			{
				string text2 = text.Substring("say ".Length);
				logSource.LogInfo((object)("Saying `" + text2 + "`"));
				HUDManager.Instance.AddTextToChatOnServer(text2, (int)HUDManager.Instance.localPlayer.playerClientId);
				__instance.screenText.text = __instance.screenText.text.Substring(0, __instance.screenText.text.Length - __instance.textAdded);
			}
		}
	}
}