mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-19 07:01:09 +03:00
* IDependencyCollection yippie * cleanup warnings * revert entityquery medibot cleanup * preconditions deps * i missed these * comment thing * used shared systems instead * sharedchatsystem :) * missed one * remove extra whitespace * dependency * conflict * PARTIAL * shakes fist * merge things --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using Content.Shared.Interaction;
|
|
using Content.Shared.Physics;
|
|
|
|
namespace Content.Server.NPC.HTN.Preconditions;
|
|
|
|
public sealed partial class TargetInLOSPrecondition : HTNPrecondition
|
|
{
|
|
[Dependency] private IEntityManager _entManager = default!;
|
|
[Dependency] private SharedInteractionSystem _interaction = default!;
|
|
|
|
[DataField("targetKey")]
|
|
public string TargetKey = "Target";
|
|
|
|
[DataField("rangeKey")]
|
|
public string RangeKey = "RangeKey";
|
|
|
|
[DataField("opaqueKey")]
|
|
public bool UseOpaqueForLOSChecksKey = true;
|
|
|
|
public override bool IsMet(NPCBlackboard blackboard)
|
|
{
|
|
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
|
|
|
if (!blackboard.TryGetValue<EntityUid>(TargetKey, out var target, _entManager))
|
|
return false;
|
|
|
|
var range = blackboard.GetValueOrDefault<float>(RangeKey, _entManager);
|
|
var collisionGroup = UseOpaqueForLOSChecksKey ? CollisionGroup.Opaque : (CollisionGroup.Impassable | CollisionGroup.InteractImpassable);
|
|
|
|
return _interaction.InRangeUnobstructed(owner, target, range, collisionGroup);
|
|
}
|
|
}
|