Decompiled source of CyberTimer v1.1.2

Plugins/CyberTimer.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CyberTimer.Data;
using CyberTimer.Utilities;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CyberTimer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+470d633c9b682fcc20da9b9eb9e5885f498f882e")]
[assembly: AssemblyProduct("CyberTimer")]
[assembly: AssemblyTitle("CyberTimer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.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 CyberTimer
{
	[BepInPlugin("chair.mods.cybertimer", "CyberTimer", "1.1.2")]
	[BepInProcess("ULTRAKILL.exe")]
	public class CyberTimer : BaseUnityPlugin
	{
		public static ManualLogSource Logger;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin CyberTimer is loaded!");
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)4;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Font/vcr_osd_mono asset");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			CyberTimerVariables.VCR_OSD_MONO = val.LoadAsset<TMP_FontAsset>("VCR_OSD_MONO SDF");
		}

		private void Start()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("chair.mods.cybertimer");
			val.PatchAll();
			InstantiateTimerGUI();
		}

		public void InstantiateTimerGUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			CyberTimerVariables.CyberTimerCanvas = new GameObject("CyberTimerCanvas");
			Canvas val = CyberTimerVariables.CyberTimerCanvas.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 100;
			CanvasScaler val2 = CyberTimerVariables.CyberTimerCanvas.AddComponent<CanvasScaler>();
			val2.uiScaleMode = (ScaleMode)1;
			val2.referenceResolution = new Vector2(1920f, 1080f);
			GameObject val3 = new GameObject("TimerPanel");
			val3.transform.SetParent(CyberTimerVariables.CyberTimerCanvas.transform, false);
			RectTransform val4 = (CyberTimerVariables.GlobalRectTransform = val3.AddComponent<RectTransform>());
			val4.anchorMin = new Vector2(1f, 1f);
			val4.anchorMax = new Vector2(1f, 1f);
			val4.pivot = new Vector2(1f, 1f);
			val4.anchoredPosition = new Vector2(-5f, -5f);
			val4.sizeDelta = new Vector2(375f, 125f);
			Outline val5 = val3.AddComponent<Outline>();
			((Shadow)val5).effectColor = new Color(0f, 0f, 0f, 1f);
			((Shadow)val5).effectDistance = new Vector2(2f, -2f);
			Image val6 = val3.AddComponent<Image>();
			((Graphic)val6).color = new Color(0f, 0f, 0f, 0.25f);
			CyberTimerVariables.AvgTimePerWaveText = UI.CreateTextElement("PaceText", val3.transform, new Vector2(5f, -5f), "Average time per wave:   00.000");
			CyberTimerVariables.PrevWaveTimeText = UI.CreateTextElement("PrevWaveTimeText", val3.transform, new Vector2(5f, -25f), "Previous wave clear time:  00.000 ");
			CyberTimerVariables._25To30Text = UI.CreateTextElement("25_to_30Text", val3.transform, new Vector2(5f, -45f), "25-30:   0.000 ");
			CyberTimerVariables._30To40Text = UI.CreateTextElement("30_to_40Text", val3.transform, new Vector2(5f, -65f), "30-40:   0.000 ");
			CyberTimerVariables._40To50Text = UI.CreateTextElement("40_to_50Text", val3.transform, new Vector2(5f, -85f), "40-50:   0.000 ");
			CyberTimerVariables._50TimeText = UI.CreateTextElement("50 time", val3.transform, new Vector2(5f, -105f), "Time to reach wave 50:   00.000 ");
			Object.DontDestroyOnLoad((Object)(object)CyberTimerVariables.CyberTimerCanvas);
			CyberTimerVariables.CyberTimerCanvas.SetActive(false);
			CyberTimerVariables.disable25to50 = true;
			((Behaviour)CyberTimerVariables._25To30Text).enabled = false;
			((Behaviour)CyberTimerVariables._30To40Text).enabled = false;
			((Behaviour)CyberTimerVariables._40To50Text).enabled = false;
			((Behaviour)CyberTimerVariables._50TimeText).enabled = false;
			CyberTimerVariables.GlobalRectTransform.sizeDelta = new Vector2(375f, 45f);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CyberTimer";

		public const string PLUGIN_NAME = "CyberTimer";

		public const string PLUGIN_VERSION = "1.1.2";
	}
}
namespace CyberTimer.Utilities
{
	public class Format
	{
		public static string FormatTime(float totalSeconds)
		{
			int num = (int)(totalSeconds / 60f);
			float num2 = totalSeconds % 60f;
			return (num > 0) ? $"{num}:{num2:00.000}" : $"{num2:0.000}";
		}
	}
	public class UI
	{
		public static TextMeshProUGUI CreateTextElement(string name, Transform parent, Vector2 position, string initialText)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0f, 1f);
			val2.anchorMax = new Vector2(0f, 1f);
			val2.pivot = new Vector2(0f, 1f);
			val2.anchoredPosition = position;
			val2.sizeDelta = new Vector2(230f, 20f);
			TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val3).enableWordWrapping = false;
			((TMP_Text)val3).text = initialText;
			((TMP_Text)val3).fontSize = 16f;
			((Graphic)val3).color = Color.white;
			((TMP_Text)val3).fontStyle = (FontStyles)1;
			((TMP_Text)val3).font = CyberTimerVariables.VCR_OSD_MONO;
			return val3;
		}

		public static void UpdateUI(float avgTimePerWave, float waveTime, float _25to30, float _30to40, float _40to50, float _50time)
		{
			((TMP_Text)CyberTimerVariables.AvgTimePerWaveText).text = "Average time per wave:   " + Format.FormatTime(avgTimePerWave);
			((TMP_Text)CyberTimerVariables.PrevWaveTimeText).text = "Previous wave clear time:  " + Format.FormatTime(waveTime) + " ";
			((TMP_Text)CyberTimerVariables._25To30Text).text = "25-30:   " + Format.FormatTime(_25to30);
			((TMP_Text)CyberTimerVariables._30To40Text).text = "30-40:   " + Format.FormatTime(_30to40);
			((TMP_Text)CyberTimerVariables._40To50Text).text = "40-50:   " + Format.FormatTime(_40to50);
			((TMP_Text)CyberTimerVariables._50TimeText).text = ((_50time == 0f) ? "Time to reach wave 50:   00.000" : ("Time to reach wave 50:   " + Format.FormatTime(_50time)));
		}
	}
}
namespace CyberTimer.Patches
{
	[HarmonyPatch]
	public class EndlessGridPatch
	{
		[HarmonyPatch(typeof(EndlessGrid), "Start")]
		[HarmonyPrefix]
		private static void ShowAndResetUI()
		{
			CyberTimerVariables.statsManager = Object.FindObjectOfType<StatsManager>();
			((TMP_Text)CyberTimerVariables.AvgTimePerWaveText).text = "Average time per wave:   00.000";
			((TMP_Text)CyberTimerVariables.PrevWaveTimeText).text = "Previous wave clear time:  00.000 ";
			((TMP_Text)CyberTimerVariables._25To30Text).text = "25-30:   0.000";
			((TMP_Text)CyberTimerVariables._30To40Text).text = "30-40:   0.000";
			((TMP_Text)CyberTimerVariables._40To50Text).text = "40-50:   0.000";
			((TMP_Text)CyberTimerVariables._50TimeText).text = "Time to reach wave 50:   00.000 ";
			CyberTimerVariables._50Time = (CyberTimerVariables._40To50Time = (CyberTimerVariables._30To40Time = (CyberTimerVariables._25To30Time = (CyberTimerVariables.waveTime = (CyberTimerVariables.prevWaveTime = (CyberTimerVariables.clearedWaves = 0f))))));
			CyberTimerVariables.CyberTimerCanvas.SetActive(true);
		}

		[HarmonyPatch(typeof(EndlessGrid), "OnTriggerEnter")]
		[HarmonyPrefix]
		private static void Disable25To50(EndlessGrid __instance)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.startWave == 25)
			{
				((Behaviour)CyberTimerVariables._25To30Text).enabled = true;
				((Behaviour)CyberTimerVariables._30To40Text).enabled = true;
				((Behaviour)CyberTimerVariables._40To50Text).enabled = true;
				((Behaviour)CyberTimerVariables._50TimeText).enabled = true;
				CyberTimerVariables.GlobalRectTransform.sizeDelta = new Vector2(375f, 125f);
				CyberTimerVariables.disable25to50 = false;
			}
			else
			{
				((Behaviour)CyberTimerVariables._25To30Text).enabled = false;
				((Behaviour)CyberTimerVariables._30To40Text).enabled = false;
				((Behaviour)CyberTimerVariables._40To50Text).enabled = false;
				((Behaviour)CyberTimerVariables._50TimeText).enabled = false;
				CyberTimerVariables.GlobalRectTransform.sizeDelta = new Vector2(375f, 45f);
				CyberTimerVariables.disable25to50 = true;
			}
		}

		[HarmonyPatch(typeof(EndlessGrid), "NextWave")]
		[HarmonyPrefix]
		private static void Patch_NextWave(EndlessGrid __instance)
		{
			if (!(CyberTimerVariables.statsManager.seconds > 0f))
			{
				return;
			}
			CyberTimerVariables.clearedWaves += 1f;
			CyberTimerVariables.avgTimePerWave = CyberTimerVariables.statsManager.seconds / CyberTimerVariables.clearedWaves;
			CyberTimerVariables.waveTime = CyberTimerVariables.statsManager.seconds - CyberTimerVariables.prevWaveTime;
			CyberTimerVariables.prevWaveTime = CyberTimerVariables.statsManager.seconds;
			if (!CyberTimerVariables.disable25to50)
			{
				if (__instance.currentWave == 24)
				{
					CyberTimerVariables._25Time = CyberTimerVariables.statsManager.seconds;
				}
				if (__instance.currentWave == 29)
				{
					CyberTimerVariables._30Time = CyberTimerVariables.statsManager.seconds;
					CyberTimerVariables._25To30Time = CyberTimerVariables._30Time - CyberTimerVariables._25Time;
				}
				if (__instance.currentWave == 39)
				{
					CyberTimerVariables._40Time = CyberTimerVariables.statsManager.seconds;
					CyberTimerVariables._30To40Time = CyberTimerVariables._40Time - CyberTimerVariables._30Time;
				}
				if (__instance.currentWave == 49)
				{
					CyberTimerVariables._50Time = CyberTimerVariables.statsManager.seconds;
					CyberTimerVariables._40To50Time = CyberTimerVariables._50Time - CyberTimerVariables._40Time;
				}
			}
			UI.UpdateUI(CyberTimerVariables.avgTimePerWave, CyberTimerVariables.waveTime, CyberTimerVariables._25To30Time, CyberTimerVariables._30To40Time, CyberTimerVariables._40To50Time, CyberTimerVariables._50Time);
		}
	}
	[HarmonyPatch]
	public class ExitCyberGrindPatch
	{
		[HarmonyPatch(typeof(SceneHelper), "LoadScene")]
		[HarmonyPatch(typeof(AbruptLevelChanger), "AbruptChangeLevel")]
		[HarmonyPatch(typeof(OptionsManager), "QuitMission")]
		[HarmonyPrefix]
		private static void Patch_GameOver()
		{
			CyberTimerVariables.CyberTimerCanvas.SetActive(false);
		}
	}
	[HarmonyPatch]
	public class ViewModelFlipPatch
	{
		[HarmonyPatch(typeof(ViewModelFlip), "Right")]
		[HarmonyPostfix]
		private static void FlipRight()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			CyberTimerVariables.GlobalRectTransform.anchorMin = new Vector2(1f, 1f);
			CyberTimerVariables.GlobalRectTransform.anchorMax = new Vector2(1f, 1f);
			CyberTimerVariables.GlobalRectTransform.pivot = new Vector2(1f, 1f);
			CyberTimerVariables.GlobalRectTransform.anchoredPosition = new Vector2(-5f, -5f);
		}

		[HarmonyPatch(typeof(ViewModelFlip), "Left")]
		[HarmonyPostfix]
		private static void FlipLeft()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			CyberTimerVariables.GlobalRectTransform.anchorMin = new Vector2(0f, 1f);
			CyberTimerVariables.GlobalRectTransform.anchorMax = new Vector2(0f, 1f);
			CyberTimerVariables.GlobalRectTransform.pivot = new Vector2(0f, 1f);
			CyberTimerVariables.GlobalRectTransform.anchoredPosition = new Vector2(5f, -5f);
		}
	}
}
namespace CyberTimer.Data
{
	public class CyberTimerVariables
	{
		public static RectTransform GlobalRectTransform;

		public static GameObject CyberTimerCanvas;

		public static TextMeshProUGUI AvgTimePerWaveText;

		public static TextMeshProUGUI PrevWaveTimeText;

		public static TextMeshProUGUI _25To30Text;

		public static TextMeshProUGUI _30To40Text;

		public static TextMeshProUGUI _40To50Text;

		public static TextMeshProUGUI _50TimeText;

		public static TMP_FontAsset VCR_OSD_MONO;

		public static float clearedWaves;

		public static float waveTime;

		public static float avgTimePerWave;

		public static float prevWaveTime;

		public static float _25To30Time;

		public static float _30To40Time;

		public static float _40To50Time;

		public static float _25Time;

		public static float _30Time;

		public static float _40Time;

		public static float _50Time;

		public static bool disable25to50;

		public static StatsManager statsManager;
	}
}