diff --git a/autowalker.cpp b/autowalker.cpp index b03613d..09ec354 100644 --- a/autowalker.cpp +++ b/autowalker.cpp @@ -2,6 +2,7 @@ #include "ai_debug.hpp" #include "gui/ritual_ui.hpp" #include "game_level.hpp" +#include "systems.hpp" #define DEBUG struct InventoryStats { @@ -29,28 +30,11 @@ int number_left() { template Pathing compute_paths() { auto& level = GameDB::current_level(); - auto& walls_original = level.map->$walls; - auto walls_copy = walls_original; + auto walls_copy = level.map->$walls; Pathing paths{matrix::width(walls_copy), matrix::height(walls_copy)}; - // first, put everything of this type as a target - level.world->query( - [&](const auto ent, auto& position, auto&) { - if(ent != level.player) { - paths.set_target(position.location); - } - }); - - level.world->query( - [&](const auto ent, auto& collision) { - if(collision.has) { - auto& pos = level.world->get(ent); - walls_copy[pos.location.y][pos.location.x] = WALL_VALUE; - } - }); - - paths.compute_paths(walls_copy); + System::multi_path(level, paths, walls_copy); auto pos = GameDB::player_position().location; matrix::dump("compute_paths walls", walls_copy, pos.x, pos.y); @@ -133,6 +117,7 @@ void Autowalker::path_fail(const std::string& msg, Matrix& bad_paths, Point pos) bool Autowalker::path_player(Pathing& paths, Point& target_out) { auto &level = GameDB::current_level(); + auto found = paths.find_path(target_out, PATHING_TOWARD, false); if(found == PathingResult::FAIL) {