Files
tbd-station-14/Content.Server/NPC/HTN/Preconditions/CoordinatesNotInRangePrecondition.cs
Plykiya b7aa97e203 Replace obsolete EntityCoordiates.InRange() with TransformSystem.InRange() (#29993)
* Replace EntityCoordiates.InRange() with TransformSystem.InRange()

* nullspace

* I figured it out

* man I have no clue how client side sutff works

* please have mercy

* remove RadiationPulseOverlay changes

* nullspace

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
2024-07-13 23:25:51 +02:00

36 lines
1.2 KiB
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!;
private SharedTransformSystem _transformSystem = default!;
[DataField("targetKey", required: true)] public string TargetKey = default!;
[DataField("rangeKey", required: true)]
public string RangeKey = default!;
public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
_transformSystem = sysManager.GetEntitySystem<SharedTransformSystem>();
}
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 !_transformSystem.InRange(coordinates, target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
}
}