mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-05 19:04:26 +00:00
fixing naming issues and default args
This commit is contained in:
@@ -37,10 +37,10 @@ namespace BBM
|
||||
|
||||
void BombHolderSystem::_dispatchExplosion(const Vector3f &position,
|
||||
WAL::Wal &wal,
|
||||
int radiusToDo,
|
||||
int size,
|
||||
ExpansionDirection expansionDirections)
|
||||
{
|
||||
if (radiusToDo <= 0)
|
||||
if (size <= 0)
|
||||
return;
|
||||
wal.getScene()->scheduleNewEntity("explosion")
|
||||
.addComponent<PositionComponent>(position)
|
||||
@@ -52,7 +52,7 @@ namespace BBM
|
||||
MAP_DIFFUSE,
|
||||
"assets/bombs/explosion/blast.png"
|
||||
));
|
||||
wal.getSystem<EventSystem>().dispatchEvent([position, radiusToDo, expansionDirections](WAL::Wal &wal) {
|
||||
wal.getSystem<EventSystem>().dispatchEvent([position, size, expansionDirections](WAL::Wal &wal) {
|
||||
for (auto &[entity, pos, _] : wal.getScene()->view<PositionComponent, TagComponent<Blowable>>()) {
|
||||
if (pos.position.round() == position) {
|
||||
if (auto *health = entity.tryGetComponent<HealthComponent>())
|
||||
@@ -61,16 +61,16 @@ namespace BBM
|
||||
}
|
||||
}
|
||||
if (expansionDirections & ExpansionDirection::FRONT) {
|
||||
_dispatchExplosion(position + Vector3f{1, 0, 0}, wal, radiusToDo - 1, ExpansionDirection::FRONT);
|
||||
_dispatchExplosion(position + Vector3f{1, 0, 0}, wal, size - 1, ExpansionDirection::FRONT);
|
||||
}
|
||||
if (expansionDirections & ExpansionDirection::BACK) {
|
||||
_dispatchExplosion(position + Vector3f{-1, 0, 0}, wal, radiusToDo - 1, ExpansionDirection::BACK);
|
||||
_dispatchExplosion(position + Vector3f{-1, 0, 0}, wal, size - 1, ExpansionDirection::BACK);
|
||||
}
|
||||
if (expansionDirections & ExpansionDirection::LEFT) {
|
||||
_dispatchExplosion(position + Vector3f{0, 0, 1}, wal, radiusToDo - 1, ExpansionDirection::LEFT);
|
||||
_dispatchExplosion(position + Vector3f{0, 0, 1}, wal, size - 1, ExpansionDirection::LEFT);
|
||||
}
|
||||
if (expansionDirections & ExpansionDirection::RIGHT) {
|
||||
_dispatchExplosion(position + Vector3f{0, 0, -1}, wal, radiusToDo - 1, ExpansionDirection::RIGHT);
|
||||
_dispatchExplosion(position + Vector3f{0, 0, -1}, wal, size - 1, ExpansionDirection::RIGHT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,6 +24,12 @@ namespace BBM
|
||||
BACK = 32
|
||||
};
|
||||
|
||||
//! @brief Ta avoid explicit casting
|
||||
inline ExpansionDirection operator|(ExpansionDirection a, ExpansionDirection b)
|
||||
{
|
||||
return static_cast<ExpansionDirection>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
//! @brief The system that allow one to place bombs.
|
||||
class BombHolderSystem : public WAL::System<PositionComponent, BombHolderComponent, ControllableComponent>
|
||||
{
|
||||
@@ -32,25 +38,15 @@ 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,
|
||||
ExpansionDirection expansionDirections);
|
||||
|
||||
//! @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,
|
||||
static_cast<ExpansionDirection>(
|
||||
ExpansionDirection::DOWN
|
||||
| ExpansionDirection::UP
|
||||
| ExpansionDirection::FRONT
|
||||
| ExpansionDirection::BACK
|
||||
| ExpansionDirection::LEFT
|
||||
| ExpansionDirection::RIGHT
|
||||
)
|
||||
);
|
||||
};
|
||||
static void _dispatchExplosion(const Vector3f &position,
|
||||
WAL::Wal &wal,
|
||||
int size,
|
||||
ExpansionDirection expansionDirections = ExpansionDirection::DOWN
|
||||
| ExpansionDirection::UP
|
||||
| ExpansionDirection::FRONT
|
||||
| ExpansionDirection::BACK
|
||||
| ExpansionDirection::LEFT
|
||||
| ExpansionDirection::RIGHT);
|
||||
|
||||
//! @brief The method triggered when the bomb explode.
|
||||
static void _bombExplosion(WAL::Entity &bomb, WAL::Wal &);
|
||||
|
||||
Reference in New Issue
Block a user