Objectives ecs rework (#19967)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-09-16 07:18:10 +01:00
committed by GitHub
parent e8c58d1574
commit f7711edbe3
106 changed files with 2121 additions and 1779 deletions

View File

@@ -0,0 +1,28 @@
using Content.Server.Objectives.Components;
using Content.Shared.Objectives.Components;
namespace Content.Server.Objectives.Systems;
/// <summary>
/// Handles role requirement for objectives that require a certain (probably antagonist) role(s).
/// </summary>
public sealed class RoleRequirementSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RoleRequirementComponent, RequirementCheckEvent>(OnCheck);
}
private void OnCheck(EntityUid uid, RoleRequirementComponent comp, ref RequirementCheckEvent args)
{
if (args.Cancelled)
return;
// this whitelist trick only works because roles are components on the mind and not entities
// if that gets reworked then this will need changing
if (!comp.Roles.IsValid(args.MindId, EntityManager))
args.Cancelled = true;
}
}