-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds NotJobsRequirement, which should probably replace NotJob
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Content.Server/DeltaV/Objectives/Components/NotJobsRequirementComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Content.Server.Objectives.Systems; | ||
using Content.Shared.Roles; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; | ||
|
||
/// <summary> | ||
/// Requires that the player not have a certain job to have this objective. | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(NotJobsRequirementSystem))] | ||
public sealed partial class NotJobsRequirementComponent : Component | ||
{ | ||
/// <summary> | ||
/// ID of the job to ban from having this objective. | ||
/// </summary> | ||
[DataField(required: true, customTypeSerializer: typeof(PrototypeIdListSerializer<JobPrototype>))] | ||
public List<string> Jobs = new(); | ||
} |
31 changes: 31 additions & 0 deletions
31
Content.Server/DeltaV/Objectives/Systems/NotJobsRequirementSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Content.Server.Objectives.Components; | ||
using Content.Shared.Objectives.Components; | ||
using Content.Shared.Roles.Jobs; | ||
|
||
namespace Content.Server.Objectives.Systems; | ||
|
||
/// <summary> | ||
/// Handles checking the job blacklist for this objective. | ||
/// </summary> | ||
public sealed class NotJobsRequirementSystem : EntitySystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<NotJobsRequirementComponent, RequirementCheckEvent>(OnCheck); | ||
} | ||
|
||
private void OnCheck(EntityUid uid, NotJobsRequirementComponent comp, ref RequirementCheckEvent args) | ||
{ | ||
if (args.Cancelled) | ||
return; | ||
|
||
// if player has no job then don't care | ||
if (!TryComp<JobComponent>(args.MindId, out var job)) | ||
return; | ||
foreach (string forbidJob in comp.Jobs) | ||
if (job.PrototypeId == forbidJob) | ||
args.Cancelled = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters