using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
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("TerminalColors")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TerminalColors")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9459ebaf-e3ed-4687-a13b-bcca1661bd3b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TerminalColors;
[BepInPlugin("com.n8bits.TerminalColors", "Terminal Colors", "1.0.3")]
public class TerminalColors : BaseUnityPlugin
{
public static ConfigEntry<string> color_cfg;
public static ConfigEntry<float> ship_light_brightness;
public static TextMeshProUGUI quota_txt;
public static ManualLogSource log;
private void Awake()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
log = Logger.CreateLogSource("Terminal Colors");
Harmony val = new Harmony("com.n8bits.TerminalColors");
val.PatchAll(typeof(TerminalPatches));
log.LogInfo((object)"Patched & Terminal Colors Plugin!");
}
public static string SetTerminalColor(string color)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_036a: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("Environment/HangarShip/Terminal/Canvas/");
if ((Object)(object)val != (Object)null)
{
log.LogInfo((object)"Found terminal canvas!");
}
TextMeshProUGUI[] componentsInChildren = val.GetComponentsInChildren<TextMeshProUGUI>(true);
if (componentsInChildren != null)
{
log.LogInfo((object)"Found text meshes!");
}
Light component = GameObject.Find("Environment/HangarShip/Terminal/terminalLight").GetComponent<Light>();
if ((Object)(object)component != (Object)null)
{
log.LogInfo((object)"Found terminal light!");
}
Color c = Color.green;
switch (color)
{
case "red":
c = Color.red;
LoopAndSetTerminalColor(componentsInChildren, component, c);
log.LogInfo((object)("Executed loop and set to " + ((object)(Color)(ref c)).ToString()));
return "Executed loop and set to " + ((object)(Color)(ref c)).ToString();
case "green":
c = Color.green;
LoopAndSetTerminalColor(componentsInChildren, component, c);
log.LogInfo((object)("Executed loop and set to " + ((object)(Color)(ref c)).ToString()));
return "Executed loop and set to " + ((object)(Color)(ref c)).ToString();
case "blue":
c = Color.blue;
LoopAndSetTerminalColor(componentsInChildren, component, c);
log.LogInfo((object)("Executed loop and set to " + ((object)(Color)(ref c)).ToString()));
return "Executed loop and set to " + ((object)(Color)(ref c)).ToString();
case "magenta":
c = Color.magenta;
LoopAndSetTerminalColor(componentsInChildren, component, c);
log.LogInfo((object)("Executed loop and set to " + ((object)(Color)(ref c)).ToString()));
return "Executed loop and set to " + ((object)(Color)(ref c)).ToString();
case "yellow":
c = Color.yellow;
LoopAndSetTerminalColor(componentsInChildren, component, c);
log.LogInfo((object)("Executed loop and set to " + ((object)(Color)(ref c)).ToString()));
return "Executed loop and set to " + ((object)(Color)(ref c)).ToString();
case "cyan":
c = Color.cyan;
LoopAndSetTerminalColor(componentsInChildren, component, c);
log.LogInfo((object)("Executed loop and set to " + ((object)(Color)(ref c)).ToString()));
return "Executed loop and set to " + ((object)(Color)(ref c)).ToString();
case "white":
c = Color.white;
LoopAndSetTerminalColor(componentsInChildren, component, c);
log.LogInfo((object)("Executed loop and set to " + ((object)(Color)(ref c)).ToString()));
return "Executed loop and set to " + ((object)(Color)(ref c)).ToString();
default:
return "Uhh, color no exist :(";
}
}
private static void LoopAndSetTerminalColor(TextMeshProUGUI[] tmeshes, Light tlight, Color c)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
log.LogInfo((object)"Executing LoopAndSet");
GameObject val = GameObject.Find("Environment/HangarShip/Terminal/Canvas/");
Canvas component = val.GetComponent<Canvas>();
component.pixelPerfect = true;
component.referencePixelsPerUnit = 10f;
GameObject val2 = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer/HeaderText");
TextMeshProUGUI component2 = val2.GetComponent<TextMeshProUGUI>();
((Graphic)component2).color = Color.yellow;
TextMeshProUGUI[] componentsInChildren = val.GetComponentsInChildren<TextMeshProUGUI>(true);
log.LogInfo((object)("Found " + componentsInChildren.Length + " TMPUGUI components under Terminal/Canvas"));
TextMeshProUGUI[] array = componentsInChildren;
foreach (TextMeshProUGUI val3 in array)
{
((Behaviour)val3).enabled = false;
((Graphic)val3).color = c;
tlight.color = c;
((Behaviour)val3).enabled = true;
}
}
}
public static class TerminalPatches
{
[HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")]
[HarmonyPostfix]
private static void HandleTP(Terminal __instance, TerminalNode __result)
{
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Expected O, but got Unknown
TerminalColors.log.LogInfo((object)"Executing ParsePlayerSentence Patch");
string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
string text2 = "No color set";
TerminalColors.log.LogInfo((object)"Detected ");
string text3 = text.ToLower();
string text4 = text3;
if (text4 == null)
{
return;
}
switch (text4.Length)
{
default:
return;
case 6:
switch (text4[1])
{
default:
return;
case 'g':
if (!(text4 == "tgreen"))
{
return;
}
text2 = TerminalColors.SetTerminalColor("green");
break;
case 'w':
if (!(text4 == "twhite"))
{
return;
}
text2 = TerminalColors.SetTerminalColor("white");
break;
}
break;
case 5:
switch (text4[1])
{
default:
return;
case 'b':
if (!(text4 == "tblue"))
{
return;
}
text2 = TerminalColors.SetTerminalColor("blue");
break;
case 'c':
if (!(text4 == "tcyan"))
{
return;
}
text2 = TerminalColors.SetTerminalColor("cyan");
break;
}
break;
case 4:
if (!(text4 == "tred"))
{
return;
}
text2 = TerminalColors.SetTerminalColor("red");
break;
case 8:
if (!(text4 == "tmagenta"))
{
return;
}
text2 = TerminalColors.SetTerminalColor("magenta");
break;
case 7:
if (!(text4 == "tyellow"))
{
return;
}
text2 = TerminalColors.SetTerminalColor("yellow");
break;
}
TerminalNode val = new TerminalNode();
val.displayText = text2;
val.clearPreviousText = true;
__result = val;
}
}