This commit is contained in:
Jan Mrna 2025-09-27 18:45:03 +02:00
parent 1b0edb664c
commit 86d52edfd7
3 changed files with 5 additions and 3 deletions

View File

@ -6,7 +6,7 @@
namespace pathfinder {
void PathFinderBase::SetMap(std::shared_ptr<Map> map)
void PathFinderBase::SetMap(const Map* map)
{
m_Map = map;
}

View File

@ -26,12 +26,12 @@ public:
PathFinderBase& operator=(const PathFinderBase&) = delete;
PathFinderBase& operator=(PathFinderBase&&) = delete;
void SetMap(std::shared_ptr<Map> map);
void SetMap(const Map* map);
virtual const std::string_view& GetName() const = 0;
virtual Path CalculatePath(WorldPos target) = 0;
private:
std::shared_ptr<Map> m_Map;
const Map* m_Map;
};

View File

@ -17,6 +17,7 @@ PathFindingDemo::PathFindingDemo(int width, int height) :
LOG_DEBUG(".");
// set default pathfinder method
m_PathFinder = pathfinder::create(pathfinder::PathFinderType::LINEAR);
m_PathFinder->SetMap(&m_Map);
}
PathFindingDemo::~PathFindingDemo() { LOG_DEBUG("."); }
@ -89,6 +90,7 @@ void PathFindingDemo::HandleActions(const std::vector<UserAction> &actions) {
using namespace pathfinder;
PathFinderType type = static_cast<PathFinderType>(action.Argument.number);
m_PathFinder = create(type);
m_PathFinder->SetMap(&m_Map);
LOG_INFO("Switched to path finding method: ", m_PathFinder->GetName());
}
};