diff --git a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs index bfe98de862..2d96cae861 100644 --- a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs @@ -133,11 +133,11 @@ public sealed class TraitorRuleSystem : GameRuleSystem Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - did not get traitor briefing"); } - // Send codewords to only the traitor client var color = TraitorCodewordColor; // Fall back to a dark red Syndicate color if a prototype is not found - RoleCodewordComponent codewordComp = EnsureComp(mindId); - _roleCodewordSystem.SetRoleCodewords(codewordComp, "traitor", factionCodewords.ToList(), color); + // The mind entity is stored in nullspace with a PVS override for the owner, so only they can see the codewords. + var codewordComp = EnsureComp(mindId); + _roleCodewordSystem.SetRoleCodewords((mindId, codewordComp), "traitor", factionCodewords.ToList(), color); // Change the faction Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Change faction"); diff --git a/Content.Shared/Roles/RoleCodeword/RoleCodewordComponent.cs b/Content.Shared/Roles/RoleCodeword/RoleCodewordComponent.cs index a1723dbc7e..222aec9bf7 100644 --- a/Content.Shared/Roles/RoleCodeword/RoleCodewordComponent.cs +++ b/Content.Shared/Roles/RoleCodeword/RoleCodewordComponent.cs @@ -1,5 +1,4 @@ using Robust.Shared.GameStates; -using Robust.Shared.Prototypes; using Robust.Shared.Serialization; namespace Content.Shared.Roles.RoleCodeword; @@ -16,8 +15,6 @@ public sealed partial class RoleCodewordComponent : Component /// [DataField, AutoNetworkedField] public Dictionary RoleCodewords = new(); - - public override bool SessionSpecific => true; } [DataDefinition, Serializable, NetSerializable] diff --git a/Content.Shared/Roles/RoleCodeword/SharedRoleCodewordSystem.cs b/Content.Shared/Roles/RoleCodeword/SharedRoleCodewordSystem.cs index 9f860715fb..345cfd4e21 100644 --- a/Content.Shared/Roles/RoleCodeword/SharedRoleCodewordSystem.cs +++ b/Content.Shared/Roles/RoleCodeword/SharedRoleCodewordSystem.cs @@ -1,49 +1,11 @@ -using Content.Shared.Mind; -using Robust.Shared.GameStates; -using Robust.Shared.Player; - namespace Content.Shared.Roles.RoleCodeword; public abstract class SharedRoleCodewordSystem : EntitySystem { - [Dependency] private readonly SharedMindSystem _mindSystem = default!; - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnCodewordCompGetStateAttempt); - } - - /// - /// Determines if a codeword component should be sent to the client. - /// - private void OnCodewordCompGetStateAttempt(EntityUid uid, RoleCodewordComponent comp, ref ComponentGetStateAttemptEvent args) - { - args.Cancelled = !CanGetState(args.Player, comp); - } - - /// - /// The criteria that determine whether a codeword component should be sent to a client. - /// Sends the component if its owner is the player mind. - /// - /// The Player the component will be sent to. - /// The component being checked against - /// - private bool CanGetState(ICommonSession? player, RoleCodewordComponent comp) - { - if (!_mindSystem.TryGetMind(player, out EntityUid mindId, out var _)) - return false; - - if (!TryComp(mindId, out RoleCodewordComponent? playerComp) && comp != playerComp) - return false; - - return true; - } - - public void SetRoleCodewords(RoleCodewordComponent comp, string key, List codewords, Color color) + public void SetRoleCodewords(Entity ent, string key, List codewords, Color color) { var data = new CodewordsData(color, codewords); - comp.RoleCodewords[key] = data; + ent.Comp.RoleCodewords[key] = data; + Dirty(ent); } }