Files
Delta-v/Content.Server/_DV/Objectives/Systems/NotJobsRequirementSystem.cs
T
deltanedasanddeltanedas ec94579ebc the great namespace refactor (#2574)
* refactor DeltaV/deltav resources to _DV

* change DeltaV namespaces to _DV

* add space before all DeltaV comments

* update xamls

* fix and move arena parallax to _DV

* more fix

* refactor even more stuff

* fix the grid fills

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
2025-01-01 07:50:34 +00:00

38 lines
1020 B
C#

using Content.Server.Objectives.Components;
using Content.Shared.Objectives.Components;
using Content.Shared.Roles;
namespace Content.Server.Objectives.Systems;
/// <summary>
/// Handles checking the job blacklist for this objective.
/// </summary>
public sealed class NotJobsRequirementSystem : EntitySystem
{
private EntityQuery<MindRoleComponent> _query;
public override void Initialize()
{
base.Initialize();
_query = GetEntityQuery<MindRoleComponent>();
SubscribeLocalEvent<NotJobsRequirementComponent, RequirementCheckEvent>(OnCheck);
}
private void OnCheck(Entity<NotJobsRequirementComponent> ent, ref RequirementCheckEvent args)
{
if (args.Cancelled)
return;
foreach (var forbidJob in ent.Comp.Jobs)
{
foreach (var roleId in args.Mind.MindRoles)
{
if (_query.CompOrNull(roleId)?.JobPrototype == forbidJob)
args.Cancelled = true;
}
}
}
}