NPC Steering refactor (#10190)

Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2022-08-03 16:02:50 +10:00
committed by GitHub
parent 4fc4567a9c
commit 098b536fb8
8 changed files with 480 additions and 840 deletions

View File

@@ -68,6 +68,13 @@ namespace Content.Server.AI.Operators.Combat.Melee
public override Outcome Execute(float frameTime)
{
if (_unarmedCombat == null ||
!_entMan.GetComponent<TransformComponent>(_target).Coordinates.TryDistance(_entMan, _entMan.GetComponent<TransformComponent>(_owner).Coordinates, out var distance) || distance >
_unarmedCombat.Range)
{
return Outcome.Failed;
}
if (_burstTime <= _elapsedTime)
{
return Outcome.Success;
@@ -78,12 +85,6 @@ namespace Content.Server.AI.Operators.Combat.Melee
return Outcome.Failed;
}
if ((_entMan.GetComponent<TransformComponent>(_target).Coordinates.Position - _entMan.GetComponent<TransformComponent>(_owner).Coordinates.Position).Length >
_unarmedCombat.Range)
{
return Outcome.Failed;
}
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
interactionSystem.AiUseInteraction(_owner, _entMan.GetComponent<TransformComponent>(_target).Coordinates, _target);
_elapsedTime += frameTime;