Skip to content

Commit

Permalink
FORMAT-AUTO: automatic format on pull request #38
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 3, 2023
1 parent cf6bf99 commit e883a93
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/ECS/Systems/Systems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ namespace Systems {
}
}

bool executeDeadFunc(std::size_t id, Registry::components<Types::Dead> &arrDead)
bool
executeDeadFunc(std::size_t id, Registry::components<Types::Dead> &arrDead)
{
std::cout << "----------------------------------" << std::endl;

// AVANT DE SUPPRIMER, JE REGARDE QUELLES ENTITES EXISTES
Registry::components<Types::Health> arrHealth1 =
Registry::getInstance().getComponents<Types::Health>();

std::vector<std::size_t> ids1 = arrHealth1.getExistingsId();
for (auto itIds1 = ids1.begin(); itIds1 != ids1.end(); itIds1++) {
std::cout << "There is an entity with id " << *itIds1 << std::endl;
Expand Down Expand Up @@ -137,19 +138,22 @@ namespace Systems {
Registry::getInstance().getComponents<Types::Health>();
Registry::components<Types::Dead> arrDead =
Registry::getInstance().getComponents<Types::Dead>();

bool isEntityRemoved = false;

std::vector<std::size_t> ids = arrHealth.getExistingsId();
for (auto itIds = ids.begin(); itIds != ids.end(); itIds++) {
if (arrHealth.exist(*itIds) && arrHealth[*itIds].hp <= 0 && arrDead.exist(*itIds)) {
if (arrHealth.exist(*itIds) && arrHealth[*itIds].hp <= 0
&& arrDead.exist(*itIds)) {
isEntityRemoved = executeDeadFunc(*itIds, arrDead);
if (isEntityRemoved) {
arrHealth = Registry::getInstance().getComponents<Types::Health>();
arrDead = Registry::getInstance().getComponents<Types::Dead>();
ids = arrHealth.getExistingsId();
arrHealth =
Registry::getInstance().getComponents<Types::Health>();
arrDead =
Registry::getInstance().getComponents<Types::Dead>();
ids = arrHealth.getExistingsId();
itIds = ids.begin();
//if empty, return
// if empty, return
if (itIds == ids.end()) {
return;
}
Expand Down

0 comments on commit e883a93

Please sign in to comment.