Skip to content

Commit b7d5413

Browse files
committed
feat: add random position spawning for enemies in the ECS
1 parent 87bed8c commit b7d5413

File tree

1 file changed

+5
-0
lines changed
  • Flakkari/Engine/EntityComponentSystem/Systems

1 file changed

+5
-0
lines changed

Flakkari/Engine/EntityComponentSystem/Systems/Systems.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ bool spawn_enemy(Registry &r, std::string &templateName, Entity &entity)
229229
entity = r.spawn_entity();
230230
templateName = template_->name;
231231
Factory::RegistryEntityByTemplate(r, entity, template_->content);
232+
233+
auto &enemyTransform = r.getComponents<ECS::Components::_3D::Transform>()[entity];
234+
enemyTransform->_position.vec.x = randomRange(-maxRangeX, maxRangeX);
235+
enemyTransform->_position.vec.y = randomRange(-maxRangeY, maxRangeY);
236+
enemyTransform->_position.vec.z = randomRange(-maxRangeZ, maxRangeZ);
232237
return true;
233238
}
234239
return false;

0 commit comments

Comments
 (0)