Implement KickstartSpeedrunData

This commit is contained in:
Terry Hearst 2024-02-01 22:09:11 -05:00
parent 28ed7c9ac8
commit 17a2fd1760

View file

@ -1,5 +1,7 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using System.Reflection;
using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
namespace Sandbox namespace Sandbox
@ -20,7 +22,24 @@ namespace Sandbox
new Harmony("com.thearst3rd.sandbox").PatchAll(); new Harmony("com.thearst3rd.sandbox").PatchAll();
IsPatched = true; IsPatched = true;
SceneManager.sceneLoaded -= beginPatch; 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");
}
} }
} }