protected int m_Index;
protected float m_NextDestinationTime;
protected float m_PatrolPauseStartTime = -1f;
public int Index { get => m_Index; set => m_Index = value; }
public override void Pause(World world, Entity entity)
{
base.Pause(world, entity);
// Store the moment when the tree was paused.
if (m_PatrolPauseStartTime < 0f)
{
m_PatrolPauseStartTime = Time.time;
}
}
public override void Resume(World world, Entity entity)
{
base.Resume(world, entity);
if (m_PatrolPauseStartTime < 0f)
{
return;
}
var pausedDuration = Time.time - m_PatrolPauseStartTime;
// If it was waiting at a waypoint when paused, shift the wait timer.
if (m_NextDestinationTime >= 0f)
{
m_NextDestinationTime += pausedDuration;
}
m_PatrolPauseStartTime = -1f;
}