Set map
This commit is contained in:
parent
1b0edb664c
commit
86d52edfd7
@ -6,7 +6,7 @@
|
||||
|
||||
namespace pathfinder {
|
||||
|
||||
void PathFinderBase::SetMap(std::shared_ptr<Map> map)
|
||||
void PathFinderBase::SetMap(const Map* map)
|
||||
{
|
||||
m_Map = map;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user