using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Assets.Scripts.Utility;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using MelonLoader;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SlowerTimer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SlowerTimer")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a052f8b9-b678-40b0-a576-d1c5418579fb")]
[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 SlowerTimer
{
[BepInPlugin("mike9k1.megabonk.slowertimer", "Slower Timer", "0.0.5")]
public class Class1 : MelonMod
{
public new const string PLUGIN_GUID = "mike9k1.megabonk.slowertimer";
public new const string PLUGIN_NAME = "Slower Timer";
public new const string PLUGIN_VERSION = "0.0.5";
private string PlayerTypeName = "Assets.Scripts.Utility.MyTime";
private string TimerMethodName = "FixedUpdate";
private PropertyInfo timer;
private static float lastTime;
private static Type FindType(string fullName)
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
try
{
Type type = assembly.GetType(fullName, throwOnError: false);
if (type != null)
{
return type;
}
}
catch
{
}
}
return null;
}
private static void SlowTimer()
{
float num = MyTime.stageTimer;
if (lastTime == 0f)
{
lastTime = num;
num -= 0.012f;
}
else if (num > lastTime + 0.018f)
{
num = (lastTime = num - 0.012f);
}
else if (lastTime > num + 0.5f)
{
lastTime = num;
}
MyTime.stageTimer = num;
}
private void TryPatch()
{
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
Type type = FindType(PlayerTypeName);
if (type == null)
{
MelonLogger.Error("Type not found: " + PlayerTypeName);
return;
}
MethodInfo method = type.GetMethod(TimerMethodName);
if (method == null)
{
MelonLogger.Error("Property not found: " + type.FullName + "." + TimerMethodName + "()");
}
else
{
HarmonyMethod val = new HarmonyMethod(typeof(Class1).GetMethod("SlowTimer", BindingFlags.Static | BindingFlags.NonPublic));
HarmonyInstance.Patch((MethodBase)method, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MelonLogger.Msg("Patched " + type.FullName + "." + TimerMethodName + "()");
}
}
public override void OnInitializeMelon()
{
TryPatch();
}
}
}
namespace MelonLoader
{
public class MelonMod : BasePlugin
{
public Harmony HarmonyInstance;
public static MelonMod melonModRef;
public virtual string PLUGIN_GUID => "author.game.modname";
public virtual string PLUGIN_NAME => "Mod Name Here";
public virtual string PLUGIN_VERSION => "0.0.1";
public MelonMod()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
HarmonyInstance = new Harmony(PLUGIN_GUID);
melonModRef = this;
}
public virtual void OnInitializeMelon()
{
}
public virtual void OnLateInitializeMelon()
{
}
public virtual void OnFixedUpdate()
{
}
public virtual void OnUpdate()
{
}
public override void Load()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
OnInitializeMelon();
HarmonyMethod val = new HarmonyMethod(typeof(MelonMod).GetMethod("FixedUpdate"));
HarmonyInstance.Patch((MethodBase)typeof(MyTime).GetMethod("FixedUpdate"), (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
HarmonyMethod val2 = new HarmonyMethod(typeof(MelonMod).GetMethod("Update"));
HarmonyInstance.Patch((MethodBase)typeof(MyTime).GetMethod("Update"), (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
public void Awake()
{
OnLateInitializeMelon();
}
public static void FixedUpdate()
{
melonModRef.OnFixedUpdate();
}
public static void Update()
{
melonModRef.OnUpdate();
}
}
public class MelonLogger
{
private static ManualLogSource log;
private static bool logAdded;
public static void Msg(string message)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
if (!logAdded)
{
log = new ManualLogSource(((AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), inherit: false)[0]).Title);
Logger.Sources.Add((ILogSource)(object)log);
logAdded = true;
}
log.LogInfo((object)message);
}
public static void Error(string message)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
if (!logAdded)
{
log = new ManualLogSource(((AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), inherit: false)[0]).Title);
Logger.Sources.Add((ILogSource)(object)log);
logAdded = true;
}
log.LogError((object)message);
}
}
}