mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-20 01:46:21 +00:00
Add a "Hard crash" button to debugger
<!-- ps-id: 10f09e20-b954-4bd7-ac82-b1a523431770 -->
This commit is contained in:
2 files changed
+60
-5
No files matched your search
@@ -1,6 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using AmongUs.Data;
|
||||
using BepInEx.Unity.IL2CPP.Utils;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using Il2CppInterop.Runtime.InteropTypes;
|
||||
using Reactor.Debugger.Utilities;
|
||||
using Reactor.Debugger.Window.Tabs;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.ImGui;
|
||||
@@ -34,6 +39,43 @@ internal sealed class DebuggerWindow : MonoBehaviour
|
||||
if (AmongUsClient.Instance && AmongUsClient.Instance.AmHost) clientName += " (host)";
|
||||
GUILayout.Label("Name: " + clientName);
|
||||
|
||||
if (GUILayout.Button("Hard crash"))
|
||||
{
|
||||
static unsafe void Corrupt(Il2CppObjectBase o)
|
||||
{
|
||||
var x = (IntPtr*) o.Pointer;
|
||||
x[0] = (IntPtr) 0xF00;
|
||||
}
|
||||
|
||||
static IEnumerator CoCrash()
|
||||
{
|
||||
if (!PlayerControl.LocalPlayer || !ShipStatus.Instance)
|
||||
{
|
||||
yield return AmongUsClient.Instance.CoCreateLocalGame(true);
|
||||
|
||||
while (!PlayerControl.LocalPlayer || !ShipStatus.Instance)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
var usable = FindObjectsOfType<MonoBehaviour>().First(x => x.TryCast<IUsable>() != null);
|
||||
if (!usable)
|
||||
{
|
||||
Error("Failed to find an IUsable to crash with");
|
||||
yield break;
|
||||
}
|
||||
|
||||
var cloned = Instantiate(usable, PlayerControl.LocalPlayer.transform.position, default);
|
||||
|
||||
Warning($"Crashing with {cloned.name}");
|
||||
|
||||
Corrupt(cloned);
|
||||
}
|
||||
|
||||
this.StartCoroutine(CoCrash());
|
||||
}
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
foreach (var tab in Tabs)
|
||||
|
||||
Reference in new issue
Block a user