introduce requirement to prevent from being tasked to steal your own item (#11139)

This commit is contained in:
Rane
2022-09-11 02:43:31 -04:00
committed by GitHub
parent 745a829976
commit fdba747541
2 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
using Content.Shared.Roles;
using Content.Server.Objectives.Interfaces;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Objectives.Requirements
{
[DataDefinition]
public sealed class NotRoleRequirement : IObjectiveRequirement
{
[DataField("roleId", customTypeSerializer:typeof(PrototypeIdSerializer<JobPrototype>))]
private string roleId = "";
/// <summary>
/// This requirement is met if the traitor is NOT the roleId, and fails if they are.
/// </summary>
public bool CanBeAssigned(Mind.Mind mind)
{
if (mind.CurrentJob == null) // no job no problems
return true;
return (mind.CurrentJob.Prototype.ID != roleId);
}
}
}