Files
tbd-station-14/Content.Server/NPC/HTN/Preconditions/TargetInLOSPrecondition.cs
metalgearsloth c31c848afd Shooting NPCs and more (#18042)
* Add pirate shooting

* Shooting working

* Basics working

* Refactor time

* More conversion

* Update primitives

* Update yml

* weh

* Building again

* Draft

* weh

* b

* Start shutdown

* Starting to take form

* Code side done

* is it worky

* Fix prototypes

* stuff

* Shitty working

* Juke events working

* Even more cleanup

* RTX

* Fix interaction combat mode and compquery

* GetAmmoCount relays

* Fix rotation speed

* Juke fixes

* fixes

* weh

* The collision avoidance never ends

* Fixes

* Pause support

* framework

* lazy

* Fix idling

* Fix drip

* goobed

* Fix takeover shutdown bug

* Merge fixes

* shitter

* Fix carpos
2023-08-01 19:48:56 -05:00

34 lines
1020 B
C#

using Content.Server.Interaction;
namespace Content.Server.NPC.HTN.Preconditions;
public sealed class TargetInLOSPrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
private InteractionSystem _interaction = default!;
[DataField("targetKey")]
public string TargetKey = "Target";
[DataField("rangeKey")]
public string RangeKey = "RangeKey";
public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
_interaction = sysManager.GetEntitySystem<InteractionSystem>();
}
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);
return _interaction.InRangeUnobstructed(owner, target, range);
}
}