* 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>
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using Robust.Shared.Map;
|
|
|
|
namespace Content.Server.NPC.HTN.Preconditions;
|
|
|
|
/// <summary>
|
|
/// Is the specified key within the specified range of us.
|
|
/// </summary>
|
|
public sealed partial class TargetInRangePrecondition : 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<EntityUid>(TargetKey, out var target, _entManager) ||
|
|
!_entManager.TryGetComponent<TransformComponent>(target, out var targetXform))
|
|
return false;
|
|
|
|
var transformSystem = _entManager.System<SharedTransformSystem>;
|
|
return _transformSystem.InRange(coordinates, targetXform.Coordinates, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
|
|
}
|
|
}
|