|
|
@ -8,7 +8,10 @@ using namespace fmt; |
|
|
|
using namespace Components; |
|
|
|
using namespace Components; |
|
|
|
|
|
|
|
|
|
|
|
void System::enemy_pathing(DinkyECS::World &world, Map &game_map, Player &player) { |
|
|
|
void System::enemy_pathing(DinkyECS::World &world, Map &game_map, Player &player) { |
|
|
|
// move enemies system
|
|
|
|
const auto &player_position = world.component<Position>(player.entity); |
|
|
|
|
|
|
|
game_map.set_target(player_position.location); |
|
|
|
|
|
|
|
game_map.make_paths(); |
|
|
|
|
|
|
|
|
|
|
|
world.system<Position, Motion>([&](const auto &ent, auto &position, auto &motion) { |
|
|
|
world.system<Position, Motion>([&](const auto &ent, auto &position, auto &motion) { |
|
|
|
if(ent != player.entity) { |
|
|
|
if(ent != player.entity) { |
|
|
|
Point out = position.location; |
|
|
|
Point out = position.location; |
|
|
@ -16,6 +19,7 @@ void System::enemy_pathing(DinkyECS::World &world, Map &game_map, Player &player |
|
|
|
motion = { int(out.x - position.location.x), int(out.y - position.location.y)}; |
|
|
|
motion = { int(out.x - position.location.x), int(out.y - position.location.y)}; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
game_map.clear_target(player_position.location); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -28,7 +32,6 @@ void System::motion(DinkyECS::World &world, Map &game_map) { |
|
|
|
motion = {0,0}; // clear it after getting it
|
|
|
|
motion = {0,0}; // clear it after getting it
|
|
|
|
|
|
|
|
|
|
|
|
if(game_map.inmap(move_to.x, move_to.y) && !game_map.iswall(move_to.x,move_to.y)) { |
|
|
|
if(game_map.inmap(move_to.x, move_to.y) && !game_map.iswall(move_to.x,move_to.y)) { |
|
|
|
game_map.clear_target(position.location); |
|
|
|
|
|
|
|
position.location = move_to; |
|
|
|
position.location = move_to; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|