mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-19 15:51:54 +00:00
Reformat code
This commit is contained in:
52 files changed
+2126
-2180
No files matched your search
@@ -9,110 +9,109 @@ using UnhollowerBaseLib;
|
||||
using UnhollowerBaseLib.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reactor.Debugger
|
||||
namespace Reactor.Debugger;
|
||||
|
||||
[BepInAutoPlugin("gg.reactor.debugger")]
|
||||
[BepInProcess("Among Us.exe")]
|
||||
[BepInDependency(ReactorPlugin.Id)]
|
||||
[ReactorPluginSide(PluginSide.ClientOnly)]
|
||||
public partial class DebuggerPlugin : BasePlugin
|
||||
{
|
||||
[BepInAutoPlugin("gg.reactor.debugger")]
|
||||
[BepInProcess("Among Us.exe")]
|
||||
[BepInDependency(ReactorPlugin.Id)]
|
||||
[ReactorPluginSide(PluginSide.ClientOnly)]
|
||||
public partial class DebuggerPlugin : BasePlugin
|
||||
public Harmony Harmony { get; } = new(Id);
|
||||
public DebuggerComponent Component { get; private set; }
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
public Harmony Harmony { get; } = new Harmony(Id);
|
||||
public DebuggerComponent Component { get; private set; }
|
||||
Component = this.AddComponent<DebuggerComponent>();
|
||||
|
||||
public override void Load()
|
||||
GameOptionsData.MaxImpostors = GameOptionsData.RecommendedImpostors = Enumerable.Repeat((int) byte.MaxValue, byte.MaxValue).ToArray();
|
||||
GameOptionsData.MinPlayers = Enumerable.Repeat(1, 4).ToArray();
|
||||
|
||||
Harmony.PatchAll();
|
||||
}
|
||||
|
||||
[RegisterInIl2Cpp]
|
||||
public class DebuggerComponent : MonoBehaviour
|
||||
{
|
||||
[HideFromIl2Cpp]
|
||||
public bool DisableGameEnd { get; set; }
|
||||
|
||||
[HideFromIl2Cpp]
|
||||
public DragWindow TestWindow { get; }
|
||||
|
||||
public DebuggerComponent(IntPtr ptr) : base(ptr)
|
||||
{
|
||||
Component = this.AddComponent<DebuggerComponent>();
|
||||
TestWindow = new DragWindow(new Rect(20, 20, 0, 0), "Debugger", () =>
|
||||
{
|
||||
GUILayout.Label("Name: " + SaveManager.PlayerName);
|
||||
DisableGameEnd = GUILayout.Toggle(DisableGameEnd, "Disable game end");
|
||||
|
||||
GameOptionsData.MaxImpostors = GameOptionsData.RecommendedImpostors = Enumerable.Repeat((int) byte.MaxValue, byte.MaxValue).ToArray();
|
||||
GameOptionsData.MinPlayers = Enumerable.Repeat(1, 4).ToArray();
|
||||
if (ShipStatus.Instance && AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
if (GUILayout.Button("Force game end"))
|
||||
{
|
||||
ShipStatus.Instance.enabled = false;
|
||||
ShipStatus.RpcEndGame(GameOverReason.ImpostorDisconnect, false);
|
||||
}
|
||||
|
||||
Harmony.PatchAll();
|
||||
if (GUILayout.Button("Call a meeting"))
|
||||
{
|
||||
PlayerControl.LocalPlayer.CmdReportDeadBody(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (TutorialManager.InstanceExists && PlayerControl.LocalPlayer)
|
||||
{
|
||||
var data = PlayerControl.LocalPlayer.Data;
|
||||
|
||||
var newIsImpostor = GUILayout.Toggle(data.Role.IsImpostor, "Is Impostor");
|
||||
if (data.Role.IsImpostor != newIsImpostor)
|
||||
{
|
||||
PlayerControl.LocalPlayer.RpcSetRole(newIsImpostor ? RoleTypes.Impostor : RoleTypes.Crewmate);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Spawn a dummy"))
|
||||
{
|
||||
var playerControl = Instantiate(TutorialManager.Instance.PlayerPrefab);
|
||||
var i = playerControl.PlayerId = (byte) GameData.Instance.GetAvailableId();
|
||||
GameData.Instance.AddPlayer(playerControl);
|
||||
AmongUsClient.Instance.Spawn(playerControl, -2, SpawnFlags.None);
|
||||
playerControl.transform.position = PlayerControl.LocalPlayer.transform.position;
|
||||
playerControl.GetComponent<DummyBehaviour>().enabled = true;
|
||||
playerControl.NetTransform.enabled = false;
|
||||
playerControl.SetName($"{TranslationController.Instance.GetString(StringNames.Dummy, Array.Empty<Il2CppSystem.Object>())} {i}");
|
||||
var color = (byte) (i % Palette.PlayerColors.Length);
|
||||
playerControl.SetColor(color);
|
||||
playerControl.SetHat(HatManager.Instance.allHats[i % HatManager.Instance.allHats.Count].ProdId, playerControl.Data.DefaultOutfit.ColorId);
|
||||
playerControl.SetPet(HatManager.Instance.allPets[i % HatManager.Instance.allPets.Count].ProdId);
|
||||
playerControl.SetSkin(HatManager.Instance.allSkins[i % HatManager.Instance.allSkins.Count].ProdId, color);
|
||||
GameData.Instance.RpcSetTasks(playerControl.PlayerId, new Il2CppStructArray<byte>(0));
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerControl.LocalPlayer)
|
||||
{
|
||||
var position = PlayerControl.LocalPlayer.transform.position;
|
||||
GUILayout.Label($"x: {position.x}");
|
||||
GUILayout.Label($"y: {position.y}");
|
||||
}
|
||||
})
|
||||
{
|
||||
Enabled = false,
|
||||
};
|
||||
}
|
||||
|
||||
[RegisterInIl2Cpp]
|
||||
public class DebuggerComponent : MonoBehaviour
|
||||
private void Update()
|
||||
{
|
||||
[HideFromIl2Cpp]
|
||||
public bool DisableGameEnd { get; set; }
|
||||
|
||||
[HideFromIl2Cpp]
|
||||
public DragWindow TestWindow { get; }
|
||||
|
||||
public DebuggerComponent(IntPtr ptr) : base(ptr)
|
||||
if (Input.GetKeyDown(KeyCode.F1))
|
||||
{
|
||||
TestWindow = new DragWindow(new Rect(20, 20, 0, 0), "Debugger", () =>
|
||||
{
|
||||
GUILayout.Label("Name: " + SaveManager.PlayerName);
|
||||
DisableGameEnd = GUILayout.Toggle(DisableGameEnd, "Disable game end");
|
||||
|
||||
if (ShipStatus.Instance && AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
if (GUILayout.Button("Force game end"))
|
||||
{
|
||||
ShipStatus.Instance.enabled = false;
|
||||
ShipStatus.RpcEndGame(GameOverReason.ImpostorDisconnect, false);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Call a meeting"))
|
||||
{
|
||||
PlayerControl.LocalPlayer.CmdReportDeadBody(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (TutorialManager.InstanceExists && PlayerControl.LocalPlayer)
|
||||
{
|
||||
var data = PlayerControl.LocalPlayer.Data;
|
||||
|
||||
var newIsImpostor = GUILayout.Toggle(data.Role.IsImpostor, "Is Impostor");
|
||||
if (data.Role.IsImpostor != newIsImpostor)
|
||||
{
|
||||
PlayerControl.LocalPlayer.RpcSetRole(newIsImpostor ? RoleTypes.Impostor : RoleTypes.Crewmate);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Spawn a dummy"))
|
||||
{
|
||||
var playerControl = Instantiate(TutorialManager.Instance.PlayerPrefab);
|
||||
var i = playerControl.PlayerId = (byte) GameData.Instance.GetAvailableId();
|
||||
GameData.Instance.AddPlayer(playerControl);
|
||||
AmongUsClient.Instance.Spawn(playerControl, -2, SpawnFlags.None);
|
||||
playerControl.transform.position = PlayerControl.LocalPlayer.transform.position;
|
||||
playerControl.GetComponent<DummyBehaviour>().enabled = true;
|
||||
playerControl.NetTransform.enabled = false;
|
||||
playerControl.SetName($"{TranslationController.Instance.GetString(StringNames.Dummy, Array.Empty<Il2CppSystem.Object>())} {i}");
|
||||
var color = (byte) (i % Palette.PlayerColors.Length);
|
||||
playerControl.SetColor(color);
|
||||
playerControl.SetHat(HatManager.Instance.allHats[i % HatManager.Instance.allHats.Count].ProdId, playerControl.Data.DefaultOutfit.ColorId);
|
||||
playerControl.SetPet(HatManager.Instance.allPets[i % HatManager.Instance.allPets.Count].ProdId);
|
||||
playerControl.SetSkin(HatManager.Instance.allSkins[i % HatManager.Instance.allSkins.Count].ProdId, color);
|
||||
GameData.Instance.RpcSetTasks(playerControl.PlayerId, new Il2CppStructArray<byte>(0));
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerControl.LocalPlayer)
|
||||
{
|
||||
var position = PlayerControl.LocalPlayer.transform.position;
|
||||
GUILayout.Label($"x: {position.x}");
|
||||
GUILayout.Label($"y: {position.y}");
|
||||
}
|
||||
})
|
||||
{
|
||||
Enabled = false
|
||||
};
|
||||
TestWindow.Enabled = !TestWindow.Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.F1))
|
||||
{
|
||||
TestWindow.Enabled = !TestWindow.Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
TestWindow.OnGUI();
|
||||
}
|
||||
private void OnGUI()
|
||||
{
|
||||
TestWindow.OnGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
-44
@@ -3,68 +3,67 @@ using HarmonyLib;
|
||||
using UnhollowerBaseLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reactor.Debugger
|
||||
namespace Reactor.Debugger;
|
||||
|
||||
internal static class Patches
|
||||
{
|
||||
internal static class Patches
|
||||
[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
|
||||
public static class UpdatePatch
|
||||
{
|
||||
[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
|
||||
public static class UpdatePatch
|
||||
public static void Prefix(GameStartManager __instance)
|
||||
{
|
||||
public static void Prefix(GameStartManager __instance)
|
||||
{
|
||||
__instance.MinPlayers = 1;
|
||||
}
|
||||
__instance.MinPlayers = 1;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
|
||||
public static class CountdownPatch
|
||||
[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
|
||||
public static class CountdownPatch
|
||||
{
|
||||
public static void Prefix(GameStartManager __instance)
|
||||
{
|
||||
public static void Prefix(GameStartManager __instance)
|
||||
{
|
||||
__instance.countDownTimer = 0;
|
||||
}
|
||||
__instance.countDownTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(StatsManager), nameof(StatsManager.AmBanned), MethodType.Getter)]
|
||||
public static class AmBannedPatch
|
||||
[HarmonyPatch(typeof(StatsManager), nameof(StatsManager.AmBanned), MethodType.Getter)]
|
||||
public static class AmBannedPatch
|
||||
{
|
||||
public static void Postfix(out bool __result)
|
||||
{
|
||||
public static void Postfix(out bool __result)
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.CheckEndCriteria))]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
public static class CheckEndCriteriaPatch
|
||||
[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.CheckEndCriteria))]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
public static class CheckEndCriteriaPatch
|
||||
{
|
||||
public static bool Prefix()
|
||||
{
|
||||
public static bool Prefix()
|
||||
{
|
||||
return !PluginSingleton<DebuggerPlugin>.Instance.Component.DisableGameEnd;
|
||||
}
|
||||
return !PluginSingleton<DebuggerPlugin>.Instance.Component.DisableGameEnd;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameSettingMenu), nameof(GameSettingMenu.Start))]
|
||||
public static class GameSettingMenuPatch
|
||||
[HarmonyPatch(typeof(GameSettingMenu), nameof(GameSettingMenu.Start))]
|
||||
public static class GameSettingMenuPatch
|
||||
{
|
||||
public static void Prefix(GameSettingMenu __instance)
|
||||
{
|
||||
public static void Prefix(GameSettingMenu __instance)
|
||||
{
|
||||
// Unlocks map/impostor amount changing in online (for testing on your custom servers)
|
||||
__instance.HideForOnline = new Il2CppReferenceArray<Transform>(0);
|
||||
}
|
||||
// Unlocks map/impostor amount changing in online (for testing on your custom servers)
|
||||
__instance.HideForOnline = new Il2CppReferenceArray<Transform>(0);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Start))]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
public static class GameOptionsMenuPatch
|
||||
[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Start))]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
public static class GameOptionsMenuPatch
|
||||
{
|
||||
public static void Postfix(GameOptionsMenu __instance)
|
||||
{
|
||||
public static void Postfix(GameOptionsMenu __instance)
|
||||
{
|
||||
__instance.Children
|
||||
.Single(o => o.Title == StringNames.GameNumImpostors)
|
||||
.Cast<NumberOption>()
|
||||
.ValidRange = new FloatRange(0, byte.MaxValue);
|
||||
}
|
||||
__instance.Children
|
||||
.Single(o => o.Title == StringNames.GameNumImpostors)
|
||||
.Cast<NumberOption>()
|
||||
.ValidRange = new FloatRange(0, byte.MaxValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user