Decompiled source of Lethal Quickchat v1.0.2

BepInEx/plugins/LethalQuickchat.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[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("LethalQuickchat")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A Quick Chat Mod For Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalQuickchat")]
[assembly: AssemblyTitle("LethalQuickchat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 LethalQuickchat
{
	[BepInPlugin("LethalQuickchat", "LethalQuickchat", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("LethalQuickchat");

		private static HUDManager HudManager;

		private static PlayerControllerB LocalPlayer;

		private static ConfigEntry<string> QC1;

		private static ConfigEntry<string> QC2;

		private static ConfigEntry<string> QC3;

		private static ConfigEntry<string> QC4;

		private static ConfigEntry<string> QC5;

		private static ConfigEntry<string> QC6;

		private static ConfigEntry<string> QC7;

		private static ConfigEntry<string> QC8;

		private static ConfigEntry<string> QC9;

		private static ConfigEntry<string> QC0;

		private static bool Active = true;

		private void ChecksumConfigEntrys()
		{
			if (QC1 == null)
			{
				QC1 = ((BaseUnityPlugin)this).Config.Bind<string>("QuickSpeak", "Chat1", "Dancing", (ConfigDescription)null);
			}
			if (QC2 == null)
			{
				QC2 = ((BaseUnityPlugin)this).Config.Bind<string>("QuickSpeak", "Chat2", "Look!", (ConfigDescription)null);
			}
			if (QC3 == null)
			{
				QC3 = ((BaseUnityPlugin)this).Config.Bind<string>("QuickSpeak", "Chat3", "Help!", (ConfigDescription)null);
			}
			if (QC4 == null)
			{
				QC4 = ((BaseUnityPlugin)this).Config.Bind<string>("QuickSpeak", "Chat4", "Monster!", (ConfigDescription)null);
			}
			if (QC5 == null)
			{
				QC5 = ((BaseUnityPlugin)this).Config.Bind<string>("QuickSpeak", "Chat5", "Corpse!", (ConfigDescription)null);
			}
			if (QC6 == null)
			{
				QC6 = ((BaseUnityPlugin)this).Config.Bind<string>("QuickSpeak", "Chat6", "Scrap!", (ConfigDescription)null);
			}
			if (QC7 == null)
			{
				QC7 = ((BaseUnityPlugin)this).Config.Bind<string>("QuickSpeak", "Chat7", "Gear!", (ConfigDescription)null);
			}
			if (QC8 == null)
			{
				QC8 = ((BaseUnityPlugin)this).Config.Bind<string>("QuickSpeak", "Chat8", "Money!", (ConfigDescription)null);
			}
			if (QC9 == null)
			{
				QC9 = ((BaseUnityPlugin)this).Config.Bind<string>("QuickSpeak", "Chat9", "Kill!", (ConfigDescription)null);
			}
			if (QC0 == null)
			{
				QC0 = ((BaseUnityPlugin)this).Config.Bind<string>("QuickSpeak", "Chat0", "Player!", (ConfigDescription)null);
			}
		}

		private static void ToggleActive()
		{
			Active = !Active;
			if (Active)
			{
				((TMP_Text)HudManager.deviceChangeText).text = "Quickchat Active";
			}
			else
			{
				((TMP_Text)HudManager.deviceChangeText).text = "Quickchat Inactive";
			}
			HudManager.deviceChangeAnimator.SetTrigger("display");
		}

		private void Awake()
		{
			ChecksumConfigEntrys();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalQuickchat is loaded!, 3 functions patched.");
			harmony.PatchAll(typeof(Plugin));
		}

		[HarmonyPatch(typeof(HUDManager), "OnEnable")]
		[HarmonyPostfix]
		private static void OnHUDEnable()
		{
			HudManager = HUDManager.Instance;
		}

		[HarmonyPatch(typeof(HUDManager), "OnDisable")]
		[HarmonyPostfix]
		private static void OnHUDDisable()
		{
			HudManager = null;
		}

		[HarmonyPatch(typeof(HUDManager), "Update")]
		[HarmonyPostfix]
		private static void HUDUpdate()
		{
			if (((ButtonControl)Keyboard.current[(Key)94]).wasPressedThisFrame)
			{
				ToggleActive();
			}
			if (!((Object)(object)HudManager == (Object)null) && Active)
			{
				LocalPlayer = GameNetworkManager.Instance.localPlayerController;
				if (((ButtonControl)Keyboard.current[(Key)41]).wasPressedThisFrame)
				{
					HudManager.AddTextToChatOnServer(QC1.Value, (int)LocalPlayer.playerClientId);
				}
				else if (((ButtonControl)Keyboard.current[(Key)42]).wasPressedThisFrame)
				{
					HudManager.AddTextToChatOnServer(QC2.Value, (int)LocalPlayer.playerClientId);
				}
				else if (((ButtonControl)Keyboard.current[(Key)43]).wasPressedThisFrame)
				{
					HudManager.AddTextToChatOnServer(QC3.Value, (int)LocalPlayer.playerClientId);
				}
				else if (((ButtonControl)Keyboard.current[(Key)44]).wasPressedThisFrame)
				{
					HudManager.AddTextToChatOnServer(QC4.Value, (int)LocalPlayer.playerClientId);
				}
				else if (((ButtonControl)Keyboard.current[(Key)45]).wasPressedThisFrame)
				{
					HudManager.AddTextToChatOnServer(QC5.Value, (int)LocalPlayer.playerClientId);
				}
				else if (((ButtonControl)Keyboard.current[(Key)46]).wasPressedThisFrame)
				{
					HudManager.AddTextToChatOnServer(QC6.Value, (int)LocalPlayer.playerClientId);
				}
				else if (((ButtonControl)Keyboard.current[(Key)47]).wasPressedThisFrame)
				{
					HudManager.AddTextToChatOnServer(QC7.Value, (int)LocalPlayer.playerClientId);
				}
				else if (((ButtonControl)Keyboard.current[(Key)48]).wasPressedThisFrame)
				{
					HudManager.AddTextToChatOnServer(QC8.Value, (int)LocalPlayer.playerClientId);
				}
				else if (((ButtonControl)Keyboard.current[(Key)49]).wasPressedThisFrame)
				{
					HudManager.AddTextToChatOnServer(QC9.Value, (int)LocalPlayer.playerClientId);
				}
				else if (((ButtonControl)Keyboard.current[(Key)50]).wasPressedThisFrame)
				{
					HudManager.AddTextToChatOnServer(QC0.Value, (int)LocalPlayer.playerClientId);
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalQuickchat";

		public const string PLUGIN_NAME = "LethalQuickchat";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}