* Initial commit * Updated Access/command.yml * Fix for Access/AccessLevelPrototype.cs * Added silicon access levels to admin items * Included self-recharging battery changes * Revert "Included self-recharging battery changes" * Addressed reviewers comments * Additional reviewer comments
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using Content.Server.Interaction;
|
|
using Content.Shared.Physics;
|
|
|
|
namespace Content.Server.NPC.HTN.Preconditions;
|
|
|
|
public sealed partial 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";
|
|
|
|
[DataField("opaqueKey")]
|
|
public bool UseOpaqueForLOSChecksKey = true;
|
|
|
|
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);
|
|
var collisionGroup = UseOpaqueForLOSChecksKey ? CollisionGroup.Opaque : (CollisionGroup.Impassable | CollisionGroup.InteractImpassable);
|
|
|
|
return _interaction.InRangeUnobstructed(owner, target, range, collisionGroup);
|
|
}
|
|
}
|