Update ControllablePhysicsComponent.cpp

This commit is contained in:
David Markowitz
2024-12-30 23:36:24 -08:00
parent 0540f23184
commit 2df65a64fc

View File

@@ -16,6 +16,7 @@
#include "eStateChangeType.h"
#include "MovementAIComponent.h"
#include "QuickBuildComponent.h"
#include "BaseCombatAIComponent.h"
ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity, int32_t componentId) : PhysicsComponent(entity, componentId) {
m_Velocity = {};
@@ -69,11 +70,13 @@ ControllablePhysicsComponent::~ControllablePhysicsComponent() {
void ControllablePhysicsComponent::Update(float deltaTime) {
if (m_Parent->IsPlayer()) return;
if (m_Parent->GetComponent<BaseCombatAIComponent>()) return; // let combat ai take care of this
auto* movementAI = m_Parent->GetComponent<MovementAIComponent>();
if (movementAI && (!movementAI->AtFinalWaypoint() || movementAI->IsPaused())) return;
if (movementAI && (!movementAI->AtFinalWaypoint() || movementAI->IsPaused())) return; // let movement ai handle it
auto* const quickBuildComponent = m_Parent->GetComponent<QuickBuildComponent>();
if (quickBuildComponent && quickBuildComponent->GetState() != eQuickBuildState::COMPLETED) return;
if (quickBuildComponent && quickBuildComponent->GetState() != eQuickBuildState::COMPLETED) return; // quickbulds dont move while not built
SetPosition(m_Position + m_Velocity * deltaTime);
Game::entityManager->SerializeEntity(m_Parent);