This commit is contained in:
D1GQ committed 2026-04-13 20:16:26 -05:00
1 parent 121b4b33d5
commit a6b4cdf95f
2 files changed
+26 -6

No files matched your search

+20
View File
@@ -82,6 +82,26 @@ internal static class RoleHelper
return string.Empty;
}
/// <summary>
/// Determines whether a role type is cliant side and can be desynced.
/// </summary>
/// <param name="role">The role type to check.</param>
/// <returns>True if the role can be desynced to other clients, false otherwise.</returns>
internal static bool CanDesyncRole(this RoleTypes role)
{
if (role is RoleTypes.Phantom or RoleTypes.Viper)
{
return false;
}
if (role is RoleTypes.Noisemaker)
{
return false;
}
return true;
}
/// <summary>
/// Dictionary mapping role types to their hexadecimal color codes.
/// </summary>
@@ -16,7 +16,7 @@ internal static class RoleManagerPatch
private static readonly Random random = new();
// Check if client is verified Better Among Us user
private static Func<InnerNet.ClientData, bool> SendTo(PlayerControl target)
private static Func<InnerNet.ClientData, bool> FilterTargetClients(PlayerControl target)
{
return (clientData) =>
{
@@ -164,9 +164,9 @@ internal static class RoleManagerPatch
// Desync role to hide special role from non-BAU players
if (BetterGameSettings.DesyncRoles.GetBool())
{
if (kvp.Key is not (RoleTypes.Phantom or RoleTypes.Viper))
if (kvp.Key.CanDesyncRole())
{
AmongUsClient.Instance.SendRpcImmediatelyDesync(pc.NetId, RpcCalls.SetRole, SendOption.None, SendTo(pc), writer =>
AmongUsClient.Instance.SendRpcImmediatelyDesync(pc.NetId, RpcCalls.SetRole, SendOption.None, FilterTargetClients(pc), writer =>
{
writer.Write((ushort)RoleTypes.Impostor);
writer.Write(false);
@@ -204,9 +204,9 @@ internal static class RoleManagerPatch
// Desync role to hide special role from non-BAU players
if (BetterGameSettings.DesyncRoles.GetBool())
{
if (kvp.Key is not RoleTypes.Noisemaker)
if (kvp.Key.CanDesyncRole())
{
AmongUsClient.Instance.SendRpcImmediatelyDesync(pc.NetId, RpcCalls.SetRole, SendOption.None, SendTo(pc), writer =>
AmongUsClient.Instance.SendRpcImmediatelyDesync(pc.NetId, RpcCalls.SetRole, SendOption.None, FilterTargetClients(pc), writer =>
{
writer.Write((ushort)RoleTypes.Crewmate);
writer.Write(false);
@@ -351,7 +351,7 @@ internal static class RoleManagerPatch
// Desync ghost role to hide it from non-BAU players
if (BetterGameSettings.DesyncRoles.GetBool())
{
AmongUsClient.Instance.SendRpcImmediatelyDesync(player.NetId, RpcCalls.SetRole, SendOption.None, SendTo(player), writer =>
AmongUsClient.Instance.SendRpcImmediatelyDesync(player.NetId, RpcCalls.SetRole, SendOption.None, FilterTargetClients(player), writer =>
{
writer.Write((ushort)player.Data.Role.DefaultGhostRole);
writer.Write(false);