2023-12-24 12:58:28 +03:00
|
|
|
using Content.Server.Antag;
|
2023-04-25 20:23:14 -04:00
|
|
|
using Content.Server.GameTicking.Rules.Components;
|
2023-06-18 11:33:19 -07:00
|
|
|
using Content.Server.Mind;
|
2023-08-28 16:53:24 -07:00
|
|
|
using Content.Server.Objectives;
|
2023-04-23 21:00:42 +00:00
|
|
|
using Content.Server.PDA.Ringer;
|
2021-12-21 21:23:29 +01:00
|
|
|
using Content.Server.Traitor.Uplink;
|
2024-10-18 14:55:43 +02:00
|
|
|
using Content.Shared.FixedPoint;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind;
|
2024-03-18 07:23:25 +00:00
|
|
|
using Content.Shared.NPC.Systems;
|
2023-06-07 10:15:22 +03:00
|
|
|
using Content.Shared.PDA;
|
2025-03-10 05:20:05 +03:00
|
|
|
using Content.Shared.Random.Helpers;
|
2021-12-26 06:13:37 +03:00
|
|
|
using Content.Shared.Roles;
|
2025-08-13 12:51:46 +02:00
|
|
|
using Content.Shared.Roles.Components;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Roles.Jobs;
|
2024-08-23 11:14:38 +02:00
|
|
|
using Content.Shared.Roles.RoleCodeword;
|
2021-12-21 21:23:29 +01:00
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
using Robust.Shared.Random;
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2025-06-06 01:19:41 +02:00
|
|
|
using Content.Server.Codewords;
|
2021-12-21 21:23:29 +01:00
|
|
|
|
|
|
|
|
namespace Content.Server.GameTicking.Rules;
|
|
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
|
2021-12-21 21:23:29 +01:00
|
|
|
{
|
2024-08-23 11:14:38 +02:00
|
|
|
private static readonly Color TraitorCodewordColor = Color.FromHex("#cc3b3b");
|
|
|
|
|
|
2024-04-24 21:31:45 -04:00
|
|
|
[Dependency] private readonly AntagSelectionSystem _antag = default!;
|
2023-08-30 21:46:11 -07:00
|
|
|
[Dependency] private readonly SharedJobSystem _jobs = default!;
|
2024-10-10 10:48:56 +02:00
|
|
|
[Dependency] private readonly MindSystem _mindSystem = default!;
|
|
|
|
|
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
|
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
2024-08-23 11:14:38 +02:00
|
|
|
[Dependency] private readonly SharedRoleCodewordSystem _roleCodewordSystem = default!;
|
2024-10-10 10:48:56 +02:00
|
|
|
[Dependency] private readonly SharedRoleSystem _roleSystem = default!;
|
|
|
|
|
[Dependency] private readonly UplinkSystem _uplink = default!;
|
2025-06-06 01:19:41 +02:00
|
|
|
[Dependency] private readonly CodewordSystem _codewordSystem = default!;
|
2022-11-03 22:58:19 -04:00
|
|
|
|
2021-12-21 21:23:29 +01:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Level = LogLevel.Debug;
|
|
|
|
|
|
2024-04-24 21:31:45 -04:00
|
|
|
SubscribeLocalEvent<TraitorRuleComponent, AfterAntagEntitySelectedEvent>(AfterEntitySelected);
|
2023-09-04 05:55:34 +01:00
|
|
|
SubscribeLocalEvent<TraitorRuleComponent, ObjectivesTextPrependEvent>(OnObjectivesTextPrepend);
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
2024-04-24 21:31:45 -04:00
|
|
|
private void AfterEntitySelected(Entity<TraitorRuleComponent> ent, ref AfterAntagEntitySelectedEvent args)
|
2023-04-24 16:21:05 +10:00
|
|
|
{
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"AfterAntagEntitySelected {ToPrettyString(ent)}");
|
2024-04-24 21:31:45 -04:00
|
|
|
MakeTraitor(args.EntityUid, ent);
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
2024-10-18 14:55:43 +02:00
|
|
|
public bool MakeTraitor(EntityUid traitor, TraitorRuleComponent component)
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
{
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - start");
|
2025-06-06 01:19:41 +02:00
|
|
|
var factionCodewords = _codewordSystem.GetCodewords(component.CodewordFactionPrototypeId);
|
2024-11-08 03:46:22 -08:00
|
|
|
|
2024-10-10 10:48:56 +02:00
|
|
|
//Grab the mind if it wasn't provided
|
2023-08-28 16:53:24 -07:00
|
|
|
if (!_mindSystem.TryGetMind(traitor, out var mindId, out var mind))
|
2024-11-08 03:46:22 -08:00
|
|
|
{
|
|
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - failed, no Mind found");
|
2022-07-20 05:46:23 -04:00
|
|
|
return false;
|
2024-11-08 03:46:22 -08:00
|
|
|
}
|
2023-08-28 16:53:24 -07:00
|
|
|
|
2024-10-18 14:55:43 +02:00
|
|
|
var briefing = "";
|
|
|
|
|
|
|
|
|
|
if (component.GiveCodewords)
|
2024-11-08 03:46:22 -08:00
|
|
|
{
|
|
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - added codewords flufftext to briefing");
|
2025-06-06 01:19:41 +02:00
|
|
|
briefing = Loc.GetString("traitor-role-codewords-short", ("codewords", string.Join(", ", factionCodewords)));
|
2024-11-08 03:46:22 -08:00
|
|
|
}
|
2024-10-18 14:55:43 +02:00
|
|
|
|
2025-03-10 05:20:05 +03:00
|
|
|
var issuer = _random.Pick(_prototypeManager.Index(component.ObjectiveIssuers));
|
2022-09-15 15:37:54 -04:00
|
|
|
|
2024-10-18 14:55:43 +02:00
|
|
|
// Uplink code will go here if applicable, but we still need the variable if there aren't any
|
2023-09-10 03:51:51 +01:00
|
|
|
Note[]? code = null;
|
2024-10-18 14:55:43 +02:00
|
|
|
|
|
|
|
|
if (component.GiveUplink)
|
2023-09-10 03:51:51 +01:00
|
|
|
{
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Uplink start");
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
// Calculate the amount of currency on the uplink.
|
2024-04-24 21:31:45 -04:00
|
|
|
var startingBalance = component.StartingBalance;
|
2024-10-10 10:48:56 +02:00
|
|
|
if (_jobs.MindTryGetJob(mindId, out var prototype))
|
2024-10-18 14:55:43 +02:00
|
|
|
{
|
|
|
|
|
if (startingBalance < prototype.AntagAdvantage) // Can't use Math functions on FixedPoint2
|
|
|
|
|
startingBalance = 0;
|
|
|
|
|
else
|
|
|
|
|
startingBalance = startingBalance - prototype.AntagAdvantage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Choose and generate an Uplink, and return the uplink code if applicable
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Uplink request start");
|
2024-10-18 14:55:43 +02:00
|
|
|
var uplinkParams = RequestUplink(traitor, startingBalance, briefing);
|
|
|
|
|
code = uplinkParams.Item1;
|
|
|
|
|
briefing = uplinkParams.Item2;
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Uplink request completed");
|
2023-09-10 03:51:51 +01:00
|
|
|
}
|
2023-04-25 20:23:14 -04:00
|
|
|
|
2024-10-18 14:55:43 +02:00
|
|
|
string[]? codewords = null;
|
|
|
|
|
if (component.GiveCodewords)
|
2024-11-08 03:46:22 -08:00
|
|
|
{
|
|
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - set codewords from component");
|
2025-06-06 01:19:41 +02:00
|
|
|
codewords = factionCodewords;
|
2024-11-08 03:46:22 -08:00
|
|
|
}
|
2024-10-18 14:55:43 +02:00
|
|
|
|
|
|
|
|
if (component.GiveBriefing)
|
2024-11-08 03:46:22 -08:00
|
|
|
{
|
2024-10-18 14:55:43 +02:00
|
|
|
_antag.SendBriefing(traitor, GenerateBriefing(codewords, code, issuer), null, component.GreetSoundNotification);
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Sent the Briefing");
|
|
|
|
|
}
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Adding TraitorMind");
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
component.TraitorMinds.Add(mindId);
|
2023-06-07 10:15:22 +03:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
// Assign briefing
|
2024-10-10 10:48:56 +02:00
|
|
|
//Since this provides neither an antag/job prototype, nor antag status/roletype,
|
|
|
|
|
//and is intrinsically related to the traitor role
|
|
|
|
|
//it does not need to be a separate Mind Role Entity
|
|
|
|
|
_roleSystem.MindHasRole<TraitorRoleComponent>(mindId, out var traitorRole);
|
|
|
|
|
if (traitorRole is not null)
|
2023-08-31 22:29:45 +01:00
|
|
|
{
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Add traitor briefing components");
|
2025-07-28 18:50:49 +06:00
|
|
|
EnsureComp<RoleBriefingComponent>(traitorRole.Value.Owner, out var briefingComp);
|
|
|
|
|
briefingComp.Briefing = briefing;
|
2024-10-10 10:48:56 +02:00
|
|
|
}
|
2024-11-08 03:46:22 -08:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - did not get traitor briefing");
|
|
|
|
|
}
|
2021-12-21 21:23:29 +01:00
|
|
|
|
2024-08-23 11:14:38 +02:00
|
|
|
var color = TraitorCodewordColor; // Fall back to a dark red Syndicate color if a prototype is not found
|
|
|
|
|
|
2025-06-27 02:27:25 +02:00
|
|
|
// The mind entity is stored in nullspace with a PVS override for the owner, so only they can see the codewords.
|
|
|
|
|
var codewordComp = EnsureComp<RoleCodewordComponent>(mindId);
|
|
|
|
|
_roleCodewordSystem.SetRoleCodewords((mindId, codewordComp), "traitor", factionCodewords.ToList(), color);
|
2024-08-23 11:14:38 +02:00
|
|
|
|
2023-06-07 10:15:22 +03:00
|
|
|
// Change the faction
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Change faction");
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
_npcFaction.RemoveFaction(traitor, component.NanoTrasenFaction, false);
|
|
|
|
|
_npcFaction.AddFaction(traitor, component.SyndicateFaction);
|
2023-01-01 20:18:47 -05:00
|
|
|
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Finished");
|
2022-07-20 05:46:23 -04:00
|
|
|
return true;
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
2024-10-18 14:55:43 +02:00
|
|
|
private (Note[]?, string) RequestUplink(EntityUid traitor, FixedPoint2 startingBalance, string briefing)
|
|
|
|
|
{
|
|
|
|
|
var pda = _uplink.FindUplinkTarget(traitor);
|
|
|
|
|
Note[]? code = null;
|
|
|
|
|
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Uplink add");
|
2024-10-18 14:55:43 +02:00
|
|
|
var uplinked = _uplink.AddUplink(traitor, startingBalance, pda, true);
|
|
|
|
|
|
|
|
|
|
if (pda is not null && uplinked)
|
|
|
|
|
{
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Uplink is PDA");
|
2024-10-18 14:55:43 +02:00
|
|
|
// Codes are only generated if the uplink is a PDA
|
2025-04-19 15:55:05 +02:00
|
|
|
var ev = new GenerateUplinkCodeEvent();
|
|
|
|
|
RaiseLocalEvent(pda.Value, ref ev);
|
2024-10-18 14:55:43 +02:00
|
|
|
|
2025-04-19 15:55:05 +02:00
|
|
|
if (ev.Code is { } generatedCode)
|
|
|
|
|
{
|
|
|
|
|
code = generatedCode;
|
|
|
|
|
|
|
|
|
|
// If giveUplink is false the uplink code part is omitted
|
|
|
|
|
briefing = string.Format("{0}\n{1}",
|
|
|
|
|
briefing,
|
|
|
|
|
Loc.GetString("traitor-role-uplink-code-short", ("code", string.Join("-", code).Replace("sharp", "#"))));
|
|
|
|
|
return (code, briefing);
|
|
|
|
|
}
|
2024-10-18 14:55:43 +02:00
|
|
|
}
|
|
|
|
|
else if (pda is null && uplinked)
|
|
|
|
|
{
|
2024-11-08 03:46:22 -08:00
|
|
|
Log.Debug($"MakeTraitor {ToPrettyString(traitor)} - Uplink is implant");
|
2024-10-18 14:55:43 +02:00
|
|
|
briefing += "\n" + Loc.GetString("traitor-role-uplink-implant-short");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (null, briefing);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-25 20:14:48 +00:00
|
|
|
// TODO: AntagCodewordsComponent
|
2023-09-04 05:55:34 +01:00
|
|
|
private void OnObjectivesTextPrepend(EntityUid uid, TraitorRuleComponent comp, ref ObjectivesTextPrependEvent args)
|
|
|
|
|
{
|
2024-11-05 19:18:28 +01:00
|
|
|
if(comp.GiveCodewords)
|
2025-06-06 01:19:41 +02:00
|
|
|
args.Text += "\n" + Loc.GetString("traitor-round-end-codewords", ("codewords", string.Join(", ", _codewordSystem.GetCodewords(comp.CodewordFactionPrototypeId))));
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
2022-11-03 22:58:19 -04:00
|
|
|
|
2024-05-25 20:14:48 +00:00
|
|
|
// TODO: figure out how to handle this? add priority to briefing event?
|
2024-10-18 14:55:43 +02:00
|
|
|
private string GenerateBriefing(string[]? codewords, Note[]? uplinkCode, string? objectiveIssuer = null)
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
2024-05-10 12:01:02 +10:00
|
|
|
sb.AppendLine(Loc.GetString("traitor-role-greeting", ("corporation", objectiveIssuer ?? Loc.GetString("objective-issuer-unknown"))));
|
2024-10-18 14:55:43 +02:00
|
|
|
if (codewords != null)
|
|
|
|
|
sb.AppendLine(Loc.GetString("traitor-role-codewords", ("codewords", string.Join(", ", codewords))));
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
if (uplinkCode != null)
|
2024-08-05 06:41:34 +02:00
|
|
|
sb.AppendLine(Loc.GetString("traitor-role-uplink-code", ("code", string.Join("-", uplinkCode).Replace("sharp", "#"))));
|
2024-10-18 14:55:43 +02:00
|
|
|
else
|
|
|
|
|
sb.AppendLine(Loc.GetString("traitor-role-uplink-implant"));
|
|
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-28 16:53:24 -07:00
|
|
|
public List<(EntityUid Id, MindComponent Mind)> GetOtherTraitorMindsAliveAndConnected(MindComponent ourMind)
|
2022-11-03 22:58:19 -04:00
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
List<(EntityUid Id, MindComponent Mind)> allTraitors = new();
|
2024-04-24 21:31:45 -04:00
|
|
|
|
|
|
|
|
var query = EntityQueryEnumerator<TraitorRuleComponent>();
|
|
|
|
|
while (query.MoveNext(out var uid, out var traitor))
|
2023-04-25 20:23:14 -04:00
|
|
|
{
|
2024-04-24 21:31:45 -04:00
|
|
|
foreach (var role in GetOtherTraitorMindsAliveAndConnected(ourMind, (uid, traitor)))
|
2023-04-25 20:23:14 -04:00
|
|
|
{
|
|
|
|
|
if (!allTraitors.Contains(role))
|
|
|
|
|
allTraitors.Add(role);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-03 22:58:19 -04:00
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
return allTraitors;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-24 21:31:45 -04:00
|
|
|
private List<(EntityUid Id, MindComponent Mind)> GetOtherTraitorMindsAliveAndConnected(MindComponent ourMind, Entity<TraitorRuleComponent> rule)
|
2023-04-25 20:23:14 -04:00
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
var traitors = new List<(EntityUid Id, MindComponent Mind)>();
|
2024-04-24 21:31:45 -04:00
|
|
|
foreach (var mind in _antag.GetAntagMinds(rule.Owner))
|
2023-08-28 16:53:24 -07:00
|
|
|
{
|
2024-04-24 21:31:45 -04:00
|
|
|
if (mind.Comp == ourMind)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
traitors.Add((mind, mind));
|
2023-08-28 16:53:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return traitors;
|
2022-11-03 22:58:19 -04:00
|
|
|
}
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|