载入中...
搜索中...
未找到
BuildingSnapshot.cpp
浏览该文件的文档.
2#include <array>
3#include <cmath>
4#include <limits>
5#include <set>
8
10namespace {
11template <class T>
12Result<T> failure(StatusCode status, std::string rule, std::string message) {
13 return Result<T>::failure(
15 {{"rule", std::move(rule)}}, "building.codec")));
16}
17template <class T>
18Result<T> success(T value) {
19 return Result<T>::success(std::move(value));
20}
21} // namespace
22Value stringArray(const std::vector<std::string>& values) {
24 for (const std::string& value : values) result.emplace_back(value);
25 return result;
26}
27
28Value numberArray(const std::vector<double>& values) {
30 for (double value : values) result.emplace_back(value);
31 return result;
32}
33
34std::vector<std::string> parseStringArray(const Value& value, bool& valid) {
35 std::vector<std::string> result;
36 const auto* values = value.getIf<Value::Array>();
37 if (!values) {
38 valid = false;
39 return result;
40 }
41 for (const Value& item : *values) {
42 const auto* text = item.getIf<std::string>();
43 if (!text) {
44 valid = false;
45 return {};
46 }
47 result.push_back(*text);
48 }
49 return result;
50}
51
54 for (const auto& [key, value] : instance.properties) properties[key] = value;
55 Value::Array garrison;
56 for (const BuildingGarrisonMemberRecord& member : instance.garrison)
57 garrison.emplace_back(
58 Value::Object{{"id", member.id}, {"type", member.type}, {"tags", stringArray(member.tags)}});
59 return Value::Object{{"instanceId", int64_t{instance.instanceId}},
60 {"buildingId", instance.buildingId},
61 {"placementKind", instance.placementKind},
62 {"edgeX", int64_t{instance.edgeX}},
63 {"edgeY", int64_t{instance.edgeY}},
64 {"edgeAxis", instance.edgeAxis},
65 {"cornerX", int64_t{instance.cornerX}},
66 {"cornerY", int64_t{instance.cornerY}},
67 {"freeRadius", instance.freeRadius},
68 {"freeHalfWidth", instance.freeHalfWidth},
69 {"freeHalfHeight", instance.freeHalfHeight},
70 {"freeFootprintVertices", numberArray(instance.freeFootprintVertices)},
71 {"cellX", int64_t{instance.cellX}},
72 {"cellY", int64_t{instance.cellY}},
73 {"level", int64_t{instance.level}},
74 {"worldX", instance.worldX},
75 {"worldY", instance.worldY},
76 {"elevation", instance.elevation},
77 {"surfaceId", instance.surfaceId},
78 {"surfaceRevision", static_cast<int64_t>(instance.surfaceRevision)},
79 {"surfaceNormalX", instance.surfaceNormalX},
80 {"surfaceNormalY", instance.surfaceNormalY},
81 {"surfaceNormalZ", instance.surfaceNormalZ},
82 {"surfaceTangentX", instance.surfaceTangentX},
83 {"surfaceTangentY", instance.surfaceTangentY},
84 {"surfaceTangentZ", instance.surfaceTangentZ},
85 {"surfaceSampleCount", int64_t{instance.surfaceSampleCount}},
86 {"surfaceMaxSlopeDegrees", instance.surfaceMaxSlopeDegrees},
87 {"surfaceHeightDelta", instance.surfaceHeightDelta},
88 {"rotationDegrees", instance.rotationDegrees},
89 {"channel", instance.channel},
90 {"properties", std::move(properties)},
91 {"tags", stringArray(instance.tags)},
92 {"garrison", std::move(garrison)},
93 {"garrisonRevision", static_cast<int64_t>(instance.garrisonRevision)}};
94}
95
96const Value* field(const Value& value, const char* key) {
97 const auto* object = value.getIf<Value::Object>();
98 if (!object) return nullptr;
99 const auto found = object->find(key);
100 return found == object->end() ? nullptr : &found->second;
101}
102
104 const auto integer = [&](const char* key) -> const int64_t* {
105 const Value* entry = field(value, key);
106 return entry ? entry->getIf<int64_t>() : nullptr;
107 };
108 std::map<std::string, double> numbers;
109 for (const auto& key : value.keys()) {
110 const auto* entry = value.find(key);
111 if (entry->isNumeric()) {
112 const double n = entry->isInt64() ? double(entry->asInt()) : entry->asDouble();
113 if (!std::isfinite(n) || std::abs(n) > std::numeric_limits<float>::max())
114 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "building.invalid-number",
115 "Non-finite or overflowing number");
116 numbers[key] = n;
117 }
118 }
119 for (const char* key :
120 {"instanceId", "cellX", "cellY", "edgeX", "edgeY", "cornerX", "cornerY", "level", "surfaceSampleCount"}) {
121 if (const auto* entry = field(value, key);
122 entry && (!entry->isInt64() || entry->asInt() < std::numeric_limits<int>::min() ||
123 entry->asInt() > std::numeric_limits<int>::max()))
124 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "building.invalid-integer",
125 "Integer field out of range");
126 }
127 const auto number = [&](const char* key) -> const double* {
128 auto it = numbers.find(key);
129 return it == numbers.end() ? nullptr : &it->second;
130 };
131 const auto string = [&](const char* key) -> const std::string* {
132 const Value* entry = field(value, key);
133 return entry ? entry->getIf<std::string>() : nullptr;
134 };
135 const auto* instanceId = integer("instanceId");
136 const auto* buildingId = string("buildingId");
137 const auto* cellX = integer("cellX");
138 const auto* cellY = integer("cellY");
139 const auto* worldX = number("worldX");
140 const auto* worldY = number("worldY");
141 const auto* elevation = number("elevation");
142 const auto* rotation = number("rotationDegrees");
143 const auto* channel = string("channel");
144 const auto* propertiesValue = field(value, "properties");
145 const auto* tagsValue = field(value, "tags");
146 const auto* garrisonValue = field(value, "garrison");
147 const auto* garrisonRevision = integer("garrisonRevision");
148 const auto* properties = propertiesValue ? propertiesValue->getIf<Value::Object>() : nullptr;
149 const auto* garrison = garrisonValue ? garrisonValue->getIf<Value::Array>() : nullptr;
150 if (!instanceId || *instanceId <= 0 || !buildingId || buildingId->empty() || !cellX || !cellY || !worldX ||
151 !worldY || !elevation || !rotation || !channel || !properties || !tagsValue || !garrison || !garrisonRevision ||
152 *garrisonRevision < 0)
153 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "editor.building.invalid-instance",
154 "Building instance payload is incomplete");
156 result.instanceId = static_cast<int>(*instanceId);
157 result.buildingId = *buildingId;
158 if (const auto* placementKind = string("placementKind")) result.placementKind = *placementKind;
159 if (const auto* edgeX = integer("edgeX")) result.edgeX = static_cast<int>(*edgeX);
160 if (const auto* edgeY = integer("edgeY")) result.edgeY = static_cast<int>(*edgeY);
161 if (const auto* edgeAxis = string("edgeAxis")) result.edgeAxis = *edgeAxis;
162 if (const auto* cornerX = integer("cornerX")) result.cornerX = static_cast<int>(*cornerX);
163 if (const auto* cornerY = integer("cornerY")) result.cornerY = static_cast<int>(*cornerY);
164 if (const auto* freeRadius = number("freeRadius")) result.freeRadius = *freeRadius;
165 if (const auto* freeHalfWidth = number("freeHalfWidth")) result.freeHalfWidth = *freeHalfWidth;
166 if (const auto* freeHalfHeight = number("freeHalfHeight")) result.freeHalfHeight = *freeHalfHeight;
167 if (const Value* polygon = field(value, "freeFootprintVertices")) {
168 const auto* vertices = polygon->getIf<Value::Array>();
169 if (!vertices)
170 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "editor.building.invalid-free-footprint",
171 "Free footprint vertices must be a numeric array");
172 for (const Value& vertex : *vertices) {
173 if (!vertex.isNumeric())
174 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "editor.building.invalid-free-footprint",
175 "Free footprint vertices must contain only numbers");
176 const double coordinate = vertex.isInt64() ? double(vertex.asInt()) : vertex.asDouble();
177 if (!std::isfinite(coordinate) || std::abs(coordinate) > std::numeric_limits<float>::max())
178 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "building.invalid-polygon",
179 "Invalid polygon coordinate");
180 result.freeFootprintVertices.push_back(coordinate);
181 }
182 }
183 result.cellX = static_cast<int>(*cellX);
184 result.cellY = static_cast<int>(*cellY);
185 if (const auto* level = integer("level")) result.level = static_cast<int>(*level);
186 result.worldX = *worldX;
187 result.worldY = *worldY;
188 result.elevation = *elevation;
189 if (const auto* surfaceId = string("surfaceId")) result.surfaceId = *surfaceId;
190 if (const auto* surfaceRevision = integer("surfaceRevision")) {
191 if (*surfaceRevision < 0)
192 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "editor.building.invalid-surface-revision",
193 "Surface revision must not be negative");
194 result.surfaceRevision = static_cast<std::uint64_t>(*surfaceRevision);
195 }
196 if (const auto* n = number("surfaceNormalX")) result.surfaceNormalX = *n;
197 if (const auto* n = number("surfaceNormalY")) result.surfaceNormalY = *n;
198 if (const auto* n = number("surfaceNormalZ")) result.surfaceNormalZ = *n;
199 if (const auto* n = number("surfaceTangentX")) result.surfaceTangentX = *n;
200 if (const auto* n = number("surfaceTangentY")) result.surfaceTangentY = *n;
201 if (const auto* n = number("surfaceTangentZ")) result.surfaceTangentZ = *n;
202 if (const auto* count = integer("surfaceSampleCount")) result.surfaceSampleCount = static_cast<int>(*count);
203 if (const auto* slope = number("surfaceMaxSlopeDegrees")) result.surfaceMaxSlopeDegrees = *slope;
204 if (const auto* delta = number("surfaceHeightDelta")) result.surfaceHeightDelta = *delta;
205 if (result.placementKind != "cell" && result.placementKind != "edge" && result.placementKind != "corner" &&
206 result.placementKind != "free")
207 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "editor.building.invalid-placement-kind",
208 "Placement kind must be cell, edge, corner, or free");
209 if (result.placementKind == "edge" && result.edgeAxis != "horizontal" && result.edgeAxis != "vertical")
210 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "editor.building.invalid-edge-axis",
211 "Edge axis must be horizontal or vertical");
212 result.rotationDegrees = *rotation;
213 result.channel = *channel;
214 result.garrisonRevision = static_cast<std::uint64_t>(*garrisonRevision);
215 for (const auto& [key, property] : *properties) {
216 const auto* text = property.getIf<std::string>();
217 if (!text)
218 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "editor.building.invalid-property",
219 "Building properties must be strings");
220 result.properties[key] = *text;
221 }
222 bool valid = true;
223 result.tags = parseStringArray(*tagsValue, valid);
224 if (!valid)
225 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "editor.building.invalid-tags",
226 "Building tags must be strings");
227 std::set<std::string> memberIds;
228 for (const Value& memberValue : *garrison) {
229 const auto* idValue = field(memberValue, "id");
230 const auto* typeValue = field(memberValue, "type");
231 const auto* memberTags = field(memberValue, "tags");
232 const auto* id = idValue ? idValue->getIf<std::string>() : nullptr;
233 const auto* type = typeValue ? typeValue->getIf<std::string>() : nullptr;
234 if (!id || id->empty() || !memberIds.insert(*id).second || !type || type->empty() || !memberTags)
235 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "editor.building.invalid-garrison",
236 "Garrison members require unique ids, type and tags");
237 auto tags = parseStringArray(*memberTags, valid);
238 if (!valid)
239 return failure<BuildingInstanceSnapshot>(StatusCode::Rejected, "editor.building.invalid-garrison-tags",
240 "Garrison member tags must be strings");
241 result.garrison.push_back({*id, *type, std::move(tags)});
242 }
243 return success<BuildingInstanceSnapshot>(std::move(result));
244}
245
247 const auto* values = value.getIf<Value::Array>();
248 if (!values || values->empty())
249 return failure<std::vector<BuildingInstanceSnapshot>>(
250 StatusCode::Rejected, "editor.building.invalid-area-payload",
251 "Building area payload must contain at least one instance");
252 std::vector<BuildingInstanceSnapshot> result;
253 std::set<int> ids;
254 result.reserve(values->size());
255 for (const Value& item : *values) {
256 auto parsed = parseInstance(item);
257 if (!parsed.ok())
258 return failure<std::vector<BuildingInstanceSnapshot>>(parsed.code(),
259 "editor.building.invalid-area-instance",
260 "Building area payload contains an invalid instance");
261 if (!ids.insert(parsed.value().instanceId).second)
262 return failure<std::vector<BuildingInstanceSnapshot>>(
263 StatusCode::Rejected, "editor.building.duplicate-area-instance",
264 "Building area payload contains duplicate instance ids");
265 result.push_back(std::move(parsed).takeValue());
266 }
267 return success<std::vector<BuildingInstanceSnapshot>>(std::move(result));
268}
269
272 result.instanceId = placed.instanceId;
273 result.buildingId = placed.buildingId;
274 result.placementKind = placed.placementKind;
275 result.edgeX = placed.edge.x;
276 result.edgeY = placed.edge.y;
277 result.edgeAxis = placed.edge.axis == building::EdgeAxis::Horizontal ? "horizontal" : "vertical";
278 result.cornerX = placed.corner.x;
279 result.cornerY = placed.corner.y;
280 result.freeRadius = placed.freeRadius;
281 result.freeHalfWidth = placed.freeHalfWidth;
282 result.freeHalfHeight = placed.freeHalfHeight;
283 for (float coordinate : placed.freeFootprintVertices) result.freeFootprintVertices.push_back(coordinate);
284 result.cellX = placed.originCellX;
285 result.cellY = placed.originCellY;
286 result.level = placed.level;
287 result.worldX = placed.worldX;
288 result.worldY = placed.worldY;
289 result.elevation = placed.elevation;
290 result.surfaceId = placed.surfaceId;
291 result.surfaceRevision = placed.surfaceRevision;
292 result.surfaceNormalX = placed.surfaceNormalX;
293 result.surfaceNormalY = placed.surfaceNormalY;
294 result.surfaceNormalZ = placed.surfaceNormalZ;
295 result.surfaceTangentX = placed.surfaceTangentX;
296 result.surfaceTangentY = placed.surfaceTangentY;
297 result.surfaceTangentZ = placed.surfaceTangentZ;
298 result.surfaceSampleCount = placed.surfaceSampleCount;
299 result.surfaceMaxSlopeDegrees = placed.surfaceMaxSlopeDegrees;
300 result.surfaceHeightDelta = placed.surfaceHeightDelta;
301 result.rotationDegrees = placed.rotationDeg;
302 result.channel = placed.channel;
303 result.properties.insert(placed.props.begin(), placed.props.end());
304 result.tags = placed.tags;
305 for (const building::GarrisonMember& member : placed.garrison)
306 result.garrison.push_back({member.id, member.type, member.tags});
307 result.garrisonRevision = placed.garrisonRevision.value();
308 return result;
309}
310
313 result.instanceId = value.instanceId;
314 result.buildingId = value.buildingId;
315 result.placementKind = value.placementKind;
316 result.edge = {value.edgeX, value.edgeY,
317 value.edgeAxis == "vertical" ? building::EdgeAxis::Vertical : building::EdgeAxis::Horizontal};
318 result.corner = {value.cornerX, value.cornerY};
319 result.freeRadius = static_cast<float>(value.freeRadius);
320 result.freeHalfWidth = static_cast<float>(value.freeHalfWidth);
321 result.freeHalfHeight = static_cast<float>(value.freeHalfHeight);
322 for (double coordinate : value.freeFootprintVertices)
323 result.freeFootprintVertices.push_back(static_cast<float>(coordinate));
324 result.originCellX = value.cellX;
325 result.originCellY = value.cellY;
326 result.level = value.level;
327 result.worldX = static_cast<float>(value.worldX);
328 result.worldY = static_cast<float>(value.worldY);
329 result.elevation = static_cast<float>(value.elevation);
330 result.surfaceId = value.surfaceId;
331 result.surfaceRevision = value.surfaceRevision;
332 result.surfaceNormalX = static_cast<float>(value.surfaceNormalX);
333 result.surfaceNormalY = static_cast<float>(value.surfaceNormalY);
334 result.surfaceNormalZ = static_cast<float>(value.surfaceNormalZ);
335 result.surfaceTangentX = static_cast<float>(value.surfaceTangentX);
336 result.surfaceTangentY = static_cast<float>(value.surfaceTangentY);
337 result.surfaceTangentZ = static_cast<float>(value.surfaceTangentZ);
338 result.surfaceSampleCount = value.surfaceSampleCount;
339 result.surfaceMaxSlopeDegrees = static_cast<float>(value.surfaceMaxSlopeDegrees);
340 result.surfaceHeightDelta = static_cast<float>(value.surfaceHeightDelta);
341 result.rotationDeg = static_cast<float>(value.rotationDegrees);
342 result.channel = value.channel;
343 result.props.insert(value.properties.begin(), value.properties.end());
344 result.tags = value.tags;
345 for (const BuildingGarrisonMemberRecord& member : value.garrison)
346 result.garrison.push_back({member.id, member.type, member.tags});
347 result.garrisonRevision = eve::Revision(value.garrisonRevision);
348 return result;
349}
350
351
352Value edgeCurveValue(const building::EdgeCurveGroup& group, const std::vector<BuildingInstanceSnapshot>& instances) {
353 std::vector<double> controls;
354 for (const building::EdgeCurveControlPoint& point : group.controlPoints) {
355 controls.push_back(point.x);
356 controls.push_back(point.y);
357 }
359 for (const BuildingInstanceSnapshot& instance : instances) values.push_back(instanceValue(instance));
360 std::vector<double> surfaceSamples;
361 for (const building::EdgeCurveSurfaceSample& sample : group.surfaceSamples) {
362 surfaceSamples.insert(surfaceSamples.end(), {sample.worldX, sample.worldY, sample.worldZ, sample.normalX,
363 sample.normalY, sample.normalZ});
364 }
365 return Value::Object{{"groupId", static_cast<int64_t>(group.id.value)},
366 {"buildingId", group.buildingId},
367 {"level", int64_t{group.level}},
368 {"subdivisions", int64_t{group.subdivisions}},
369 {"controlPoints", numberArray(controls)},
370 {"surfaceProviderName", group.surfaceProviderName},
371 {"surfaceId", group.surfaceId},
372 {"surfaceRevision", static_cast<int64_t>(group.surfaceRevision)},
373 {"surfaceSamples", numberArray(surfaceSamples)},
374 {"instances", std::move(values)}};
375}
376
378 const Value* groupIdValue = field(value, "groupId");
379 const Value* buildingIdValue = field(value, "buildingId");
380 const Value* levelValue = field(value, "level");
381 const Value* subdivisionsValue = field(value, "subdivisions");
382 const Value* controlsValue = field(value, "controlPoints");
383 const Value* instancesValue = field(value, "instances");
384 const auto* groupId = groupIdValue ? groupIdValue->getIf<int64_t>() : nullptr;
385 const auto* buildingId = buildingIdValue ? buildingIdValue->getIf<std::string>() : nullptr;
386 const auto* level = levelValue ? levelValue->getIf<int64_t>() : nullptr;
387 const auto* subdivisions = subdivisionsValue ? subdivisionsValue->getIf<int64_t>() : nullptr;
388 const auto* controls = controlsValue ? controlsValue->getIf<Value::Array>() : nullptr;
389 if (!groupId || *groupId <= 0 || !buildingId || buildingId->empty() || !level ||
390 *level < std::numeric_limits<int>::min() || *level > std::numeric_limits<int>::max() || !subdivisions ||
391 *subdivisions < 2 || *subdivisions > 4096 || !controls || controls->size() != 8 || !instancesValue)
392 return failure<EdgeCurvePayload>(StatusCode::Rejected, "editor.building.invalid-edge-curve",
393 "Edge curve payload is incomplete");
394 auto instances = parseInstances(*instancesValue);
395 if (!instances.ok())
396 return failure<EdgeCurvePayload>(instances.code(), "editor.building.invalid-edge-curve-instances",
397 "Edge curve instances are invalid");
399 result.group.id = {static_cast<std::uint64_t>(*groupId)};
400 result.group.buildingId = *buildingId;
401 result.group.level = static_cast<int>(*level);
402 result.group.subdivisions = static_cast<int>(*subdivisions);
403 if (const Value* provider = field(value, "surfaceProviderName"))
404 if (const auto* text = provider->getIf<std::string>()) result.group.surfaceProviderName = *text;
405 if (const Value* surface = field(value, "surfaceId"))
406 if (const auto* text = surface->getIf<std::string>()) result.group.surfaceId = *text;
407 if (const Value* revision = field(value, "surfaceRevision")) {
408 const auto* integer = revision->getIf<int64_t>();
409 if (!integer || *integer < 0)
410 return failure<EdgeCurvePayload>(StatusCode::Rejected,
411 "editor.building.invalid-edge-curve-surface-revision",
412 "Edge curve surface revision is invalid");
413 result.group.surfaceRevision = static_cast<std::uint64_t>(*integer);
414 }
415 if (const Value* sampleValue = field(value, "surfaceSamples")) {
416 const auto* samples = sampleValue->getIf<Value::Array>();
417 if (!samples || samples->size() % 6 != 0)
418 return failure<EdgeCurvePayload>(StatusCode::Rejected, "editor.building.invalid-edge-curve-surface-samples",
419 "Edge curve surface samples must contain position and normal sextuples");
420 for (size_t index = 0; index < samples->size(); index += 6) {
421 std::array<float, 6> frame{};
422 for (size_t component = 0; component < 6; ++component) {
423 const auto& number = (*samples)[index + component];
424 if (!number.isNumeric())
425 return failure<EdgeCurvePayload>(StatusCode::Rejected,
426 "editor.building.invalid-edge-curve-surface-samples",
427 "Edge curve surface samples must be numeric");
428 frame[component] = static_cast<float>(number.isInt64() ? double(number.asInt()) : number.asDouble());
429 if (!std::isfinite(frame[component]))
430 return failure<EdgeCurvePayload>(StatusCode::Rejected, "building.invalid-curve-frame",
431 "Non-finite curve frame");
432 }
433 result.group.surfaceSamples.push_back({frame[0], frame[1], frame[2], frame[3], frame[4], frame[5]});
434 }
435 }
436 for (size_t index = 0; index < controls->size(); index += 2) {
437 const auto& x = (*controls)[index];
438 const auto& y = (*controls)[index + 1];
439 if (!x.isNumeric() || !y.isNumeric())
440 return failure<EdgeCurvePayload>(StatusCode::Rejected, "editor.building.invalid-edge-curve-controls",
441 "Edge curve controls must be numbers");
442 result.group.controlPoints.push_back({static_cast<float>(x.isInt64() ? double(x.asInt()) : x.asDouble()),
443 static_cast<float>(y.isInt64() ? double(y.asInt()) : y.asDouble())});
444 }
445 for (const auto& point : result.group.controlPoints)
446 if (!std::isfinite(point.x) || !std::isfinite(point.y))
447 return failure<EdgeCurvePayload>(StatusCode::Rejected, "building.invalid-curve-controls",
448 "Non-finite curve controls");
449 result.instances = std::move(instances).takeValue();
450 for (const BuildingInstanceSnapshot& instance : result.instances)
451 result.group.instanceIds.push_back(instance.instanceId);
452 return success<EdgeCurvePayload>(std::move(result));
453}
454
455
456} // namespace eve::building::codec
double y
double x
std::uint64_t revision
SQObjectPtr key
Definition ECS.cpp:155
int instanceId
std::string message
wgpu::PopErrorScopeStatus status
glm::vec3 n
Definition Grass.cpp:63
float elevation
std::vector< NumericField > numbers
std::array< float, 4 > rotation
std::map< std::string, PropertyRule > properties
std::string id
Poco::JSON::Object::Ptr result
Snapshot snapshot
bool valid
std::unordered_set< std::string > tags
int level
ssq::Object frame
std::set< std::string > values
Object::Ptr value
double number
bool found
std::string text
std::string string
int count
AbilityActivationGroup group
bool placed
std::array< double, 2 > vertices[3]
float(ui::Theme::* member)[4]
uint32_t index
glm::vec3 point
A structured explanation of a failed, degraded, or noteworthy result.
Definition Diagnostic.h:94
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Status failure(StatusCode code, Diagnostic diagnostic)
Construct a failed status with one diagnostic.
Definition Status.cpp:28
std::map< std::string, Value > Object
Definition Value.h:34
std::vector< Value > Array
Definition Value.h:33
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:209
EVENGINE_API_FOUNDATION public API.
Definition Json.h:39
std::unordered_map< const void *, size_t > ids
Definition Snapshot.cpp:109
Result< EdgeCurvePayload > parseEdgeCurve(const Value &value)
Decode one complete curve with structured failure and independent ownership.
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
Result< std::vector< BuildingInstanceSnapshot > > parseInstances(const Value &value)
Decode a nonempty instance batch with unique identities; pure owning result.
Result< BuildingInstanceSnapshot > parseInstance(const Value &value)
Decode legacy/current instance fields without mutating a world; owning result.
Value stringArray(const std::vector< std::string > &values)
Value numberArray(const std::vector< double > &values)
Value edgeCurveValue(const building::EdgeCurveGroup &group, const std::vector< BuildingInstanceSnapshot > &instances)
Encode one complete curve group in linear time; no world mutation.
std::vector< std::string > parseStringArray(const Value &value, bool &valid)
Value instanceValue(const BuildingInstanceSnapshot &instance)
Encode a complete owning instance; pure, caller-thread, linear in instance metadata.
StatusCode
Stable outcome category for an operation.
Definition Status.h:28
detail::StrongUint64< detail::RevisionTag > Revision
Monotonic content/state revision used for optimistic-concurrency checks.
Definition Revision.h:13
Persistent garrison member copied through building editor undo.
Complete runtime-neutral placed-building snapshot.
std::map< std::string, std::string > properties
std::vector< BuildingGarrisonMemberRecord > garrison
One cubic Bezier control point in logical grid-vertex space.
World-owned authoritative description and membership of one committed edge curve.
One committed 3D centerline frame sampled from a custom placement surface.
One persistent member of a placed building's logical garrison.
已放置的建筑实例。
Owning curve group and all exact members, shared by runtime and editor persistence.