antag objective issuing refactor (#28216)
* add AntagObjectives from GenericAntag * add AntagRandomObjectives that traitor and thief can use * make ObjectivesSystem use initial character name which AntagSelection passes * make thief and traitor use AntagRandomObjectives * remove now unused locale * make sleeper agents rule use baseTraitorRule * restore dragon rule oop * bandaid for genericantag * real * typo --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
35
Content.Server/Antag/AntagObjectivesSystem.cs
Normal file
35
Content.Server/Antag/AntagObjectivesSystem.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Content.Server.Antag.Components;
|
||||
using Content.Server.Objectives;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Objectives.Systems;
|
||||
|
||||
namespace Content.Server.Antag;
|
||||
|
||||
/// <summary>
|
||||
/// Adds fixed objectives to an antag made with <c>AntagObjectivesComponent</c>.
|
||||
/// </summary>
|
||||
public sealed class AntagObjectivesSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedMindSystem _mind = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<AntagObjectivesComponent, AfterAntagEntitySelectedEvent>(OnAntagSelected);
|
||||
}
|
||||
|
||||
private void OnAntagSelected(Entity<AntagObjectivesComponent> ent, ref AfterAntagEntitySelectedEvent args)
|
||||
{
|
||||
if (!_mind.TryGetMind(args.Session, out var mindId, out var mind))
|
||||
{
|
||||
Log.Error($"Antag {ToPrettyString(args.EntityUid):player} was selected by {ToPrettyString(ent):rule} but had no mind attached!");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var id in ent.Comp.Objectives)
|
||||
{
|
||||
_mind.TryAddObjective(mindId, mind, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user