Skip to content

Commit

Permalink
Adds NotJobsRequirement, which should probably replace NotJob
Browse files Browse the repository at this point in the history
  • Loading branch information
PHCodes committed Oct 28, 2023
1 parent 70c2fce commit 427760b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
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();
}
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;
}
}
6 changes: 6 additions & 0 deletions Resources/Prototypes/Nyanotrasen/Objectives/traitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
description: We need you to acquire psionics and keep them until your mission is complete.
noSpawn: true
components:
- type: NotJobsRequirement
jobs:
- Mime
- ForensicMantis
- type: Objective
difficulty: 2.5
#unique: false
Expand All @@ -35,6 +39,8 @@
# description: objective-condition-become-golem-description.
# noSpawn: true
# components:
# - type: NotJobRequirement
# job: Chaplain
# - type: Objective
# difficulty: 3.5
# #unique: false
Expand Down

0 comments on commit 427760b

Please sign in to comment.