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 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.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a66d6a194c964ccfc826b662d083ec95d3d7e74c")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("CyberTimer")]
[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 CyberTimer
{
[BepInPlugin("chair.mods.cybertimer", "CyberTimer", "1.0.4")]
[BepInProcess("ULTRAKILL.exe")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch]
private static class CyberTimer
{
[HarmonyPatch(typeof(SceneHelper), "LoadScene")]
[HarmonyPatch(typeof(AbruptLevelChanger), "AbruptChangeLevel")]
[HarmonyPatch(typeof(OptionsManager), "QuitMission")]
[HarmonyPostfix]
private static void Patch_GameOver(OptionsManager __instance)
{
cyberTimerCanvas.SetActive(false);
}
[HarmonyPatch(typeof(ViewModelFlip), "Right")]
[HarmonyPostfix]
private static void FlipRight(ViewModelFlip __instance)
{
//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)
globalRectTransform.anchorMin = new Vector2(1f, 1f);
globalRectTransform.anchorMax = new Vector2(1f, 1f);
globalRectTransform.pivot = new Vector2(1f, 1f);
globalRectTransform.anchoredPosition = new Vector2(-5f, -5f);
}
[HarmonyPatch(typeof(ViewModelFlip), "Left")]
[HarmonyPostfix]
private static void FlipLeft(ViewModelFlip __instance)
{
//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)
globalRectTransform.anchorMin = new Vector2(0f, 1f);
globalRectTransform.anchorMax = new Vector2(0f, 1f);
globalRectTransform.pivot = new Vector2(0f, 1f);
globalRectTransform.anchoredPosition = new Vector2(5f, -5f);
}
[HarmonyPatch(typeof(EndlessGrid), "Start")]
[HarmonyPrefix]
private static void ShowAndResetUI(EndlessGrid __instance)
{
((TMP_Text)avgTimePerWaveText).text = "Average time per wave: 00.000";
((TMP_Text)prevWaveTimeText).text = "Previous wave clear time: 00.000 ";
((TMP_Text)_25To30Text).text = "25-30: 0.000";
((TMP_Text)_30To40Text).text = "30-40: 0.000";
((TMP_Text)_40To50Text).text = "40-50: 0.000";
((TMP_Text)_50TimeText).text = "Time to reach wave 50: 00.000 ";
_50Time = (_40To50Time = (_30To40Time = (_25To30Time = (waveTime = (prevWaveTime = (clearedWaves = 0f))))));
cyberTimerCanvas.SetActive(true);
}
[HarmonyPatch(typeof(EndlessGrid), "OnTriggerEnter")]
[HarmonyPrefix]
private static void Disable25to50(EndlessGrid __instance)
{
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
EndlessGrid val = Object.FindObjectOfType<EndlessGrid>();
if (val.startWave == 25)
{
((Behaviour)_25To30Text).enabled = true;
((Behaviour)_30To40Text).enabled = true;
((Behaviour)_40To50Text).enabled = true;
((Behaviour)_50TimeText).enabled = true;
globalRectTransform.sizeDelta = new Vector2(375f, 125f);
disable25to50 = false;
}
else
{
((Behaviour)_25To30Text).enabled = false;
((Behaviour)_30To40Text).enabled = false;
((Behaviour)_40To50Text).enabled = false;
((Behaviour)_50TimeText).enabled = false;
globalRectTransform.sizeDelta = new Vector2(375f, 45f);
disable25to50 = true;
}
}
[HarmonyPatch(typeof(EndlessGrid), "NextWave")]
[HarmonyPrefix]
private static void Patch_NextWave(EndlessGrid __instance)
{
EndlessGrid val = Object.FindObjectOfType<EndlessGrid>();
StatsManager val2 = Object.FindObjectOfType<StatsManager>();
if (!(val2.seconds > 0f))
{
return;
}
clearedWaves += 1f;
avgTimePerWave = val2.seconds / clearedWaves;
waveTime = val2.seconds - prevWaveTime;
prevWaveTime = val2.seconds;
if (!disable25to50)
{
if (val.currentWave == 24)
{
_25Time = val2.seconds;
}
if (val.currentWave == 29)
{
_30Time = val2.seconds;
_25To30Time = _30Time - _25Time;
}
if (val.currentWave == 39)
{
_40Time = val2.seconds;
_30To40Time = _40Time - _30Time;
}
if (val.currentWave == 49)
{
_50Time = val2.seconds;
_40To50Time = _50Time - _40Time;
}
}
UpdateUI(avgTimePerWave, waveTime, _25To30Time, _30To40Time, _40To50Time, _50Time);
}
}
private static RectTransform globalRectTransform;
private static GameObject cyberTimerCanvas;
private static TextMeshProUGUI avgTimePerWaveText;
private static TextMeshProUGUI prevWaveTimeText;
private static TextMeshProUGUI _25To30Text;
private static TextMeshProUGUI _30To40Text;
private static TextMeshProUGUI _40To50Text;
private static TextMeshProUGUI _50TimeText;
private static ManualLogSource Logger;
private static float clearedWaves;
private static float waveTime;
private static float avgTimePerWave;
private static float prevWaveTime;
private static float _25To30Time;
private static float _30To40Time;
private static float _40To50Time;
private static float _25Time;
private static float _30Time;
private static float _40Time;
private static float _50Time;
private TMP_FontAsset VCR_OSD_MONO;
private static bool disable25to50;
public 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();
TimerGUI();
}
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(Paths.PluginPath, "0chair-CyberTimer", "vcr_osd_mono asset");
AssetBundle val = AssetBundle.LoadFromFile(text);
VCR_OSD_MONO = val.LoadAsset<TMP_FontAsset>("VCR_OSD_MONO SDF");
}
private static string FormatTime(float totalSeconds)
{
int num = (int)(totalSeconds / 60f);
float num2 = totalSeconds % 60f;
return (num > 0) ? $"{num}:{num2:00.000}" : $"{num2:0.000}";
}
private void TimerGUI()
{
//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_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
cyberTimerCanvas = new GameObject("CyberTimerCanvas");
Canvas val = cyberTimerCanvas.AddComponent<Canvas>();
val.renderMode = (RenderMode)0;
val.sortingOrder = 100;
CanvasScaler val2 = cyberTimerCanvas.AddComponent<CanvasScaler>();
val2.uiScaleMode = (ScaleMode)1;
val2.referenceResolution = new Vector2(1920f, 1080f);
GameObject val3 = new GameObject("TimerPanel");
val3.transform.SetParent(cyberTimerCanvas.transform, false);
RectTransform val4 = (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);
avgTimePerWaveText = CreateTextElement("PaceText", val3.transform, new Vector2(5f, -5f), "Average time per wave: 00.000");
prevWaveTimeText = CreateTextElement("PrevWaveTimeText", val3.transform, new Vector2(5f, -25f), "Previous wave clear time: 00.000 ");
_25To30Text = CreateTextElement("25_to_30Text", val3.transform, new Vector2(5f, -45f), "25-30: 0.000 ");
_30To40Text = CreateTextElement("30_to_40Text", val3.transform, new Vector2(5f, -65f), "30-40: 0.000 ");
_40To50Text = CreateTextElement("40_to_50Text", val3.transform, new Vector2(5f, -85f), "40-50: 0.000 ");
_50TimeText = CreateTextElement("50 time", val3.transform, new Vector2(5f, -105f), "Time to reach wave 50: 00.000 ");
Object.DontDestroyOnLoad((Object)(object)cyberTimerCanvas);
cyberTimerCanvas.SetActive(false);
}
private 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_00a2: 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 = VCR_OSD_MONO;
return val3;
}
private static void UpdateUI(float _avgTimePerWave, float _waveTime, float _25to30, float _30to40, float _40to50, float _50time)
{
((TMP_Text)avgTimePerWaveText).text = "Average time per wave: " + FormatTime(_avgTimePerWave);
((TMP_Text)prevWaveTimeText).text = "Previous wave clear time: " + FormatTime(_waveTime) + " ";
((TMP_Text)_25To30Text).text = "25-30: " + FormatTime(_25to30);
((TMP_Text)_30To40Text).text = "30-40: " + FormatTime(_30to40);
((TMP_Text)_40To50Text).text = "40-50: " + FormatTime(_40to50);
((TMP_Text)_50TimeText).text = ((_50time == 0f) ? "Time to reach wave 50: 00.000" : ("Time to reach wave 50: " + FormatTime(_50time)));
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CyberTimer";
public const string PLUGIN_NAME = "My first plugin";
public const string PLUGIN_VERSION = "1.0.0";
}
}