* Purge calls to obsolete EntityCoordinates methods * Pizza defruited; rerun those tests!
29 lines
985 B
C#
29 lines
985 B
C#
using Robust.Shared.Map;
|
|
|
|
namespace Content.Server.NPC.HTN.Preconditions;
|
|
|
|
/// <summary>
|
|
/// Is the specified coordinate not in range of us.
|
|
/// </summary>
|
|
public sealed partial class CoordinatesNotInRangePrecondition : HTNPrecondition
|
|
{
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
|
|
[DataField("targetKey", required: true)] public string TargetKey = default!;
|
|
|
|
[DataField("rangeKey", required: true)]
|
|
public string RangeKey = default!;
|
|
|
|
public override bool IsMet(NPCBlackboard blackboard)
|
|
{
|
|
if (!blackboard.TryGetValue<EntityCoordinates>(NPCBlackboard.OwnerCoordinates, out var coordinates, _entManager))
|
|
return false;
|
|
|
|
if (!blackboard.TryGetValue<EntityCoordinates>(TargetKey, out var target, _entManager))
|
|
return false;
|
|
|
|
return !coordinates.InRange(_entManager, _entManager.System<SharedTransformSystem>(), target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
|
|
}
|
|
}
|
|
|