Modded Protocol toggleable

This commit is contained in:
D1GQ committed 2024-07-31 00:46:45 -05:00
1 parent cd561e1ad7
commit 854df3b89b
6 files changed
+40 -6

No files matched your search

+1
View File
@@ -100,6 +100,7 @@ static class ExtendedPlayerControl
public static void RpcTeleport(this PlayerControl player, Vector2 position)
{
if (!GameStates.IsHost) return;
if (!GameStates.IsModdedProtocol) return;
var cancelTeleport = false;
+3 -1
View File
@@ -1,4 +1,5 @@
using AmongUs.GameOptions;
using BetterAmongUs.Patches;
namespace BetterAmongUs;
@@ -23,7 +24,8 @@ public static class GameStates
public static bool IsInGamePlay => (InGame && !IsLobby && !IsInIntro && IsShip) || IsFreePlay;
public static bool IsEnded => AmongUsClient.Instance?.GameState == InnerNet.InnerNetClient.GameStates.Ended;
public static bool IsNotJoined => AmongUsClient.Instance?.GameState == InnerNet.InnerNetClient.GameStates.NotJoined;
public static bool IsOnlineGame => AmongUsClient.Instance?.NetworkMode == NetworkModes.OnlineGame;
public static bool IsOnlineGame => AmongUsClient.Instance?.NetworkMode == NetworkModes.OnlineGame;
public static bool IsModdedProtocol => ServerUpdatePatch.IsModdedProtocol;
public static bool IsVanillaServer
{
get
+2
View File
@@ -94,6 +94,8 @@ internal static class RPC
return;
}
if (!GameStates.IsModdedProtocol) return;
PlayerControl asPlayer = Main.AllPlayerControls.Where(pc => pc.IsAlive()).OrderBy(pc => pc == PlayerControl.LocalPlayer ? 0 : 1).First();
var oldName = asPlayer.CurrentOutfit.PlayerName;
+17 -3
View File
@@ -11,6 +11,7 @@ public static class OptionsMenuBehaviourPatch
{
private static ClientOptionItem AntiCheat;
private static ClientOptionItem BetterHost;
private static ClientOptionItem ModdedProtocol;
private static ClientOptionItem BetterRoleAlgorithma;
private static ClientOptionItem LobbyPlayerInfo;
private static ClientOptionItem DisableLobbyTheme;
@@ -22,9 +23,17 @@ public static class OptionsMenuBehaviourPatch
[HarmonyPrefix]
public static void Start_Postfix(OptionsMenuBehaviour __instance)
{
static bool toggleCheckInGame(string buttonName)
static bool toggleCheckInGamePlay(string buttonName)
{
bool flag = GameStates.IsInGame && !GameStates.IsLobby || GameStates.IsFreePlay;
if (flag)
BetterNotificationManager.Notify($"Unable to toggle {buttonName} while in gameplay!", 2.5f);
return flag;
}
static bool toggleCheckInGame(string buttonName)
{
bool flag = GameStates.IsInGame;
if (flag)
BetterNotificationManager.Notify($"Unable to toggle {buttonName} while in game!", 2.5f);
@@ -40,7 +49,7 @@ public static class OptionsMenuBehaviourPatch
if (BetterHost == null || BetterHost.ToggleButton == null)
{
BetterHost = ClientOptionItem.Create("<color=#4f92ff>Better Host</color>", Main.BetterHost, __instance, BetterHostButtonToggle, () => !toggleCheckInGame("<color=#4f92ff>Better Host</color>"));
BetterHost = ClientOptionItem.Create("<color=#4f92ff>Better Host</color>", Main.BetterHost, __instance, BetterHostButtonToggle, () => !toggleCheckInGamePlay("<color=#4f92ff>Better Host</color>"));
static void BetterHostButtonToggle()
{
var flag = GameStates.IsHost && Main.BetterHost.Value;
@@ -51,11 +60,16 @@ public static class OptionsMenuBehaviourPatch
RPC.SyncAllNames(force: true);
}
}
if (ModdedProtocol == null || ModdedProtocol.ToggleButton == null)
{
ModdedProtocol = ClientOptionItem.Create("<color=#4f92ff>Modded Protocol</color>", Main.ModdedProtocol, __instance, toggleCheck: () => !toggleCheckInGame("<color=#4f92ff>Modded Protocol</color>"));
}
if (BetterRoleAlgorithma == null || BetterRoleAlgorithma.ToggleButton == null)
{
BetterRoleAlgorithma = ClientOptionItem.Create("<color=#4f92ff>Better Role Algorithma</color>", Main.BetterRoleAlgorithma, __instance, toggleCheck: () => !toggleCheckInGame("<color=#4f92ff>Better Role Algorithma</color>"));
BetterRoleAlgorithma = ClientOptionItem.Create("<color=#4f92ff>Better Role Algorithma</color>", Main.BetterRoleAlgorithma, __instance, toggleCheck: () => !toggleCheckInGamePlay("<color=#4f92ff>Better Role Algorithma</color>"));
}
if (LobbyPlayerInfo == null || LobbyPlayerInfo.ToggleButton == null)
+5
View File
@@ -31,6 +31,11 @@ public class PingTrackerPatch
sb.Append("<size=75%><color=#4f92ff>Better Host</color>: <color=#00f04c>Enabled</color></size>\n");
}
if (GameStates.IsModdedProtocol)
{
sb.Append("<size=75%><color=#4f92ff>Modded Protocol</color>: <color=#00f04c>Enabled</color></size>\n");
}
if (Main.ShowFPS.Value)
{
float FPSNum = 1.0f / Time.deltaTime;
+12 -2
View File
@@ -7,6 +7,11 @@ namespace BetterAmongUs.Patches;
[HarmonyPatch(typeof(Constants), nameof(Constants.GetBroadcastVersion))]
class ServerUpdatePatch
{
private static int VanillaVersionServer = 0;
private static int ModdedVersionServer = 0;
public static bool IsModdedProtocol => ModdedVersionServer == VanillaVersionServer + 25;
static void Postfix(ref int __result)
{
if (GameStates.IsLocalGame)
@@ -15,7 +20,12 @@ class ServerUpdatePatch
}
if (GameStates.IsOnlineGame)
{
// __result += 25;
VanillaVersionServer = __result;
if (Main.ModdedProtocol.Value)
{
__result += 25;
}
ModdedVersionServer = __result;
Logger.Log($"IsOnlineGame: {__result}", "VersionServer");
}
}
@@ -25,7 +35,7 @@ public static class IsVersionModdedPatch
{
public static bool Prefix(ref bool __result)
{
__result = true;
__result = ServerUpdatePatch.IsModdedProtocol;
return false;
}
}