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.Roles;
|
|
|
|
|
using Content.Server.Traitor.Uplink;
|
2024-06-04 11:53:24 +00:00
|
|
|
using Content.Shared.GameTicking.Components;
|
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-09-16 07:18:10 +01:00
|
|
|
using Content.Shared.Objectives.Components;
|
2023-06-07 10:15:22 +03:00
|
|
|
using Content.Shared.PDA;
|
2024-08-23 11:14:38 +02:00
|
|
|
using Content.Shared.Radio;
|
2021-12-26 06:13:37 +03:00
|
|
|
using Content.Shared.Roles;
|
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;
|
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");
|
|
|
|
|
|
2021-12-21 21:23:29 +01:00
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
2023-07-17 15:51:52 +12:00
|
|
|
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
2024-04-24 21:31:45 -04:00
|
|
|
[Dependency] private readonly AntagSelectionSystem _antag = default!;
|
2022-08-17 00:34:25 -04:00
|
|
|
[Dependency] private readonly UplinkSystem _uplink = default!;
|
2023-06-18 11:33:19 -07:00
|
|
|
[Dependency] private readonly MindSystem _mindSystem = default!;
|
2023-08-30 21:46:11 -07:00
|
|
|
[Dependency] private readonly SharedRoleSystem _roleSystem = default!;
|
|
|
|
|
[Dependency] private readonly SharedJobSystem _jobs = default!;
|
2024-08-23 11:14:38 +02:00
|
|
|
[Dependency] private readonly SharedRoleCodewordSystem _roleCodewordSystem = default!;
|
2022-11-03 22:58:19 -04:00
|
|
|
|
2021-12-21 21:23:29 +01:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
protected override void Added(EntityUid uid, TraitorRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
|
|
|
|
|
{
|
|
|
|
|
base.Added(uid, component, gameRule, args);
|
2024-08-05 10:03:24 +02:00
|
|
|
SetCodewords(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-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-04-24 21:31:45 -04:00
|
|
|
MakeTraitor(args.EntityUid, ent);
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
2024-08-05 10:03:24 +02:00
|
|
|
private void SetCodewords(TraitorRuleComponent component)
|
|
|
|
|
{
|
|
|
|
|
component.Codewords = GenerateTraitorCodewords(component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string[] GenerateTraitorCodewords(TraitorRuleComponent component)
|
2022-07-20 05:46:23 -04:00
|
|
|
{
|
2024-04-24 21:31:45 -04:00
|
|
|
var adjectives = _prototypeManager.Index(component.CodewordAdjectives).Values;
|
|
|
|
|
var verbs = _prototypeManager.Index(component.CodewordVerbs).Values;
|
2022-07-20 05:46:23 -04:00
|
|
|
var codewordPool = adjectives.Concat(verbs).ToList();
|
2024-04-24 21:31:45 -04:00
|
|
|
var finalCodewordCount = Math.Min(component.CodewordCount, codewordPool.Count);
|
2024-08-05 10:03:24 +02:00
|
|
|
string[] codewords = new string[finalCodewordCount];
|
2022-07-20 05:46:23 -04:00
|
|
|
for (var i = 0; i < finalCodewordCount; i++)
|
|
|
|
|
{
|
2024-08-05 10:03:24 +02:00
|
|
|
codewords[i] = _random.PickAndTake(codewordPool);
|
2022-07-20 05:46:23 -04:00
|
|
|
}
|
2024-08-05 10:03:24 +02:00
|
|
|
return codewords;
|
2022-07-20 05:46:23 -04:00
|
|
|
}
|
|
|
|
|
|
2024-05-25 20:14:48 +00:00
|
|
|
public bool MakeTraitor(EntityUid traitor, TraitorRuleComponent component, bool giveUplink = true)
|
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
|
|
|
{
|
|
|
|
|
//Grab the mind if it wasnt provided
|
2023-08-28 16:53:24 -07:00
|
|
|
if (!_mindSystem.TryGetMind(traitor, out var mindId, out var mind))
|
2022-07-20 05:46:23 -04:00
|
|
|
return false;
|
2023-08-28 16:53:24 -07: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
|
|
|
var briefing = Loc.GetString("traitor-role-codewords-short", ("codewords", string.Join(", ", component.Codewords)));
|
2024-05-10 12:01:02 +10:00
|
|
|
var issuer = _random.Pick(_prototypeManager.Index(component.ObjectiveIssuers).Values);
|
2022-09-15 15:37:54 -04:00
|
|
|
|
2023-09-10 03:51:51 +01:00
|
|
|
Note[]? code = null;
|
|
|
|
|
if (giveUplink)
|
|
|
|
|
{
|
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;
|
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 (_jobs.MindTryGetJob(mindId, out _, out var prototype))
|
|
|
|
|
startingBalance = Math.Max(startingBalance - prototype.AntagAdvantage, 0);
|
|
|
|
|
|
2023-09-10 03:51:51 +01:00
|
|
|
// creadth: we need to create uplink for the antag.
|
|
|
|
|
// PDA should be in place already
|
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 pda = _uplink.FindUplinkTarget(traitor);
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
if (pda == null || !_uplink.AddUplink(traitor, startingBalance, giveDiscounts: true))
|
2023-09-10 03:51:51 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Give traitors their codewords and uplink code to keep in their character info menu
|
|
|
|
|
code = EnsureComp<RingerUplinkComponent>(pda.Value).Code;
|
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
|
|
|
|
2023-09-10 03:51:51 +01:00
|
|
|
// If giveUplink is false the uplink code part is omitted
|
|
|
|
|
briefing = string.Format("{0}\n{1}", 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
|
|
|
Loc.GetString("traitor-role-uplink-code-short", ("code", string.Join("-", code).Replace("sharp", "#"))));
|
2023-09-10 03:51:51 +01:00
|
|
|
}
|
2023-04-25 20:23:14 -04:00
|
|
|
|
2024-05-10 12:01:02 +10:00
|
|
|
_antag.SendBriefing(traitor, GenerateBriefing(component.Codewords, code, issuer), null, component.GreetSoundNotification);
|
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-08-23 11:14:38 +02: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
|
|
|
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
|
2023-08-31 22:29:45 +01:00
|
|
|
_roleSystem.MindAddRole(mindId, new RoleBriefingComponent
|
|
|
|
|
{
|
2024-04-24 21:31:45 -04:00
|
|
|
Briefing = 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
|
|
|
}, mind, true);
|
2021-12-21 21:23:29 +01:00
|
|
|
|
2024-08-23 11:14:38 +02:00
|
|
|
// 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<RoleCodewordComponent>(mindId);
|
|
|
|
|
_roleCodewordSystem.SetRoleCodewords(codewordComp, "traitor", component.Codewords.ToList(), color);
|
|
|
|
|
|
2023-06-07 10:15:22 +03:00
|
|
|
// Change the 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
|
|
|
|
2022-07-20 05:46:23 -04:00
|
|
|
return true;
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
args.Text += "\n" + Loc.GetString("traitor-round-end-codewords", ("codewords", string.Join(", ", comp.Codewords)));
|
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-05-10 12:01:02 +10: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-08-05 06:41:34 +02:00
|
|
|
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", "#"))));
|
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
|
|
|
}
|