Cleaning up callbacks

This commit is contained in:
Zoe Roux
2021-06-05 19:11:26 +02:00
parent f20445cdc8
commit f3ce14caca
5 changed files with 67 additions and 91 deletions

View File

@@ -26,26 +26,14 @@ namespace BBM
this->_window.clear();
this->_window.useCamera(this->_camera);
for (auto &entity : this->_wal.scene->getEntities()) {
if (!entity.hasComponent<Drawable3DComponent>()
|| !entity.hasComponent<PositionComponent>())
continue;
auto &drawable = entity.getComponent<Drawable3DComponent>();
auto &pos = entity.getComponent<PositionComponent>();
for (auto &[_, pos, drawable] : this->_wal.scene->view<PositionComponent, Drawable3DComponent>()) {
drawable.drawable->setPosition(pos.position);
drawable.drawable->drawOn(this->_window);
}
this->_window.unuseCamera();
// TODO sort entities based on the Z axis
for (auto &entity : this->_wal.scene->getEntities()) {
if (!entity.hasComponent<Drawable2DComponent>()
|| !entity.hasComponent<PositionComponent>())
continue;
auto &drawable = entity.getComponent<Drawable2DComponent>();
auto &pos = entity.getComponent<PositionComponent>();
for (auto &[_, pos, drawable] : this->_wal.scene->view<PositionComponent, Drawable2DComponent>()) {
drawable.drawable->setPosition(Vector2f(pos.position.x, pos.position.y));
drawable.drawable->drawOn(this->_window);
}