Forgot to set targets for pathing.
This commit is contained in:
parent
3dae65fe82
commit
8b61a4fad8
1 changed files with 5 additions and 2 deletions
|
@ -8,7 +8,10 @@ using namespace fmt;
|
|||
using namespace Components;
|
||||
|
||||
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) {
|
||||
if(ent != player.entity) {
|
||||
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)};
|
||||
}
|
||||
});
|
||||
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
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue