bombs are exploding in chain successfully adding BlowablePass tag

This commit is contained in:
Clément Le Bihan
2021-06-15 00:30:47 +02:00
parent d164e3d407
commit 2b70d4883f
2 changed files with 18 additions and 1 deletions
+3
View File
@@ -50,5 +50,8 @@ namespace BBM
TagComponent &operator=(const TagComponent &) = delete;
};
// interact with bombs & stop the explosion
constexpr const char Blowable[] = "Blowable";
// interact with bombs (getting damage etc) but doesn't stop explosion
constexpr const char BlowablePass[] = "BlowablePass";
}
+15 -1
View File
@@ -44,7 +44,7 @@ namespace BBM
return;
wal.getScene()->scheduleNewEntity("explosion")
.addComponent<PositionComponent>(position)
.addComponent<TimerComponent>(1s, [](WAL::Entity &explosion, WAL::Wal &wal) {
.addComponent<TimerComponent>(500ms, [](WAL::Entity &explosion, WAL::Wal &wal) {
explosion.scheduleDeletion();
})
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/bombs/explosion/explosion.glb", false,
@@ -60,6 +60,12 @@ namespace BBM
return;
}
}
for (auto &[entity, pos, _] : wal.getScene()->view<PositionComponent, TagComponent<BlowablePass>>()) {
if (pos.position.round() == position) {
if (auto *health = entity.tryGetComponent<HealthComponent>())
health->takeDmg(1);
}
}
if (expansionDirections & ExpansionDirection::FRONT) {
_dispatchExplosion(position + Vector3f{1, 0, 0}, wal, size - 1, ExpansionDirection::FRONT);
}
@@ -87,6 +93,14 @@ namespace BBM
{
this->_wal.getScene()->scheduleNewEntity("Bomb")
.addComponent<PositionComponent>(position.round())
.addComponent<HealthComponent>(1, [](WAL::Entity &entity, WAL::Wal &wal) {
// the bomb explode when hit
entity.scheduleDeletion();
auto &pos = entity.getComponent<PositionComponent>();
auto &bombDetails = entity.getComponent<BasicBombComponent>();
BombHolderSystem::_dispatchExplosion(pos.position, wal, bombDetails.explosionRadius);
})
.addComponent<TagComponent<BlowablePass>>()
.addComponent<BasicBombComponent>(holder.damage, holder.explosionRadius, id)
.addComponent<TimerComponent>(BombHolderSystem::explosionTimer, &BombHolderSystem::_bombExplosion)
.addComponent<CollisionComponent>(