2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind;
|
|
|
|
|
using Content.Shared.Objectives.Interfaces;
|
2023-08-28 16:53:24 -07:00
|
|
|
using Content.Shared.Roles;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Roles.Jobs;
|
2022-09-11 02:43:31 -04:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Objectives.Requirements
|
|
|
|
|
{
|
|
|
|
|
[DataDefinition]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class NotRoleRequirement : IObjectiveRequirement
|
2022-09-11 02:43:31 -04:00
|
|
|
{
|
2023-07-30 05:34:51 +12:00
|
|
|
[DataField("roleId", customTypeSerializer:typeof(PrototypeIdSerializer<JobPrototype>), required:true)]
|
|
|
|
|
private string _roleId = default!;
|
2022-09-11 02:43:31 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This requirement is met if the traitor is NOT the roleId, and fails if they are.
|
|
|
|
|
/// </summary>
|
2023-08-28 16:53:24 -07:00
|
|
|
public bool CanBeAssigned(EntityUid mindId, MindComponent mind)
|
2022-09-11 02:43:31 -04:00
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
// TODO ECS this shit i keep seeing shitcode everywhere
|
|
|
|
|
var entities = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
if (!entities.TryGetComponent(mindId, out JobComponent? job))
|
2022-09-11 02:43:31 -04:00
|
|
|
return true;
|
|
|
|
|
|
2023-08-28 16:53:24 -07:00
|
|
|
return job.PrototypeId != _roleId;
|
2022-09-11 02:43:31 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|