From 84ff472f2aaa5fcc7bf83c3147f5e2dd48d8a24f Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 9 Jun 2021 14:36:19 +0200 Subject: [PATCH] Real bombs collisions but waiting for origin/bonus to be merged --- sources/System/BombHolder/BombHolderSystem.cpp | 15 +++++++++++++-- sources/System/BombHolder/BombHolderSystem.hpp | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sources/System/BombHolder/BombHolderSystem.cpp b/sources/System/BombHolder/BombHolderSystem.cpp index 0ccd396b..7807577e 100644 --- a/sources/System/BombHolder/BombHolderSystem.cpp +++ b/sources/System/BombHolder/BombHolderSystem.cpp @@ -19,6 +19,17 @@ namespace BBM { std::chrono::nanoseconds BombHolderSystem::explosionTimer = 3s; + void BombHolderSystem::_bombCollide(WAL::Entity &entity, + const WAL::Entity &bomb, + CollisionComponent::CollidedAxis collidedAxis) + { + auto &bombInfo = bomb.getComponent(); + if (bombInfo.skipOwner && bombInfo.owner == entity) + return; + return MapGenerator::wallCollide(entity, bomb, collidedAxis); + } + + BombHolderSystem::BombHolderSystem(WAL::Wal &wal) : System(wal) {} @@ -54,8 +65,8 @@ namespace BBM this->_wal.scene->scheduleNewEntity("Bomb") .addComponent(position.round()) .addComponent(BombHolderSystem::explosionTimer, &BombHolderSystem::_bombExplosion) -// .addComponent(WAL::Callback(), -// &MapGenerator::wallCollide, 0.25, .75) + .addComponent(WAL::Callback(), + &BombHolderSystem::_bombCollide, 0.25, .75) .addComponent("assets/bombs/bomb.obj", std::make_pair(MAP_DIFFUSE, "assets/bombs/bomb_normal.png")); } diff --git a/sources/System/BombHolder/BombHolderSystem.hpp b/sources/System/BombHolder/BombHolderSystem.hpp index 105f9139..ed3486d1 100644 --- a/sources/System/BombHolder/BombHolderSystem.hpp +++ b/sources/System/BombHolder/BombHolderSystem.hpp @@ -6,6 +6,7 @@ #include #include +#include #include "Models/Vector3.hpp" #include "Component/Position/PositionComponent.hpp" #include "Component/BombHolder/BombHolderComponent.hpp" @@ -25,6 +26,9 @@ namespace BBM //! @brief The method triggered when the bomb explode. static void _bombExplosion(WAL::Entity &bomb, WAL::Wal &); + + //! @brief The method called when a player collide with a bomb. + static void _bombCollide(WAL::Entity &entity, const WAL::Entity &wall, BBM::CollisionComponent::CollidedAxis collidedAxis); public: //! @brief The explosion time of new bombs. static std::chrono::nanoseconds explosionTimer;