CatStation/Content.Server/EntityConditions/Conditions/ObjectiveTargetEntityConditionSystem.cs
Princess Cheeseballs c5f5a43dd7
Generic Target System (#43554)
* number 15

* evil

* borgar

* Generic Target System

* jafhfjasj

* borger

* whoops

* rename

* a

* whoop

* whoop

* thars your problem!

* asssssssssssssssssssssssssss

* fasfasfsa

* random

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2026-07-11 04:11:24 +00:00

38 lines
1.5 KiB
C#

using Content.Server.Objectives.Components;
using Content.Shared.EntityConditions;
using Content.Shared.EntityConditions.Conditions.Mind;
using Content.Shared.Mind;
using Content.Shared.Whitelist;
namespace Content.Server.EntityConditions.Conditions;
/// <summary>
/// Checks if the target entity, is an objective target of the given source mind entity.
/// Then filters by a whitelist, if any objectives pass the whitelist and target entity is a target, the condition passes.
/// Fails if the passed argument is null or not a mind.
/// </summary>
public sealed partial class ObjectiveTargetEntityConditionSystem : EntityConditionSystem<MindComponent, ObjectiveTargetCondition>
{
[Dependency] private EntityWhitelistSystem _whitelist = default!;
[Dependency] private EntityQuery<TargetObjectiveComponent> _targetQuery;
protected override void Condition(Entity<MindComponent> entity, ref EntityConditionEvent<ObjectiveTargetCondition> args)
{
if (!TryComp<MindComponent>(args.SourceEnt, out var mind))
return;
foreach (var objective in mind.Objectives)
{
// if the player has an objective targeting this mind
if (!_targetQuery.TryComp(objective, out var kill) || kill.Target != entity)
continue;
// remove the mind if this objective is blacklisted
if (!_whitelist.IsWhitelistPassOrNull(args.Condition.Whitelist, objective))
continue;
args.Result = true;
return;
}
}
}