|
|
|
@ -130,6 +130,34 @@ void System::death(GameLevel &level) { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void System::combat(GameLevel &level) { |
|
|
|
|
auto &collider = *level.collision; |
|
|
|
|
auto &world = *level.world; |
|
|
|
|
auto player = world.get_the<Player>(); |
|
|
|
|
|
|
|
|
|
const auto& player_position = world.get<Position>(player.entity); |
|
|
|
|
auto& player_combat = world.get<Combat>(player.entity); |
|
|
|
|
|
|
|
|
|
// this is guaranteed to not return the given position
|
|
|
|
|
auto [found, nearby] = collider.neighbors(player_position.location); |
|
|
|
|
|
|
|
|
|
if(found) { |
|
|
|
|
for(auto entity : nearby) { |
|
|
|
|
if(world.has<Combat>(entity)) { |
|
|
|
|
auto& enemy_combat = world.get<Combat>(entity); |
|
|
|
|
|
|
|
|
|
Events::Combat result { |
|
|
|
|
player_combat.attack(enemy_combat), |
|
|
|
|
enemy_combat.attack(player_combat) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
world.send<Events::GUI>(Events::GUI::COMBAT, entity, result); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void System::collision(GameLevel &level) { |
|
|
|
|
auto &collider = *level.collision; |
|
|
|
|
auto &world = *level.world; |
|
|
|
|