using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BGTimerMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BGTimerMod")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b4b684ca-cd7c-4050-83c8-341de28ea82b")]
[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 BGTimerMod;
[BepInPlugin("com.zombusa.bgtimermod", "BG Timer Mod", "1.2.1")]
public class TimerCheatPlugin : BaseUnityPlugin
{
public const string PluginGuid = "com.zombusa.bgtimermod";
public const string PluginName = "BG Timer Mod";
public const string PluginVersion = "1.2.1";
private string _popupText = "";
private float _popupUntil;
private GUIStyle _popupStyle;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"BG Timer Mod loaded. Press F8 to add 5 minutes.");
}
private void Update()
{
if (IsF8Pressed())
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"F8 detected.");
if (TryAddFiveMinutes(out var result))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)result);
ShowPopup("Added 5 minutes");
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)result);
ShowPopup("Failed to add time");
}
}
}
private bool IsF8Pressed()
{
try
{
Type type = Type.GetType("UnityEngine.InputSystem.Keyboard, Unity.InputSystem");
if (type != null)
{
object obj = type.GetProperty("current", BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
if (obj != null)
{
object obj2 = type.GetProperty("f8Key", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj);
if (obj2 != null)
{
PropertyInfo property = obj2.GetType().GetProperty("wasPressedThisFrame", BindingFlags.Instance | BindingFlags.Public);
if (property != null)
{
return (bool)property.GetValue(obj2);
}
}
}
}
}
catch
{
}
try
{
Type type2 = Type.GetType("UnityEngine.Input, UnityEngine.InputLegacyModule");
if (type2 != null)
{
MethodInfo method = type2.GetMethod("GetKeyDown", new Type[1] { typeof(KeyCode) });
if (method != null && method.Invoke(null, new object[1] { (object)(KeyCode)289 }) is bool result)
{
return result;
}
}
}
catch
{
}
return false;
}
private bool TryAddFiveMinutes(out string result)
{
result = "";
try
{
Type type = AccessTools.TypeByName("GameProgressionManager");
if (type == null)
{
result = "Could not find type: GameProgressionManager";
return false;
}
object obj = null;
PropertyInfo propertyInfo = AccessTools.Property(type, "Instance");
if (propertyInfo != null)
{
obj = propertyInfo.GetValue(null);
}
if (obj == null)
{
Object[] array = Object.FindObjectsByType(type, (FindObjectsInactive)1, (FindObjectsSortMode)0);
if (array != null && array.Length != 0)
{
obj = array[0];
}
}
if (obj == null)
{
result = "GameProgressionManager instance not found (are you in a match?)";
return false;
}
PropertyInfo propertyInfo2 = type.GetProperty("IsServer", BindingFlags.Instance | BindingFlags.Public) ?? obj.GetType().BaseType?.GetProperty("IsServer", BindingFlags.Instance | BindingFlags.Public);
if (propertyInfo2 != null && !(bool)propertyInfo2.GetValue(obj))
{
result = "You are not host/server. Timer is server-authoritative.";
return false;
}
MethodInfo methodInfo = AccessTools.Method(type, "AddGameTime", new Type[1] { typeof(float) }, (Type[])null);
if (methodInfo == null)
{
result = "Could not find method GameProgressionManager.AddGameTime(float)";
return false;
}
PropertyInfo propertyInfo3 = AccessTools.Property(type, "GameTimeInMinutes");
float num = -1f;
float num2 = -1f;
if (propertyInfo3 != null && propertyInfo3.CanRead)
{
num = Convert.ToSingle(propertyInfo3.GetValue(obj));
}
methodInfo.Invoke(obj, new object[1] { -5f });
if (propertyInfo3 != null && propertyInfo3.CanRead)
{
num2 = Convert.ToSingle(propertyInfo3.GetValue(obj));
}
result = $"Added 5 minutes via AddGameTime(). GameTimeInMinutes: {num} -> {num2}";
return true;
}
catch (Exception ex)
{
result = "Exception: " + ex.GetType().Name + ": " + ex.Message;
return false;
}
}
private void ShowPopup(string text)
{
_popupText = text;
_popupUntil = Time.unscaledTime + 2f;
}
private void OnGUI()
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
if (!(Time.unscaledTime > _popupUntil) && !string.IsNullOrEmpty(_popupText))
{
if (_popupStyle == null)
{
_popupStyle = new GUIStyle(GUI.skin.label);
_popupStyle.fontSize = 22;
_popupStyle.fontStyle = (FontStyle)1;
_popupStyle.alignment = (TextAnchor)2;
_popupStyle.normal.textColor = Color.white;
}
GUI.Label(new Rect((float)(Screen.width - 420), 20f, 400f, 40f), _popupText, _popupStyle);
}
}
}