Skip to content

Commit

Permalink
feat: add random position spawning for enemies in the ECS
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterLaplace committed Nov 22, 2024
1 parent 87bed8c commit b7d5413
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Flakkari/Engine/EntityComponentSystem/Systems/Systems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ bool spawn_enemy(Registry &r, std::string &templateName, Entity &entity)
entity = r.spawn_entity();
templateName = template_->name;
Factory::RegistryEntityByTemplate(r, entity, template_->content);

auto &enemyTransform = r.getComponents<ECS::Components::_3D::Transform>()[entity];
enemyTransform->_position.vec.x = randomRange(-maxRangeX, maxRangeX);
enemyTransform->_position.vec.y = randomRange(-maxRangeY, maxRangeY);
enemyTransform->_position.vec.z = randomRange(-maxRangeZ, maxRangeZ);
return true;
}
return false;
Expand Down

0 comments on commit b7d5413

Please sign in to comment.