载入中...
搜索中...
未找到
HexTerrainBake.cpp
浏览该文件的文档.
45[[nodiscard]] Result<std::vector<HexCellData>> unpackCells(std::string_view packed, std::size_t expected) {
65 if (field->isInt64()) return Result<std::int32_t>::success(static_cast<std::int32_t>(field->asInt()));
131 if (kindField == nullptr || !kindField->isString()) return invalidBake("hex terrain bake is missing string 'kind'");
176 if (bake.kind != HexTerrainBake::Kind::Planar) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "applyHexTerrain requires a planar bake", "hexmap"));
177 if (bake.cellCountX <= 0 || bake.cellCountZ <= 0) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "planar bake size must be positive", "hexmap"));
179 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "planar bake cell count does not match width and height", "hexmap"));
194 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "applyHexSphereTerrain requires a sphere bake", "hexmap"));
195 if (map.empty()) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "applyHexSphereTerrain requires an existing sphere topology", "hexmap"));
197 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "sphere bake cell count is inconsistent", "hexmap"));
199 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "sphere bake does not match the live topology; call newSphere with the same subdivision", "hexmap"));
Stable, structured diagnostics shared by engine modules.
Terrain bake hexmap applies; procgen produces the payload.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
const std::string & asString() const
Return the string payload; the caller must have checked the kind.
Definition Value.cpp:87
bool isNumeric() const noexcept
Return whether this value is an integer or finite number.
Definition Value.h:159
double asDouble() const
Return the Double payload; the caller must have checked the kind.
Definition Value.cpp:75
void set(const std::string &key, Value value)
Insert or replace an object member.
Definition Value.cpp:118
std::int64_t asInt() const
Return the Int64 payload; the caller must have checked the kind.
Definition Value.cpp:69
Value * find(const std::string &key) noexcept
Return an object member, or nullptr when absent.
Definition Value.cpp:124
HexCoordinates coordinatesAt(std::int32_t index) const noexcept
Coordinates of a linear cell index; out-of-range indices return (0, 0).
Definition HexMap.cpp:69
Result< void > setCellState(HexCoordinates c, HexValues values, HexFlags flags)
Writes a complete cell record verbatim.
Definition HexMap.cpp:505
Result< void > reset(std::int32_t cellCountX, std::int32_t cellCountZ, std::uint32_t seed)
Replaces the grid with a new cellCountX * cellCountZ map.
Definition HexMap.cpp:37
const HexCellData * cellAt(std::int32_t index) const noexcept
Cell record by linear index, or null when out of range. @ownership Borrowed; the map owns the record....
Definition HexMap.cpp:74
std::int32_t subdivision() const noexcept
The subdivision level this map was built at.
Definition HexSphereMap.h:87
const HexCellData * cellAt(HexSphereCell cell) const noexcept
Cell record by id, or null when out of range. @ownership Borrowed; the map owns the record....
Definition HexSphereMap.cpp:111
Result< void > setCellState(HexSphereCell c, HexValues values, HexFlags flags)
Writes a complete cell record verbatim.
Definition HexSphereMap.cpp:498
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:26
Definition HexCell.h:9
HexTerrainBake snapshotHexSphereTerrain(const HexSphereMap &map)
Snapshot every cell of a spherical map into a bake.
Definition HexTerrainBake.cpp:96
Result< void > applyHexTerrain(HexMap &map, const HexTerrainBake &bake)
Replace a planar map's cells with a bake.
Definition HexTerrainBake.cpp:175
Result< HexTerrainBake > hexTerrainBakeFromValue(const Value &value)
Parse a script bake payload produced by hexTerrainBakeToValue.
Definition HexTerrainBake.cpp:128
HexTerrainBake snapshotHexTerrain(const HexMap &map)
Snapshot every cell of a planar map into a bake.
Definition HexTerrainBake.cpp:81
Result< void > applyHexSphereTerrain(HexSphereMap &map, const HexTerrainBake &bake)
Replace a spherical map's cells with a bake.
Definition HexTerrainBake.cpp:192
Value hexTerrainBakeToValue(const HexTerrainBake &bake)
Project a bake into the script Result payload.
Definition HexTerrainBake.cpp:111
const EditorValue * field(const EditorValue &value, const char *name)
Definition RoadNetworkEditTarget.cpp:15
@ InvalidArgument
One cell of the hex map: packed values plus packed flags.
Definition HexCell.h:244
Packed terrain produced by a generator and applied onto a hex map.
Definition HexTerrainBake.h:28