Decompiled source of Terminal Clock v1.0.6

BepInEx/plugins/TerminalClock.dll

Decompiled 7 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 TerminalApi.Events;
using UnityEngine;

[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.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("TerminalClock")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5afd40ebd6827491e1c7c10c5c31c950b7e830c0")]
[assembly: AssemblyProduct("TerminalClock")]
[assembly: AssemblyTitle("TerminalClock")]
[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 TerminalClock
{
	[HarmonyPatch(typeof(HUDManager))]
	public static class OnSetClock
	{
		[HarmonyPatch("SetClock")]
		[HarmonyPostfix]
		public static void SetClock(ref HUDManager __instance)
		{
			((TMP_Text)Plugin.ClockText).text = ((TMP_Text)__instance.clockNumber).text.Replace('\n', ' ');
		}
	}
	[BepInPlugin("atomic.terminalclock", "Terminal Clock", "1.0.5")]
	[BepInDependency("atomic.terminalapi", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static GameObject _clock;

		internal const string UNKOWNTIME = "??:?? ??";

		internal static ConfigEntry<bool> configDisplayUnkownTime;

		internal static TextMeshProUGUI ClockText => _clock.GetComponent<TextMeshProUGUI>();

		private void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			SetupConfig();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Terminal Clock is loaded!");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			Events.TerminalAwake += new TerminalEventHandler(OnTerminalAwake);
		}

		private void OnTerminalAwake(object sender, TerminalEventArgs e)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)e.Terminal).transform.parent.parent.Find("Canvas").Find("MainContainer");
			try
			{
				_clock = ((Component)val.Find("Clock")).gameObject;
			}
			catch
			{
				_clock = Object.Instantiate<GameObject>(((Component)val.Find("CurrentCreditsNum")).gameObject, val);
				((Object)_clock).name = "Clock";
				_clock.transform.localPosition = new Vector3(255f, 200.6003f, -1.0003f);
				_clock.transform.localScale = new Vector3(0.9f, 0.9f, 1f);
				((TMP_Text)ClockText).text = (configDisplayUnkownTime.Value ? "??:?? ??" : "");
			}
		}

		internal void SetupConfig()
		{
			configDisplayUnkownTime = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "displayUnknown", true, "Whether or not to show '??:??' when the time is unkown.");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TerminalClock";

		public const string PLUGIN_NAME = "TerminalClock";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace TerminalClock.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	public static class OnFillEndGameStats
	{
		[HarmonyPatch("FillEndGameStats")]
		[HarmonyPostfix]
		public static void FillEndGameStats()
		{
			((TMP_Text)Plugin.ClockText).text = (Plugin.configDisplayUnkownTime.Value ? "??:?? ??" : "");
		}
	}
}