add movementAI on load

This commit is contained in:
David Markowitz 2023-08-07 19:23:17 -07:00
parent ed0c979544
commit 4fbd536e74
2 changed files with 13 additions and 11 deletions

View File

@ -707,15 +707,15 @@ void Entity::Initialize() {
if (path->pathType == PathType::MovingPlatform) { if (path->pathType == PathType::MovingPlatform) {
MovingPlatformComponent* plat = new MovingPlatformComponent(this, pathName); MovingPlatformComponent* plat = new MovingPlatformComponent(this, pathName);
m_Components.insert(std::make_pair(eReplicaComponentType::MOVING_PLATFORM, plat)); m_Components.insert(std::make_pair(eReplicaComponentType::MOVING_PLATFORM, plat));
// else if we are a movement path } else if (path->pathType == PathType::Movement) {
} /*else if (path->pathType == PathType::Movement) { Game::logger->Log("Entity", "is movement %i", GetLOT());
auto movementAIcomp = GetComponent<MovementAIComponent>(); auto movementAIcomp = GetComponent<MovementAIComponent>();
if (movementAIcomp){ if (!movementAIcomp) {
// TODO: set path in existing movementAIComp movementAIcomp = new MovementAIComponent(this, {});
} else { m_Components.insert(std::make_pair(eReplicaComponentType::MOVEMENT_AI, movementAIcomp));
// TODO: create movementAIcomp and set path }
movementAIcomp->SetupPath(pathName);
} }
}*/
} else { } else {
// else we still need to setup moving platform if it has a moving platform comp but no path // else we still need to setup moving platform if it has a moving platform comp but no path
int32_t movingPlatformComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MOVING_PLATFORM, -1); int32_t movingPlatformComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MOVING_PLATFORM, -1);

View File

@ -287,9 +287,11 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
auto* enemy = Game::entityManager->CreateEntity(info, nullptr, self); auto* enemy = Game::entityManager->CreateEntity(info, nullptr, self);
Game::entityManager->ConstructEntity(enemy); Game::entityManager->ConstructEntity(enemy);
auto* movementAI = new MovementAIComponent(enemy, {}); auto* movementAI = enemy->GetComponent<MovementAIComponent>();
if (!movementAI) {
movementAI = new MovementAIComponent(enemy, {});
enemy->AddComponent(eReplicaComponentType::MOVEMENT_AI, movementAI); enemy->AddComponent(eReplicaComponentType::MOVEMENT_AI, movementAI);
}
movementAI->SetMaxSpeed(toSpawn.initialSpeed); movementAI->SetMaxSpeed(toSpawn.initialSpeed);
movementAI->SetCurrentSpeed(toSpawn.initialSpeed); movementAI->SetCurrentSpeed(toSpawn.initialSpeed);