miuu-sandbox/PatchEntryPoint.cs

46 lines
1.1 KiB
C#
Raw Normal View History

2024-02-01 01:06:57 -05:00
using HarmonyLib;
using System;
2024-02-01 22:09:11 -05:00
using System.Reflection;
using UnityEngine;
2024-02-01 01:06:57 -05:00
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;
2024-02-01 22:09:11 -05:00
KickstartSpeedrunData();
2024-02-01 01:06:57 -05:00
}
}
2024-02-01 22:09:11 -05:00
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");
}
2024-02-01 01:06:57 -05:00
}
}