Skip to content

Commit

Permalink
Applied AwareFoxy comment fix
Browse files Browse the repository at this point in the history
Co-authored-by: AwareFoxy <[email protected]>
  • Loading branch information
Tornado-Technology and AwareFoxy authored Nov 10, 2024
1 parent 1611f18 commit a0bded5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public sealed partial class TraitorRuleComponent : Component
public ProtoId<DatasetPrototype> CodewordVerbs = "verbs";

[DataField]
public ProtoId<DatasetPrototype> ObjectiveIssuers = "TraitorFlavor";
public ProtoId<DatasetPrototype> ObjectiveIssuers = "TraitorFlavor"; // Corvax-Next-Traitors

public int TotalTraitors => TraitorMinds.Count;
public string[] Codewords = new string[3];
public string ObjectiveIssuer = string.Empty;
public string ObjectiveIssuer = string.Empty; // Corvax-Next-Traitors

public enum SelectionState
{
Expand Down
12 changes: 8 additions & 4 deletions Content.Server/GameTicking/Rules/TraitorRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override void Initialize()

SubscribeLocalEvent<TraitorRuleComponent, AfterAntagEntitySelectedEvent>(AfterEntitySelected);

SubscribeLocalEvent<TraitorRuleComponent, ObjectivesTextGetInfoEvent>(OnObjectivesTextGetInfo, after: new[] { typeof(AntagSelectionSystem) });
SubscribeLocalEvent<TraitorRuleComponent, ObjectivesTextGetInfoEvent>(OnObjectivesTextGetInfo, after: new[] { typeof(AntagSelectionSystem) }); // Corvax-Next-Traitors
SubscribeLocalEvent<TraitorRuleComponent, ObjectivesTextPrependEvent>(OnObjectivesTextPrepend);
}

Expand Down Expand Up @@ -83,7 +83,7 @@ public bool MakeTraitor(EntityUid traitor, TraitorRuleComponent component, bool

var briefing = Loc.GetString("traitor-role-codewords-short", ("codewords", string.Join(", ", component.Codewords)));
var issuer = _random.Pick(_prototypeManager.Index(component.ObjectiveIssuers).Values);
component.ObjectiveIssuer = issuer;
component.ObjectiveIssuer = issuer; // Corvax-Next-Traitors

Note[]? code = null;
if (giveUplink)
Expand All @@ -103,15 +103,15 @@ public bool MakeTraitor(EntityUid traitor, TraitorRuleComponent component, bool
code = EnsureComp<RingerUplinkComponent>(pda.Value).Code;
}

_antag.SendBriefing(traitor, GenerateBriefing(component.Codewords, code, issuer), Color.Crimson, component.GreetSoundNotification);
_antag.SendBriefing(traitor, GenerateBriefing(component.Codewords, code, issuer), Color.Crimson, component.GreetSoundNotification); // Corvax-Next-Traitors


component.TraitorMinds.Add(mindId);

// Assign briefing
_roleSystem.MindAddRole(mindId, new RoleBriefingComponent
{
Briefing = GenerateBriefingCharacter(component.Codewords, code, issuer)
Briefing = GenerateBriefingCharacter(component.Codewords, code, issuer) // Corvax-Next-Traitors
}, mind, true);

// Send codewords to only the traitor client
Expand All @@ -127,10 +127,12 @@ public bool MakeTraitor(EntityUid traitor, TraitorRuleComponent component, bool
return true;
}

// Corvax-Next-Traitors-Start
private void OnObjectivesTextGetInfo(EntityUid uid, TraitorRuleComponent comp, ref ObjectivesTextGetInfoEvent args)
{
args.Faction = Loc.GetString($"traitor-round-end-agent-name");
}
// Corvax-Next-Traitors-End

// TODO: AntagCodewordsComponent
private void OnObjectivesTextPrepend(EntityUid uid, TraitorRuleComponent comp, ref ObjectivesTextPrependEvent args)
Expand All @@ -139,6 +141,7 @@ private void OnObjectivesTextPrepend(EntityUid uid, TraitorRuleComponent comp, r
}

// TODO: figure out how to handle this? add priority to briefing event?
// Corvax-Next-Traitors-Start
private string GenerateBriefing(string[] codewords, Note[]? uplinkCode, string objectiveIssuer)
{
var sb = new StringBuilder();
Expand Down Expand Up @@ -175,6 +178,7 @@ private string GenerateBriefingCharacter(string[] codewords, Note[]? uplinkCode,
sb.AppendLine(Loc.GetString($"traitor-{objectiveIssuer}-goal"));

sb.AppendLine("\n" + Loc.GetString($"traitor-role-clarity"));
// Corvax-Next-Traitors-End

return sb.ToString();
}
Expand Down
11 changes: 8 additions & 3 deletions Content.Server/Objectives/ObjectivesSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public override void Shutdown()
private void OnRoundEndText(RoundEndTextAppendEvent ev)
{
// go through each gamerule getting data for the roundend summary.
var summaries = new Dictionary<string, Dictionary<string, Dictionary<string, List<(EntityUid, string)>>>>();
var summaries = new Dictionary<string, Dictionary<string, Dictionary<string, List<(EntityUid, string)>>>>(); // Corvax-Next-Traitors

var query = EntityQueryEnumerator<GameRuleComponent>();
while (query.MoveNext(out var uid, out var gameRule))
{
Expand All @@ -65,6 +66,7 @@ private void OnRoundEndText(RoundEndTextAppendEvent ev)
continue;

// first group the gamerules by their factions, for example 2 different dragons
// Corvax-Next-Traitors-Start
var agent = info.Faction ?? info.AgentName;
if (!summaries.ContainsKey(agent))
summaries[agent] = new Dictionary<string, Dictionary<string, List<(EntityUid, string)>>>();
Expand Down Expand Up @@ -124,6 +126,8 @@ private void OnRoundEndText(RoundEndTextAppendEvent ev)

ev.AddLine(result.AppendLine().ToString());
}
// Corvax-Next-Traitors-End

}
}

Expand Down Expand Up @@ -259,7 +263,8 @@ private bool IsInCustody(EntityUid mindId, MindComponent? mind = null)
/// Get the title for a player's mind used in round end.
/// Pass in the original entity name which is shown alongside username.
/// </summary>
public string GetTitle(Entity<MindComponent?> mind, string name = "")
public string GetTitle(Entity<MindComponent?> mind, string name = "") // Corvax-Next-Traitors

{
if (Resolve(mind, ref mind.Comp) &&
mind.Comp.OriginalOwnerUserId != null &&
Expand Down Expand Up @@ -313,7 +318,7 @@ private void CreateCompletions()
/// The objectives system already checks if the game rule is added so you don't need to check that in this event's handler.
/// </remarks>
[ByRefEvent]
public record struct ObjectivesTextGetInfoEvent(List<(EntityUid, string)> Minds, string AgentName, string? Faction = null);
public record struct ObjectivesTextGetInfoEvent(List<(EntityUid, string)> Minds, string AgentName, string? Faction = null); // Corvax-Next-Traitors

/// <summary>
/// Raised on the game rule before text for each agent's objectives is added, letting you prepend something.
Expand Down

0 comments on commit a0bded5

Please sign in to comment.