载入中...
搜索中...
未找到
Pathfinder.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "map/FlowField.h"
6#include "map/Path.h"
7#include "map/TileLayer.h"
8
9#include <cstdint>
10#include <functional>
11#include <memory>
12#include <span>
13#include <string>
14#include "common/Result.h"
15
16namespace eve::map {
23 std::uint64_t configuration = 0, layer = 0;
24 friend bool operator==(const NavigationChangeStamp &, const NavigationChangeStamp &) = default;
25};
28 friend class Pathfinder;
29 struct Data;
30 std::shared_ptr<const Data> data_;
31
32public:
36 [[nodiscard]] bool valid() const noexcept { return static_cast<bool>(data_); }
38 [[nodiscard]] int width() const noexcept;
40 [[nodiscard]] int height() const noexcept;
42 [[nodiscard]] std::uint64_t revision() const noexcept;
44 [[nodiscard]] NavigationTopology topology() const noexcept;
46 [[nodiscard]] bool isStaggerAxisY() const noexcept;
48 [[nodiscard]] bool isStaggerOdd() const noexcept;
50 [[nodiscard]] std::span<const float> costs() const noexcept;
52 [[nodiscard]] std::span<const std::uint8_t> enterMasks() const noexcept;
54 [[nodiscard]] std::span<const std::uint8_t> exitMasks() const noexcept;
55};
56
63public:
65 Pathfinder();
67 explicit Pathfinder(TileLayer *layer);
69 explicit Pathfinder(int width, int height);
78 [[nodiscard]] Result<NavigationGridSnapshot> captureNavigationGrid();
83 [[nodiscard]] NavigationChangeStamp getNavigationChangeStamp() const noexcept;
84
86 Pathfinder(Pathfinder &&) noexcept;
88 Pathfinder &operator=(Pathfinder &&) noexcept;
89 Pathfinder(const Pathfinder &) = delete;
90 Pathfinder &operator=(const Pathfinder &) = delete;
91
93 void bindLayer(TileLayer *layer);
95 void setSize(int width, int height);
96
97 // --- Grid config (script-friendly) ---
99 void setTopology(const std::string &name);
101 std::string getTopology() const;
103 void setDiagonal(bool enable);
105 bool getDiagonal() const;
107 void blockGid(int gid);
109 void unblockGid(int gid);
111 void clearBlockedGids();
113 void setBlockEmpty(bool enable);
115 bool getBlockEmpty() const;
117 void setBlocked(int x, int y, bool blocked);
119 bool isWalkable(int x, int y) const;
121 void setCellCost(int x, int y, float cost);
123 float getCellCost(int x, int y) const;
125 void syncFromLayer();
126
131 Path *findPath(int sx, int sy, int gx, int gy);
132
145 Path *findPath(int sx, int sy, int gx, int gy,
147 const std::function<float(int, int)> &entryPenalty);
148
164 [[nodiscard]] Result<bool> keepsPathOpen(int sx, int sy, int gx, int gy, int blockX, int blockY);
165
173 [[nodiscard]] Result<bool> keepsPathOpenFootprint(int sx, int sy, int gx, int gy, int originX, int originY,
174 int footprintW, int footprintH);
175
177 FlowField *buildFlowField(int gx, int gy);
178
181 Path *followFlow(FlowField *field, int sx, int sy);
182
187 Path *findGroupPath(int sx, int sy, int gx, int gy);
188
190 void invalidateCache();
191
192private:
193 struct Impl;
194 std::unique_ptr<Impl> impl_;
195};
196
197} // namespace eve::map
double y
double x
std::uint64_t revision
eve::resource::CostSpec cost
std::string name
Definition ECS.cpp:154
#define EVENGINE_API_WORLD
Definition Export.h:109
std::uint32_t height
std::uint32_t width
Topology topology
TileLayer * layer
Move-only, checked operation results for the common layer.
MigrationFunction function
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Integration + direction field for group pathfinding to a single goal. nextX/nextY point to the neighb...
Definition FlowField.h:15
Immutable owning capture; independent of Pathfinder and TileLayer lifetimes.
Definition Pathfinder.h:27
NavigationGridSnapshot()=default
Construct an absent snapshot.
bool valid() const noexcept
Whether this value contains captured data.
Definition Pathfinder.h:36
Ordered tile-index waypoints from start to goal (inclusive).
Definition Path.h:10
Pathfinding facade. Single-agent: A*. Group (same goal): Flow Field + follow. Grid/topology internals...
Definition Pathfinder.h:62
~Pathfinder()
Pathfinder.
ECS tile layer entity. Script mutates tile GIDs / tileset / draw; TileRenderSystem batch-draws atlas ...
Definition TileLayer.h:33
放置世界:格子占用(多通道)+ 地形语义 + 已放置建筑实例。 行为由 PlacementSystem 提供;本类暴露便于脚本绑定的薄封装方法。 坐标换算统一走 eve::grid(支持 rectang...
NavigationTopology
Logical adjacency of a captured map navigation grid.
Definition Pathfinder.h:18
Cheap invalidation hint, distinct from immutable capture content revisions. Includes bound-layer tile...
Definition Pathfinder.h:22
friend bool operator==(const NavigationChangeStamp &, const NavigationChangeStamp &)=default