mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-02-24 14:09:08 +00:00
30 lines
734 B
C++
30 lines
734 B
C++
//
|
|
// Created by Zoe Roux on 6/9/21.
|
|
//
|
|
|
|
#include <Component/BombHolder/BombHolderComponent.hpp>
|
|
#include "BombSystem.hpp"
|
|
|
|
namespace BBM
|
|
{
|
|
BombSystem::BombSystem(WAL::Wal &wal)
|
|
: System(wal)
|
|
{}
|
|
|
|
void BombSystem::onUpdate(WAL::ViewEntity<BasicBombComponent, PositionComponent> &entity, std::chrono::nanoseconds dtime)
|
|
{
|
|
auto &bomb = entity.get<BasicBombComponent>();
|
|
if (!bomb.ignoreOwner)
|
|
return;
|
|
auto &pos = entity.get<PositionComponent>();
|
|
for (auto &[owner, ownerPos, _] : this->_wal.getScene()->view<PositionComponent, BombHolderComponent>()) {
|
|
if (owner.getUid() != bomb.ownerID)
|
|
continue;
|
|
if (pos.position.distance(ownerPos.position) >= 1.1) {
|
|
bomb.ignoreOwner = false;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|