45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using HarmonyLib;
|
|
using System;
|
|
using System.Reflection;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
namespace Sandbox
|
|
{
|
|
public static class PatchEntryPoint
|
|
{
|
|
private static bool IsPatched;
|
|
|
|
public static void Start()
|
|
{
|
|
SceneManager.sceneLoaded += beginPatch;
|
|
}
|
|
|
|
private static void beginPatch(Scene scene, LoadSceneMode loadSceneMode)
|
|
{
|
|
if (!IsPatched)
|
|
{
|
|
new Harmony("com.thearst3rd.sandbox").PatchAll();
|
|
IsPatched = true;
|
|
SceneManager.sceneLoaded -= beginPatch;
|
|
|
|
KickstartSpeedrunData();
|
|
}
|
|
}
|
|
|
|
private static void KickstartSpeedrunData()
|
|
{
|
|
// Kickstart SpeedrunData using reflection shenanigans
|
|
// We want to run the following code:
|
|
//SpeedrunData.SetValue(0, -1, -1);
|
|
|
|
Assembly miuuAsm = typeof(MarbleController).Assembly;
|
|
Type speedrunDataType = miuuAsm.GetType("SpeedrunData");
|
|
MethodInfo speedrunDataSetValueMethod = speedrunDataType.GetMethod("SetValue", BindingFlags.Public | BindingFlags.Static);
|
|
|
|
speedrunDataSetValueMethod.Invoke(null, new object[] { 0, -1, -1 });
|
|
|
|
Debug.Log("SpeedrunData kickstarted");
|
|
}
|
|
}
|
|
}
|