载入中...
搜索中...
未找到
Map.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Module.h"
6#include "common/Result.h"
7#include "map/TileLayer.h"
8#include "map/MapObject.h"
9#include "map/Pathfinder.h"
10#include "map/Fov.h"
11#include "map/TileCollision.h"
12
13#include <optional>
14#include <string>
15#include <string_view>
16#include <vector>
17
18namespace eve::graphics {
19class Graphics;
20}
21
22namespace eve::map {
23
31public:
34 Map();
36 ~Map() override = default;
37
39 TileLayer *newLayer(int mapW, int mapH, float tileW = 32.f, float tileH = 32.f);
40
42 Pathfinder *newPathfinder(TileLayer *layer);
44 Pathfinder *newPathfinderSize(int mapW, int mapH);
45
47 Fov *newFov(TileLayer *layer);
49 Fov *newFovSize(int mapW, int mapH);
51 Fov *newFovVolume(int mapW, int mapH, int depth);
52
63 TileLayer *newLayerFromFile(const std::string &path);
64
69 int loadFromFile(const std::string &path);
70
80 [[nodiscard]] eve::Result<int> loadFromFileWithObjectContract(const std::string &path,
81 std::string_view contractJson);
82
92 [[nodiscard]] eve::Result<int> loadFromTextWithObjectContract(std::string_view mapJson,
93 std::string_view contractJson);
94
96 void update(float dt);
98 void render(graphics::Graphics *gfx);
100 int pollConfigs();
102 int getLastVisibleTileCount() const;
104 int getLastCustomVisualCount() const;
106 int getLastAtlasCount() const;
108 int getLastVisitedChunkCount() const;
110 int getLastVisitedCellCount() const;
111
113 int publishCollision(TileLayer *layer);
115 int getCollisionRectCount() const;
117 float getCollisionRectX(int index) const;
119 float getCollisionRectY(int index) const;
121 float getCollisionRectWidth(int index) const;
123 float getCollisionRectHeight(int index) const;
124
126 int getLayerCount() const;
128 TileLayer *getLayer(int index) const;
129
131 int getObjectCount() const;
133 std::string getObjectName(int i) const;
135 std::string getObjectType(int i) const;
137 float getObjectX(int i) const;
139 float getObjectY(int i) const;
141 float getObjectWidth(int i) const;
143 float getObjectHeight(int i) const;
145 int getObjectGid(int i) const;
146
155 int getObjectPropertyCount(int objectIndex) const;
156
166 std::string getObjectPropertyName(int objectIndex, int propertyIndex) const;
167
176 [[nodiscard]] bool hasObjectProperty(int objectIndex, std::string_view name) const;
177
189 [[nodiscard]] std::string getObjectProperty(int objectIndex, std::string_view name,
190 std::string defaultValue = {}) const;
191
201 [[nodiscard]] std::optional<std::size_t> findObjectByName(std::string_view name) const;
202
214 [[nodiscard]] std::optional<std::size_t> findObjectAt(float x, float y,
215 std::string_view type = {}) const;
216
218 void setObjects(std::vector<MapObject> objects);
219
225 bool resolveDualGrid(TileLayer *logic, TileLayer *display);
227 bool resolveDualGridFilled(TileLayer *logic, TileLayer *display, int filledGid);
229 int dualGridMaskAt(TileLayer *logic, int dx, int dy, int filledGid);
231 int dualGridFrame(int mask);
233 float dualGridOffsetX(TileLayer *logic);
235 float dualGridOffsetY(TileLayer *logic);
237 std::string lastDualGridError() const;
238
239private:
240 std::vector<MapObject> objects_;
241 std::vector<TileLayer *> loadedLayers_;
242 std::string dualGridError_;
243 std::vector<TileCollisionRect> collisionRects_;
244};
245
246} // namespace eve::map
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
int mask
#define EVENGINE_API_WORLD
Definition Export.h:109
std::string name
TileLayer * layer
std::string path
Definition PlayHost.cpp:110
Move-only, checked operation results for the common layer.
float dy
float dx
int tileW
int tileH
uint32_t index
std::uint32_t depth
EVENGINE_API_FOUNDATION public API.
Definition Module.h:46
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Dynamic field-of-view / fog-of-war facade. Phase A: 2D shadowcast + multi-revealer + explored memory....
Definition Fov.h:27
Map module — factory + script binding for 2D tilemaps. Per-frame: TileConfigSystem (hot reload) → uni...
Definition Map.h:30
~Map() override=default
Map.
Pathfinding facade. Single-agent: A*. Group (same goal): Flow Field + follow. Grid/topology internals...
Definition Pathfinder.h:20
ECS tile layer entity. Script mutates tile GIDs / tileset / draw; TileRenderSystem batch-draws atlas ...
Definition TileLayer.h:32
const char * defaultValue
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
放置世界:格子占用(多通道)+ 地形语义 + 已放置建筑实例。 行为由 PlacementSystem 提供;本类暴露便于脚本绑定的薄封装方法。 坐标换算统一走 eve::grid(支持 rectang...