Decompiled source of BetterTerminalColors v1.0.1

TermColor.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 HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[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("TermColor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Fancy Terminal Colors")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TermColor")]
[assembly: AssemblyTitle("TermColor")]
[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 TermColor
{
	[BepInPlugin("autumnnova.termcolor", "Terminal Colors", "1.0.0")]
	internal class Plugin : BaseUnityPlugin
	{
		internal static ConfigEntry<Vector4> Tcopreference { get; private set; }

		private void Awake()
		{
			//IL_0005: 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_0031: 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)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("autumnnova.termcolor").PatchAll(typeof(TCoPatch));
			Tcopreference = ((BaseUnityPlugin)this).Config.Bind<Vector4>("General", "Terminal Color", Color.op_Implicit(Color32.op_Implicit(default(Color32))), "RGB value to be autoset upon round start, Will be autoset via tcolor");
		}

		internal static void SetColor(Color c)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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)
			TextMeshProUGUI[] componentsInChildren = GameObject.Find("Environment/HangarShip/Terminal/Canvas/").GetComponentsInChildren<TextMeshProUGUI>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Graphic)componentsInChildren[i]).color = c;
			}
			GameObject.Find("Environment/HangarShip/Terminal/Canvas/MainContainer/Scroll View/Viewport/InputField (TMP)").GetComponent<TMP_InputField>().caretColor = c;
			GameObject.Find("Environment/HangarShip/Terminal/terminalLight").GetComponent<Light>().color = c;
		}
	}
	internal class TCoPatch
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPrefix]
		private static void StartPatch(ref StartOfRound __instance)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Color32 val = Color32.op_Implicit(Color.op_Implicit(Plugin.Tcopreference.Value));
			if (val.rgba != default(Color32).rgba)
			{
				val.a = byte.MaxValue;
				Plugin.SetColor(Color32.op_Implicit(val));
			}
		}

		[HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")]
		[HarmonyPostfix]
		private static void ColorPatch(Terminal __instance, ref TerminalNode __result)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00e3: 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)
			string[] array = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).ToLower().Split(" ");
			if (!(array[0] != "tcolor"))
			{
				if (array.Length < 4)
				{
					TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
					val.displayText = "Error: RGB value required after tcolor command\n (e.g tcolor 255 0 0 for red)\n\n";
					val.clearPreviousText = true;
					__result = val;
					return;
				}
				Color32 val2 = default(Color32);
				val2.r = (byte)Math.Clamp(int.Parse(array[1]), 0, 255);
				val2.g = (byte)Math.Clamp(int.Parse(array[2]), 0, 255);
				val2.b = (byte)Math.Clamp(int.Parse(array[3]), 0, 255);
				val2.a = byte.MaxValue;
				Color32 val3 = val2;
				Plugin.SetColor(Color32.op_Implicit(val3));
				Plugin.Tcopreference.Value = Color.op_Implicit(Color32.op_Implicit(val3));
				TerminalNode val4 = ScriptableObject.CreateInstance<TerminalNode>();
				val4.displayText = "Color Set!\n\n";
				val4.clearPreviousText = true;
				__result = val4;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TermColor";

		public const string PLUGIN_NAME = "TermColor";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}