diff --git a/Content.Client/CharacterInfo/CharacterInfoSystem.cs b/Content.Client/CharacterInfo/CharacterInfoSystem.cs index 2b2694c677..cab9ef7c2f 100644 --- a/Content.Client/CharacterInfo/CharacterInfoSystem.cs +++ b/Content.Client/CharacterInfo/CharacterInfoSystem.cs @@ -58,7 +58,7 @@ public sealed class CharacterInfoSystem : EntitySystem EntityUid Entity, string Job, Dictionary> Objectives, - string Briefing, + string? Briefing, string EntityName ); diff --git a/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs b/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs index 71a06d58ee..beb37029c6 100644 --- a/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs +++ b/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs @@ -141,11 +141,14 @@ public sealed class CharacterUIController : UIController, IOnStateEntered>(); var jobTitle = "No Profession"; - var briefing = "!!ERROR: No Briefing!!"; //should never show on the UI unless there's an issue + string? briefing = null; if (_minds.TryGetMind(entity, out var mindId, out var mind)) { // Get objectives @@ -48,7 +48,7 @@ public sealed class CharacterInfoSystem : EntitySystem jobTitle = jobName; // Get briefing - briefing = _roles.MindGetBriefing(mindId) ?? string.Empty; + briefing = _roles.MindGetBriefing(mindId); } RaiseNetworkEvent(new CharacterInfoEvent(entity, jobTitle, conditions, briefing), args.SenderSession); diff --git a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs index 81a4fad7c5..1bcdb99839 100644 --- a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs @@ -254,11 +254,18 @@ public sealed class TraitorRuleSystem : GameRuleSystem var traitorRole = new TraitorRoleComponent { PrototypeId = traitorRule.TraitorPrototypeId, - Briefing = briefing }; // Assign traitor roles - _roleSystem.MindAddRole(mindId, traitorRole); + _roleSystem.MindAddRole(mindId, new TraitorRoleComponent + { + PrototypeId = traitorRule.TraitorPrototypeId + }); + // Assign briefing + _roleSystem.MindAddRole(mindId, new RoleBriefingComponent + { + Briefing = briefing + }); SendTraitorBriefing(mindId, traitorRule.Codewords, code); traitorRule.TraitorMinds.Add(mindId); diff --git a/Content.Server/Roles/RoleBriefingComponent.cs b/Content.Server/Roles/RoleBriefingComponent.cs new file mode 100644 index 0000000000..3577033f7d --- /dev/null +++ b/Content.Server/Roles/RoleBriefingComponent.cs @@ -0,0 +1,11 @@ +namespace Content.Server.Roles; + +/// +/// Adds a briefing to the character info menu, does nothing else. +/// +[RegisterComponent] +public sealed partial class RoleBriefingComponent : Component +{ + [DataField("briefing"), ViewVariables(VVAccess.ReadWrite)] + public string Briefing; +} diff --git a/Content.Server/Roles/RoleBriefingSystem.cs b/Content.Server/Roles/RoleBriefingSystem.cs new file mode 100644 index 0000000000..27cfdc1cad --- /dev/null +++ b/Content.Server/Roles/RoleBriefingSystem.cs @@ -0,0 +1,25 @@ +namespace Content.Server.Roles; + +public sealed class RoleBriefingSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnGetBriefing); + } + + private void OnGetBriefing(EntityUid uid, RoleBriefingComponent comp, ref GetBriefingEvent args) + { + if (args.Briefing == null) + { + // no previous briefing so just set it + args.Briefing = comp.Briefing; + } + else + { + // there is a previous briefing so append to it + args.Briefing += "\n" + comp.Briefing; + } + } +} diff --git a/Content.Server/Roles/RoleSystem.cs b/Content.Server/Roles/RoleSystem.cs index 54160d19e2..96f52150d9 100644 --- a/Content.Server/Roles/RoleSystem.cs +++ b/Content.Server/Roles/RoleSystem.cs @@ -17,7 +17,18 @@ public sealed class RoleSystem : SharedRoleSystem public string? MindGetBriefing(EntityUid? mindId) { - // TODO this should be an event - return CompOrNull(mindId)?.Briefing; + if (mindId == null) + return null; + + var ev = new GetBriefingEvent(); + RaiseLocalEvent(mindId.Value, ref ev); + return ev.Briefing; } } + +/// +/// Event raised on the mind to get its briefing. +/// Handlers can either replace or append to the briefing, whichever is more appropriate. +/// +[ByRefEvent] +public record struct GetBriefingEvent(string? Briefing = null); diff --git a/Content.Server/Roles/TraitorRoleComponent.cs b/Content.Server/Roles/TraitorRoleComponent.cs index 52e7d25ab7..6c436e76ac 100644 --- a/Content.Server/Roles/TraitorRoleComponent.cs +++ b/Content.Server/Roles/TraitorRoleComponent.cs @@ -5,5 +5,4 @@ namespace Content.Server.Roles; [RegisterComponent] public sealed partial class TraitorRoleComponent : AntagonistRoleComponent { - public string? Briefing; } diff --git a/Content.Shared/CharacterInfo/SharedCharacterInfoSystem.cs b/Content.Shared/CharacterInfo/SharedCharacterInfoSystem.cs index 7365229f2a..89b55e54fa 100644 --- a/Content.Shared/CharacterInfo/SharedCharacterInfoSystem.cs +++ b/Content.Shared/CharacterInfo/SharedCharacterInfoSystem.cs @@ -20,9 +20,9 @@ public sealed class CharacterInfoEvent : EntityEventArgs public readonly EntityUid EntityUid; public readonly string JobTitle; public readonly Dictionary> Objectives; - public readonly string Briefing; + public readonly string? Briefing; - public CharacterInfoEvent(EntityUid entityUid, string jobTitle, Dictionary> objectives, string briefing) + public CharacterInfoEvent(EntityUid entityUid, string jobTitle, Dictionary> objectives, string? briefing) { EntityUid = entityUid; JobTitle = jobTitle;