mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-19 15:51:54 +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
@@ -7,17 +7,30 @@ namespace Reactor.Debugger.Utilities;
|
|||||||
|
|
||||||
internal static class Extensions
|
internal static class Extensions
|
||||||
{
|
{
|
||||||
public static IEnumerator CoCreateLocalGame(this AmongUsClient client)
|
public static IEnumerator CoCreateLocalGame(this AmongUsClient client, bool isFreePlay = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.NetworkMode = NetworkModes.LocalGame;
|
if (isFreePlay)
|
||||||
|
{
|
||||||
|
client.NetworkMode = NetworkModes.FreePlay;
|
||||||
|
|
||||||
InnerNetServer.Instance.StartAsServer();
|
InnerNetServer.Instance.StartAsLocalServer();
|
||||||
|
|
||||||
|
client.MainMenuScene = "MainMenu";
|
||||||
|
client.OnlineScene = "Tutorial";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.NetworkMode = NetworkModes.LocalGame;
|
||||||
|
|
||||||
|
InnerNetServer.Instance.StartAsServer();
|
||||||
|
|
||||||
|
client.MainMenuScene = "MatchMaking";
|
||||||
|
client.OnlineScene = "OnlineGame";
|
||||||
|
}
|
||||||
|
|
||||||
client.SetEndpoint(Constants.LocalNetAddress, Constants.GamePlayPort, false);
|
client.SetEndpoint(Constants.LocalNetAddress, Constants.GamePlayPort, false);
|
||||||
client.MainMenuScene = "MatchMaking";
|
|
||||||
client.OnlineScene = "OnlineGame";
|
|
||||||
}
|
}
|
||||||
catch (Il2CppException e)
|
catch (Il2CppException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
using AmongUs.Data;
|
using AmongUs.Data;
|
||||||
|
using BepInEx.Unity.IL2CPP.Utils;
|
||||||
using Il2CppInterop.Runtime.Attributes;
|
using Il2CppInterop.Runtime.Attributes;
|
||||||
|
using Il2CppInterop.Runtime.InteropTypes;
|
||||||
|
using Reactor.Debugger.Utilities;
|
||||||
using Reactor.Debugger.Window.Tabs;
|
using Reactor.Debugger.Window.Tabs;
|
||||||
using Reactor.Utilities.Attributes;
|
using Reactor.Utilities.Attributes;
|
||||||
using Reactor.Utilities.ImGui;
|
using Reactor.Utilities.ImGui;
|
||||||
@@ -34,6 +39,43 @@ internal sealed class DebuggerWindow : MonoBehaviour
|
|||||||
if (AmongUsClient.Instance && AmongUsClient.Instance.AmHost) clientName += " (host)";
|
if (AmongUsClient.Instance && AmongUsClient.Instance.AmHost) clientName += " (host)";
|
||||||
GUILayout.Label("Name: " + clientName);
|
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();
|
GUILayout.BeginHorizontal();
|
||||||
{
|
{
|
||||||
foreach (var tab in Tabs)
|
foreach (var tab in Tabs)
|
||||||
|
|||||||
Reference in new issue
Block a user