2021-09-19 20:33:51 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.Behaviours.Peds.AI
|
|
|
|
{
|
2021-09-26 18:26:56 +00:00
|
|
|
public class EscapeState : BaseState, IPathMovementState
|
2021-09-19 20:33:51 +00:00
|
|
|
{
|
|
|
|
private readonly PathMovementData _pathMovementData = new PathMovementData();
|
2021-09-26 18:26:56 +00:00
|
|
|
public PathMovementData PathMovementData => _pathMovementData;
|
2021-09-19 20:33:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
public override void UpdateState()
|
|
|
|
{
|
|
|
|
// TODO: exit vehicle
|
|
|
|
|
|
|
|
if (PedAI.ArrivedAtDestinationNode(_pathMovementData, _ped.transform))
|
|
|
|
PedAI.OnArrivedToDestinationNode(_pathMovementData);
|
|
|
|
|
|
|
|
if (!_pathMovementData.destinationNode.HasValue)
|
|
|
|
{
|
|
|
|
PedAI.FindClosestWalkableNode(_pathMovementData, _ped.transform.position);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.MyPed.IsSprintOn = true;
|
|
|
|
this.MyPed.Movement = (_pathMovementData.moveDestination - this.MyPed.transform.position).normalized;
|
|
|
|
this.MyPed.Heading = this.MyPed.Movement;
|
|
|
|
}
|
2021-09-26 18:17:17 +00:00
|
|
|
|
|
|
|
protected internal override void OnDrawGizmosSelected()
|
|
|
|
{
|
|
|
|
PedAI.OnDrawGizmosSelected(_pathMovementData);
|
|
|
|
}
|
2021-09-19 20:33:51 +00:00
|
|
|
}
|
|
|
|
}
|