using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using On;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PopyModSpeedrunTools")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PopyModSpeedrunTools")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4c8b3bbd-6ac5-4085-8bc4-46a2ff1ff22e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace PopyModSpeedrunTools
{
[BepInPlugin("PopyMod.SpeedrunTools", "SpeedrunTools", "1.1.0")]
public class PopyModSpeedrunTools : BaseUnityPlugin
{
public class PopyModConfig
{
public readonly ConfigEntry<float> TimeComparison;
public PopyModConfig(ConfigFile cfg)
{
TimeComparison = cfg.Bind<float>("General", "Time Comparison", 5999.999f, "This is what your in-game timer will compared to. The value is in seconds, so a time of '7m 48s 217ms' would be '468.217'.");
}
}
private const string modGUID = "PopyMod.SpeedrunTools";
private const string modName = "SpeedrunTools";
private const string modVersion = "1.1.0";
internal static ManualLogSource Log;
public List<TextMeshProUGUI> timerText;
public float timerTime;
public int minutes;
public int seconds;
public int milliseconds;
public float timerReset = 0f;
public bool timerActive = false;
public bool PPB = false;
public float PPBtimer = 2f;
public bool VTHud = false;
public float CmdOnTimer = 3f;
public float CmdOffTimer = 1f;
public bool CmdOnTimerActive = false;
public bool CmdOffTimerActive = false;
internal static PopyModConfig ModConfig { get; private set; }
private void Awake()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
Log = Logger.CreateLogSource("PopyMod.SpeedrunTools");
Log.LogWarning((object)"\r\n .-\"\"\"-. \r\n / / \\ PopyMod\r\n |- < -| Speedrun Tools\r\n \\ \\ / 1.1.0 loaded\r\n '-...-' ");
InputManager.Start += new hook_Start(PPStart);
InputManager.Update += new hook_Update(PPUpdate);
ModConfig = new PopyModConfig(((BaseUnityPlugin)this).Config);
}
private void PPStart(orig_Start orig, InputManager self)
{
orig.Invoke(self);
CreateCanvasObject("SpeedrunTimer Canvas");
CreateGameObject("SpeedrunTimer Object");
CreateTextObject("PopyTimer (TMP) - Face", isOutline: false);
timerText = new List<TextMeshProUGUI>(((Component)GameObject.Find("SpeedrunTimer Object").transform).GetComponentsInChildren<TextMeshProUGUI>());
UpdateTimerText();
}
private void PPUpdate(orig_Update orig, InputManager self)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Invalid comparison between Unknown and I4
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Invalid comparison between Unknown and I4
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Invalid comparison between Unknown and I4
orig.Invoke(self);
foreach (TextMeshProUGUI item in timerText)
{
TextMeshProUGUI component = ((Component)item).GetComponent<TextMeshProUGUI>();
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "MainMenu" && ((TMP_Text)component).fontSize == 50f)
{
((TMP_Text)component).fontSize = 0f;
continue;
}
activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != "MainMenu" && ((TMP_Text)component).fontSize == 0f)
{
((TMP_Text)component).fontSize = 50f;
}
}
if (timerActive)
{
timerTime += Time.deltaTime;
UpdateTimerText();
}
if (!((Object)(object)GameObject.Find("_GameManager (+ HeartJar Manager) (+ ChatBox Manager)") != (Object)null))
{
return;
}
GameManager component2 = GameObject.Find("_GameManager (+ HeartJar Manager) (+ ChatBox Manager)").GetComponent<GameManager>();
HudManager component3 = GameObject.Find("_HudManager").GetComponent<HudManager>();
if ((int)component2.gameState == 1 && !timerActive)
{
if ((Object)(object)GameObject.Find("Video Tutorials") == (Object)null)
{
TimerActiveToggle(x: true);
Log.LogDebug((object)VTHud);
}
else if ((Object)(object)GameObject.Find("Video Tutorials") != (Object)null)
{
TimerReset();
VTHud = true;
Log.LogDebug((object)VTHud);
}
}
if (VTHud && (Object)(object)GameObject.Find("Video Tutorials") == (Object)null)
{
TimerActiveToggle(x: true);
VTHud = false;
}
if ((int)component2.gameState != 1 && timerActive)
{
TimerActiveToggle(x: false);
CmdOnTimerActive = true;
}
if (CmdOnTimerActive)
{
CmdOnTimer -= Time.deltaTime;
if (CmdOnTimer <= 0f)
{
SimulateF3Press();
CmdOnTimerActive = false;
CmdOnTimer = 3f;
CmdOffTimerActive = true;
}
}
if (CmdOffTimerActive)
{
CmdOffTimer -= Time.deltaTime;
if (CmdOffTimer <= 0f)
{
SimulateF3Press();
CmdOffTimerActive = false;
CmdOffTimer = 1f;
}
}
if ((int)component2.gameState == 0 && timerTime > 0f)
{
TimerActiveToggle(x: false);
TimerReset();
}
if ((int)component2.gameState == 3)
{
if (PPBtimer > 0f)
{
PPBtimer -= Time.deltaTime;
if (!PPB)
{
ClosePreGameHuds();
component3.OpenMatchSettingsPanel();
PPB = true;
}
}
else if (PPBtimer <= 0f)
{
ClosePreGameHuds();
component3.ShowGameIsStartingPopUp();
PPBtimer = 2f;
}
}
else if (PPB)
{
PPB = false;
Log.LogDebug((object)"PPB Reset");
}
if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)114))
{
component3.ChangeMenuState(1);
component2.RestartGameButtonClick();
}
}
private void ClosePreGameHuds()
{
HudManager component = GameObject.Find("_HudManager").GetComponent<HudManager>();
component.CloseMatchSettingsPanel();
component.HideGameIsStartingPopUp();
}
private void SimulateF3Press()
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
CmdConsole component = GameObject.Find("DebugConsoleToScreen").GetComponent<CmdConsole>();
component.hidden = !component.hidden;
if (!component.hidden)
{
component.baseWindowElement.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
((Focusable)component.commandField).Focus();
((MonoBehaviour)component).StartCoroutine(component.ScrollToBottom());
}
else
{
component.baseWindowElement.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
}
component.ToggleLogs((ConsoleLogType)3, true);
component.ToggleLogs((ConsoleLogType)2, false);
component.ToggleLogs((ConsoleLogType)1, false);
component.ToggleLogs((ConsoleLogType)0, false);
}
private void UpdateTimerText()
{
minutes = Mathf.FloorToInt(timerTime / 60f);
seconds = Mathf.FloorToInt(timerTime % 60f);
milliseconds = Mathf.FloorToInt(timerTime * 1000f % 1000f);
foreach (TextMeshProUGUI item in timerText)
{
((TMP_Text)item).text = "<" + GetTimerColor() + ">IGT: " + $"{minutes:00}:{seconds:00}.{milliseconds:000}" + "</color>";
}
}
public void TimerReset()
{
timerActive = false;
timerTime = timerReset;
UpdateTimerText();
Log.LogDebug((object)"Timer has been Reset");
}
public void TimerActiveToggle(bool x)
{
timerActive = x;
UpdateTimerText();
Log.LogDebug((object)("TimerActiveToggle: " + x));
}
private void CreateTextObject(string Name, bool isOutline)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(Name);
val.transform.SetParent(GameObject.Find("SpeedrunTimer Object").transform);
val.transform.localPosition = new Vector3(0f, 0f, 0f);
val.transform.localScale = new Vector3(1f, 1f, 1f);
val.AddComponent<CanvasRenderer>();
val.AddComponent<TextMeshProUGUI>();
((TMP_Text)val.GetComponent<TextMeshProUGUI>()).font = ((TMP_Text)GameObject.Find("Play Button").GetComponentInChildren<TextMeshProUGUI>()).font;
((TMP_Text)val.GetComponent<TextMeshProUGUI>()).enableWordWrapping = false;
((TMP_Text)val.GetComponent<TextMeshProUGUI>()).fontSize = 50f;
if (isOutline)
{
((TMP_Text)val.GetComponent<TextMeshProUGUI>()).fontMaterial.SetColor("_FaceColor", new Color(0f, 0f, 0f));
((TMP_Text)val.GetComponent<TextMeshProUGUI>()).fontMaterial.SetFloat("_FaceDilate", 0.2f);
}
}
private void CreateGameObject(string Name)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(Name);
val.transform.SetParent(GameObject.Find("SpeedrunTimer Canvas").transform);
val.transform.localPosition = new Vector3(615f, 390f, 0f);
val.transform.localScale = new Vector3(1f, 1f, 1f);
}
private void CreateCanvasObject(string Name)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
GameObject val = new GameObject(Name);
val.transform.SetParent(GameObject.Find("_InputManager").transform);
val.AddComponent<Canvas>();
((Component)val.transform).GetComponent<Canvas>().renderMode = (RenderMode)0;
((Component)val.transform).GetComponent<Canvas>().sortingOrder = 50;
}
private string GetTimerColor()
{
if (timerTime <= 0f)
{
return "#fff";
}
if (timerTime > ModConfig.TimeComparison.Value)
{
return "#f77";
}
if (timerActive)
{
return "#7ff";
}
return "#7f7";
}
}
}