载入中...
搜索中...
未找到
HexMapModule.h
浏览该文件的文档.
1#pragma once
2
5#include "common/Module.h"
6#include "common/Result.h"
7#include "hexmap/HexMap.h"
8#include "hexmap/HexMapMesh.h"
9#include "hexmap/HexSearch.h"
11#include "hexmap/HexSphereMap.h"
13#include "hexmap/HexUnits.h"
15
16#include <cstdint>
17#include <vector>
18
19namespace eve::graphics {
20class Graphics;
21class Mesh;
22} // namespace eve::graphics
23
24namespace eve::hexmap {
25
44public:
46
50 ~HexMapModule() override;
51
63 [[nodiscard]] Result<void> newGrid(graphics::Graphics* gfx, std::int32_t cellCountX, std::int32_t cellCountZ,
64 std::uint32_t seed);
65
73 std::int32_t rebuildDirtyChunks(graphics::Graphics* gfx);
74
83 std::int32_t rebuildChunk(graphics::Graphics* gfx, std::int32_t chunkIndex);
84
93 [[nodiscard]] graphics::Mesh* chunkMeshAt(std::int32_t chunkIndex, HexSurface surface) const;
94
101 void releaseMeshes(graphics::Graphics* gfx);
102
104 [[nodiscard]] const HexMap& map() const noexcept { return map_; }
106 [[nodiscard]] HexMap& map() noexcept { return map_; }
108 [[nodiscard]] bool hasGrid() const noexcept { return !map_.empty(); }
109
110 // --- spherical map ------------------------------------------------------
111
126 [[nodiscard]] Result<void> newSphere(graphics::Graphics* gfx, std::int32_t subdivision, float radius,
127 std::uint32_t seed);
128
137 [[nodiscard]] Result<void> rebuildSphere(graphics::Graphics* gfx);
138
143 void releaseSphereMeshes(graphics::Graphics* gfx) noexcept;
144
146 [[nodiscard]] const HexSphereMap& sphere() const noexcept { return sphere_; }
148 [[nodiscard]] HexSphereMap& sphere() noexcept { return sphere_; }
154 [[nodiscard]] graphics::Mesh* sphereTerrainMesh() const noexcept { return sphereTerrain_; }
160 [[nodiscard]] graphics::Mesh* sphereWaterMesh() const noexcept { return sphereWater_; }
161
163 [[nodiscard]] HexVisibility& visibility() noexcept { return visibility_; }
165 [[nodiscard]] HexUnitRegistry& units() noexcept { return units_; }
167 [[nodiscard]] HexSearchContext& scratch() noexcept { return scratch_; }
168
184 [[nodiscard]] Result<void> adoptGrid(graphics::Graphics* gfx, HexMap&& restored,
185 const std::vector<HexUnitState>& units);
186
191 void syncScratch();
192
208 [[nodiscard]] Result<void> applyTerrain(graphics::Graphics* gfx, const HexTerrainBake& bake);
209
222 [[nodiscard]] Result<void> applySphereTerrain(graphics::Graphics* gfx, const HexTerrainBake& bake);
223
224private:
225 [[nodiscard]] std::int32_t meshSlot(std::int32_t chunkIndex, HexSurface surface) const noexcept;
226 void clearMeshSlots() noexcept;
227
228 HexMap map_{};
229 std::vector<graphics::Mesh*> meshes_{};
230 std::vector<std::uint8_t> meshPopulated_{};
231 HexSearchContext scratch_{};
232 HexVisibility visibility_{};
233 HexUnitRegistry units_{};
234
235 HexSphereMap sphere_{};
236 graphics::Mesh* sphereTerrain_ = nullptr;
237 graphics::Mesh* sphereWater_ = nullptr;
238};
239
240} // namespace eve::hexmap
#define EVENGINE_API_WORLD
Definition Export.h:109
Per-chunk mesh generation for every hex map surface.
Editable hex cell grid: topology, queries, picking and authoring.
Cell-graph search used by pathfinding and visibility.
Versioned payload codec for a hex map and its units.
Editable spherical hex map over an icosahedral hex topology.
Terrain bake hexmap applies; procgen produces the payload.
Units that occupy cells, travel along paths and carry vision.
Reference-counted cell visibility and explored state.
float radius
std::uint32_t seed
Definition PointSet.cpp:807
Move-only, checked operation results for the common layer.
std::vector< UnitCandidate > units
EVENGINE_API_FOUNDATION public API.
Definition Module.h:46
Move-only operation result carrying either a value or Status.
Definition Result.h:155
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:25
Owns the active hex map and the GPU meshes generated from it.
HexUnitRegistry & units() noexcept
Units of the active map.
bool hasGrid() const noexcept
Whether a grid has been created.
~HexMapModule() override
Destructor; GPU meshes must already have been released.
HexMap & map() noexcept
The active map (mutable, for internal build steps).
graphics::Mesh * sphereWaterMesh() const noexcept
Borrowed GPU ocean mesh of the sphere, or null when nothing is flooded. @ownership Borrowed; the modu...
HexVisibility & visibility() noexcept
Fog-of-war counters of the active map.
HexMapModule()
Constructs an empty module with no map and no meshes.
HexSphereMap & sphere() noexcept
The active spherical map (mutable, for internal build steps).
const HexMap & map() const noexcept
The active map.
const HexSphereMap & sphere() const noexcept
The active spherical map.
graphics::Mesh * sphereTerrainMesh() const noexcept
Borrowed GPU terrain mesh of the sphere. @ownership Borrowed; the module retains ownership until rele...
HexSearchContext & scratch() noexcept
Search scratch sized to the active map.
An editable, chunked, pointy-top hex map.
Definition HexMap.h:72
Reusable search scratch: one record per cell plus a priority bucket queue.
Definition HexSearch.h:68
An editable hex map wrapped onto a sphere.
Owns the units of one map and their fog-of-war contribution.
Definition HexUnits.h:69
Fog-of-war bookkeeping: how many viewers currently see each cell.
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
HexSurface
Surface streams a chunk mesh is generated for.
Definition HexMap.h:19
Packed terrain produced by a generator and applied onto a hex map.