mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
Modded Protocol toggleable
This commit is contained in:
1 parent
cd561e1ad7
commit
854df3b89b
6 files changed
+40
-6
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user