give revs briefing (#20749)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-10-05 16:05:09 +01:00
committed by GitHub
parent 14256dee03
commit a365568a7a
4 changed files with 42 additions and 11 deletions

View File

@@ -58,6 +58,7 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
SubscribeLocalEvent<CommandStaffComponent, MobStateChangedEvent>(OnCommandMobStateChanged); SubscribeLocalEvent<CommandStaffComponent, MobStateChangedEvent>(OnCommandMobStateChanged);
SubscribeLocalEvent<HeadRevolutionaryComponent, MobStateChangedEvent>(OnHeadRevMobStateChanged); SubscribeLocalEvent<HeadRevolutionaryComponent, MobStateChangedEvent>(OnHeadRevMobStateChanged);
SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEndText); SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEndText);
SubscribeLocalEvent<RevolutionaryRoleComponent, GetBriefingEvent>(OnGetBriefing);
SubscribeLocalEvent<HeadRevolutionaryComponent, AfterFlashedEvent>(OnPostFlash); SubscribeLocalEvent<HeadRevolutionaryComponent, AfterFlashedEvent>(OnPostFlash);
} }
@@ -118,6 +119,15 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
} }
} }
private void OnGetBriefing(EntityUid uid, RevolutionaryRoleComponent comp, ref GetBriefingEvent args)
{
if (!TryComp<MindComponent>(uid, out var mind) || mind.OwnedEntity == null)
return;
var head = HasComp<HeadRevolutionaryComponent>(mind.OwnedEntity);
args.Append(Loc.GetString(head ? "head-rev-briefing" : "rev-briefing"));
}
private void OnStartAttempt(RoundStartAttemptEvent ev) private void OnStartAttempt(RoundStartAttemptEvent ev)
{ {
var query = AllEntityQuery<RevolutionaryRuleComponent, GameRuleComponent>(); var query = AllEntityQuery<RevolutionaryRuleComponent, GameRuleComponent>();

View File

@@ -11,15 +11,6 @@ public sealed class RoleBriefingSystem : EntitySystem
private void OnGetBriefing(EntityUid uid, RoleBriefingComponent comp, ref GetBriefingEvent args) private void OnGetBriefing(EntityUid uid, RoleBriefingComponent comp, ref GetBriefingEvent args)
{ {
if (args.Briefing == null) args.Append(comp.Briefing);
{
// 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;
}
} }
} }

View File

@@ -35,4 +35,28 @@ public sealed class RoleSystem : SharedRoleSystem
/// Handlers can either replace or append to the briefing, whichever is more appropriate. /// Handlers can either replace or append to the briefing, whichever is more appropriate.
/// </summary> /// </summary>
[ByRefEvent] [ByRefEvent]
public record struct GetBriefingEvent(string? Briefing = null); public sealed class GetBriefingEvent
{
public string? Briefing;
public GetBriefingEvent(string? briefing = null)
{
Briefing = briefing;
}
/// <summary>
/// If there is no briefing, sets it to the string.
/// If there is a briefing, adds a new line to separate it from the appended string.
/// </summary>
public void Append(string text)
{
if (Briefing == null)
{
Briefing = text;
}
else
{
Briefing += "\n" + text;
}
}
}

View File

@@ -10,6 +10,10 @@ head-rev-role-greeting =
Beware, this won't work on Security, Command, or those wearing sunglasses. Beware, this won't work on Security, Command, or those wearing sunglasses.
Viva la revolución! Viva la revolución!
head-rev-briefing =
Use flashes to convert people to your cause.
Kill all heads to take over the station.
head-rev-initial-name = [color=#5e9cff]{$name}[/color] was one of the Head Revolutionaries. head-rev-initial-name = [color=#5e9cff]{$name}[/color] was one of the Head Revolutionaries.
head-rev-initial-name-user = [color=#5e9cff]{$name}[/color] ([color=gray]{$username}[/color]) was one of the Head Revolutionaries. head-rev-initial-name-user = [color=#5e9cff]{$name}[/color] ([color=gray]{$username}[/color]) was one of the Head Revolutionaries.
@@ -33,6 +37,8 @@ rev-role-greeting =
Eliminate all of the command staff. Eliminate all of the command staff.
Viva la revolución! Viva la revolución!
rev-briefing = Help your head revolutionaries kill every head to take over the station.
## General ## General
rev-title = Revolutionaries rev-title = Revolutionaries