diff --git a/dGame/dComponents/MovementAIComponent.cpp b/dGame/dComponents/MovementAIComponent.cpp index 81d49af7..bce5ec54 100644 --- a/dGame/dComponents/MovementAIComponent.cpp +++ b/dGame/dComponents/MovementAIComponent.cpp @@ -16,9 +16,9 @@ std::map MovementAIComponent::m_PhysicsSpeedCache = {}; MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) : Component(parent) { m_Info = std::move(info); m_Done = true; + m_IsPaused = false; m_BaseCombatAI = nullptr; - m_BaseCombatAI = reinterpret_cast(m_Parent->GetComponent(COMPONENT_TYPE_BASE_COMBAT_AI)); //Try and fix the insane values: @@ -36,16 +36,21 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) : m_Timer = 0; m_CurrentSpeed = 0; m_Speed = 0; + m_TotalTime = 0; m_LockRotation = false; + m_MovementPath = nullptr; m_isReverse = false; + + } MovementAIComponent::~MovementAIComponent() = default; void MovementAIComponent::Update(const float deltaTime) { + if (m_IsPaused) return; if (m_Interrupted) { const auto source = GetCurrentWaypoint(); @@ -66,7 +71,7 @@ void MovementAIComponent::Update(const float deltaTime) { return; } - if (AtFinalWaypoint()) return; // Are we donw? + if (AtFinalWaypoint()) return; // Are we done? if (m_HaltDistance > 0) { if (Vector3::DistanceSquared(ApproximateLocation(), GetDestination()) < m_HaltDistance * m_HaltDistance) { // Prevent us from hugging the target @@ -78,15 +83,13 @@ void MovementAIComponent::Update(const float deltaTime) { // Game::logger->Log("MovementAIComponent", "timer %f", m_Timer); if (m_Timer > 0) { m_Timer -= deltaTime; - - if (m_Timer > 0) { - return; - } - + if (m_Timer > 0) return; m_Timer = 0; } + const auto source = GetCurrentWaypoint(); + // We've arrived at a waypoint, do the things if we need to SetPosition(source); @@ -107,7 +110,7 @@ void MovementAIComponent::Update(const float deltaTime) { m_CurrentSpeed = m_Speed; } - const auto speed = m_CurrentSpeed * m_BaseSpeed; + const auto speed = m_BaseSpeed; const auto delta = m_NextWaypoint - source; diff --git a/dGame/dComponents/MovementAIComponent.h b/dGame/dComponents/MovementAIComponent.h index ee133888..1b46c7fa 100644 --- a/dGame/dComponents/MovementAIComponent.h +++ b/dGame/dComponents/MovementAIComponent.h @@ -343,6 +343,17 @@ private: * If we are reversing on a path */ bool m_isReverse; + + /** + * If we are waiting on a delay before moving + */ + bool m_IsWaiting; + + /** + * If we are paused for some reason + */ + bool m_IsPaused; + }; #endif // MOVEMENTAICOMPONENT_H