From 8b61a4fad8e892187c6ab1641f3175a36cadbc1a Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 17 Oct 2024 23:50:07 -0400 Subject: [PATCH] Forgot to set targets for pathing. --- systems.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/systems.cpp b/systems.cpp index 5634c6a..95c09a1 100644 --- a/systems.cpp +++ b/systems.cpp @@ -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(player.entity); + game_map.set_target(player_position.location); + game_map.make_paths(); + world.system([&](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; } });