Add reversing

This commit is contained in:
David Markowitz 2023-08-07 01:46:03 -07:00
parent aa734ef7ae
commit b546c96193
2 changed files with 18 additions and 0 deletions

View File

@ -141,6 +141,15 @@ nextAction:
Game::entityManager->SerializeEntity(m_Parent);
}
void MovementAIComponent::ReversePath() {
if (m_CurrentPath.empty()) return;
if (m_NextPathWaypointIndex < 0) m_NextPathWaypointIndex = 0;
if (m_NextPathWaypointIndex >= m_CurrentPath.size()) m_NextPathWaypointIndex = m_CurrentPath.size() - 1;
m_CurrentPathWaypointIndex = m_NextPathWaypointIndex;
m_IsInReverse = !m_IsInReverse;
AdvancePathWaypointIndex();
}
bool MovementAIComponent::AdvancePathWaypointIndex() {
m_CurrentPathWaypointIndex = m_NextPathWaypointIndex;
if (m_IsInReverse) {

View File

@ -175,8 +175,15 @@ public:
bool IsPaused() const { return m_IsPaused; }
/**
* Pauses the current pathing of this entity. The current path waypoint will be saved for resuming later.
*/
void Pause();
/**
* Resumes pathing from the current position to the destination that was set
* when the entity was paused.
*/
void Resume();
/**
@ -184,6 +191,8 @@ public:
*/
void Stop();
void ReversePath();
/**
* Stops the current movement and moves the entity to a certain point. Will continue until it's close enough,
* after which its AI is enabled again.