载入中...
搜索中...
未找到
Pathfinder.h
浏览该文件的文档.
1#pragma once
2
3#include "map/FlowField.h"
4#include "map/Path.h"
5#include "map/TileLayer.h"
6
7#include <memory>
8#include <string>
9
10namespace eve::map {
11
18public:
19 Pathfinder();
20 explicit Pathfinder(TileLayer *layer);
21 explicit Pathfinder(int width, int height);
23
24 Pathfinder(Pathfinder &&) noexcept;
25 Pathfinder &operator=(Pathfinder &&) noexcept;
26 Pathfinder(const Pathfinder &) = delete;
27 Pathfinder &operator=(const Pathfinder &) = delete;
28
30 void setSize(int width, int height);
31
32 // --- Grid config (script-friendly) ---
33 void setTopology(const std::string &name);
34 std::string getTopology() const;
35 void setDiagonal(bool enable);
36 bool getDiagonal() const;
37 void blockGid(int gid);
38 void unblockGid(int gid);
39 void clearBlockedGids();
40 void setBlockEmpty(bool enable);
41 bool getBlockEmpty() const;
42 void setBlocked(int x, int y, bool blocked);
43 bool isWalkable(int x, int y) const;
44 void setCellCost(int x, int y, float cost);
45 float getCellCost(int x, int y) const;
46 void syncFromLayer();
47
52 Path *findPath(int sx, int sy, int gx, int gy);
53
55 FlowField *buildFlowField(int gx, int gy);
56
58 Path *followFlow(FlowField *field, int sx, int sy);
59
64 Path *findGroupPath(int sx, int sy, int gx, int gy);
65
67 void invalidateCache();
68
69private:
70 struct Impl;
71 std::unique_ptr<Impl> impl_;
72};
73
74} // namespace eve::map
int y
Definition Grass.cpp:135
float height
Definition Grass.cpp:235
int x
Definition Grass.cpp:135
int width
TileLayer * layer
std::vector< float > cost
const char * name
Definition RockMesh.cpp:21
Integration + direction field for group pathfinding to a single goal. nextX/nextY point to the neighb...
Definition FlowField.h:13
Ordered tile-index waypoints from start to goal (inclusive).
Definition Path.h:8
Pathfinding facade. Single-agent: A*. Group (same goal): Flow Field + follow. Grid/topology internals...
Definition Pathfinder.h:17
std::string getTopology() const
void invalidateCache()
Invalidate cached flow field (also called when grid dirties).
void setBlockEmpty(bool enable)
float getCellCost(int x, int y) const
Path * followFlow(FlowField *field, int sx, int sy)
void bindLayer(TileLayer *layer)
FlowField * buildFlowField(int gx, int gy)
Build / reuse cached flow field toward goal. Owned by caller.
void setCellCost(int x, int y, float cost)
void setTopology(const std::string &name)
bool getBlockEmpty() const
bool isWalkable(int x, int y) const
bool getDiagonal() const
Path * findPath(int sx, int sy, int gx, int gy)
A* from (sx,sy) to (gx,gy). Returns owned Path* (may be empty if unreachable). Never returns nullptr ...
void blockGid(int gid)
void setBlocked(int x, int y, bool blocked)
Pathfinder(Pathfinder &&) noexcept
void setSize(int width, int height)
Path * findGroupPath(int sx, int sy, int gx, int gy)
Group helper: ensure field for goal, then follow from start. Equivalent to buildFlowField + followFlo...
void unblockGid(int gid)
void setDiagonal(bool enable)
ECS tile layer entity. Script mutates tile GIDs / tileset / draw; TileRenderSystem batch-draws atlas ...
Definition TileLayer.h:30
放置世界:格子占用(多通道)+ 地形语义 + 已放置建筑实例。 行为由 PlacementSystem 提供;本类暴露便于脚本绑定的薄封装方法。 坐标换算统一走 eve::grid(支持 rectang...