diff --git a/Reactor.Debugger/Utilities/Extensions.cs b/Reactor.Debugger/Utilities/Extensions.cs index cfa9ce6..6eabac9 100644 --- a/Reactor.Debugger/Utilities/Extensions.cs +++ b/Reactor.Debugger/Utilities/Extensions.cs @@ -7,17 +7,30 @@ namespace Reactor.Debugger.Utilities; internal static class Extensions { - public static IEnumerator CoCreateLocalGame(this AmongUsClient client) + public static IEnumerator CoCreateLocalGame(this AmongUsClient client, bool isFreePlay = false) { 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.MainMenuScene = "MatchMaking"; - client.OnlineScene = "OnlineGame"; } catch (Il2CppException e) { diff --git a/Reactor.Debugger/Window/DebuggerWindow.cs b/Reactor.Debugger/Window/DebuggerWindow.cs index 460098b..cd154e8 100644 --- a/Reactor.Debugger/Window/DebuggerWindow.cs +++ b/Reactor.Debugger/Window/DebuggerWindow.cs @@ -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().First(x => x.TryCast() != 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)