From d3f77835d34e9b611ad77faaccef7d3403f18e7b Mon Sep 17 00:00:00 2001 From: Askou Date: Mon, 14 Jun 2021 10:51:49 +0200 Subject: [PATCH] fix cmake not compiling because of git merge --- .../System/BombHolder/BombHolderSystem.cpp | 28 ++++++------------- .../System/BombHolder/BombHolderSystem.hpp | 9 ++---- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/sources/System/BombHolder/BombHolderSystem.cpp b/sources/System/BombHolder/BombHolderSystem.cpp index 1cae7500..d91c2a27 100644 --- a/sources/System/BombHolder/BombHolderSystem.cpp +++ b/sources/System/BombHolder/BombHolderSystem.cpp @@ -31,13 +31,14 @@ namespace BBM return MapGenerator::wallCollided( entity, bomb, collidedAxis); } + BombHolderSystem::BombHolderSystem(WAL::Wal &wal) : System(wal) {} - void BombHolderSystem::_dispatchExplosion(const Vector3f &position, WAL::Wal &wal, int radiusToDo, const Vector3f &posFrom) + void BombHolderSystem::_dispatchExplosion(Vector3f position, WAL::Wal &wal, int count) { - if (radiusToDo <= 0) + if (count <= 0) return; wal.getScene()->scheduleNewEntity("explosion") .addComponent(position) @@ -54,23 +55,10 @@ namespace BBM return; } } - const Vector3f expandVectors[] = { - {1, 0, 0}, - {-1, 0, 0}, - {0, 0, 1}, - {0, 0, -1}, - }; - - // should be true only at the first iteration - bool alwaysDispatch = position == posFrom; - - for (const auto &expandVector : expandVectors) { - Vector3f newPos = position + expandVector; - if (!alwaysDispatch && newPos == posFrom) { - continue; - } - _dispatchExplosion(newPos, wal, radiusToDo - 1, position); - } + _dispatchExplosion(position + Vector3f(1, 0, 0), wal, count - 1); + _dispatchExplosion(position + Vector3f(-1, 0, 0), wal, count - 1); + _dispatchExplosion(position + Vector3f(0, 0, 1), wal, count - 1); + _dispatchExplosion(position + Vector3f(0, 0, -1), wal, count - 1); }); } @@ -79,7 +67,7 @@ namespace BBM bomb.scheduleDeletion(); auto position = bomb.getComponent().position.round(); auto explosionRadius = bomb.getComponent().explosionRadius; - _dispatchExplosion(position, wal, explosionRadius); + _dispatchExplosion(position, wal, 3 + (explosionRadius - 3)); } void BombHolderSystem::_spawnBomb(Vector3f position, BombHolderComponent &holder, unsigned id) diff --git a/sources/System/BombHolder/BombHolderSystem.hpp b/sources/System/BombHolder/BombHolderSystem.hpp index 6c872ca8..6d26435e 100644 --- a/sources/System/BombHolder/BombHolderSystem.hpp +++ b/sources/System/BombHolder/BombHolderSystem.hpp @@ -22,12 +22,7 @@ namespace BBM void _spawnBomb(Vector3f position, BombHolderComponent &holder, unsigned id); //! @brief Spawn a bomb at the specified position. - static void _dispatchExplosion(const Vector3f &position, WAL::Wal &wal, int radiusToDo, const Vector3f &posFrom); - - //! @brief Wrapped call to specify default arg value - inline static void _dispatchExplosion(const Vector3f &position, WAL::Wal &wal, int radiusToDo) { - return _dispatchExplosion(position, wal, radiusToDo, position); - }; + static void _dispatchExplosion(Vector3f position, WAL::Wal &, int count); //! @brief The method triggered when the bomb explode. static void _bombExplosion(WAL::Entity &bomb, WAL::Wal &); @@ -51,4 +46,4 @@ namespace BBM //! @brief A bomb holder system is not assignable. BombHolderSystem &operator=(const BombHolderSystem &) = delete; }; -} +} \ No newline at end of file