载入中...
搜索中...
未找到
BiomeRulesEditor.cpp
浏览该文件的文档.
2#include <algorithm>
3#include <cmath>
4#include <cstdint>
5#include <simplesquirrel/simplesquirrel.hpp>
6#include <string>
7#include <utility>
11#include "procgen/PointSet.h"
14
15// BiomeRulesEditor.cpp
16namespace eve::biome_editor {
17namespace {
18
19template <class T = void>
20biome_editing::Result<T> editorError(biome_editing::EditorStatus status, std::string rule, std::string message) {
21 return eve::editing::failed<T>(status, biome_editing::RuleId(std::move(rule)), std::move(message));
22}
23
24} // namespace
25
26BiomeRulesEditor::SpatialResolver::SpatialResolver(procgen::SpatialData* forest, procgen::SpatialData* clearing)
27 : forest_(forest), clearing_(clearing) {}
28
29biome_editing::Result<procgen::SpatialData*> BiomeRulesEditor::SpatialResolver::resolve(
30 const std::string& asset) const {
31 if (asset == "asset://preview/forest.spatial") return eve::editing::applied<procgen::SpatialData*>(forest_);
32 if (asset == "asset://preview/clearing.spatial") return eve::editing::applied<procgen::SpatialData*>(clearing_);
33 return editorError<procgen::SpatialData*>(biome_editing::EditorStatus::NotFound, "editor.biome.spatial",
34 "Unknown biome spatial asset");
35}
36
37BiomeRulesEditor::BiomeRulesEditor(std::string targetId)
38 : target_(std::move(targetId)),
39 authority_(&target_),
40 transactions_(&authority_),
41 forestDomain_(procgen::SpatialData::box(0.0f, 0.0f, 0.0f, 4.0f, 0.0f, 4.0f)),
42 clearingDomain_(procgen::SpatialData::box(0.0f, 0.0f, 0.0f, 1.5f, 0.0f, 1.5f)),
43 resolver_(&forestDomain_, &clearingDomain_) {
44 seedPreviewDocument();
45 auto previewed = refreshPreview();
46 if (!previewed.ok()) previewed.ignore("biome editor keeps an empty PointSet when the seeded preview is rejected");
47}
48
49void BiomeRulesEditor::seedPreviewDocument() {
51 assets.push_back(biome_editing::EditorValue::Object{{"id", std::string("oak")},
52 {"asset", std::string("models/oak.prefab")},
53 {"weight", 1.0},
54 {"minScale", 1.0},
55 {"maxScale", 1.0},
56 {"randomYaw", false}});
58 layers.push_back(biome_editing::EditorValue::Object{{"id", std::string("forest")},
59 {"name", std::string("forest")},
60 {"spatial", std::string("asset://preview/forest.spatial")},
61 {"priority", std::int64_t{1}},
62 {"density", 1.0},
63 {"assets", std::move(assets)}});
65 content["layers"] = std::move(layers);
66 content["exclusions"] = biome_editing::EditorValue::Array{};
68 root["schemaVersion"] = std::int64_t{1};
69 root["content"] = biome_editing::EditorValue(std::move(content));
70 auto loaded = target_.loadSnapshot(biome_editing::EditorValue(std::move(root)));
71 if (!loaded.ok()) loaded.ignore("biome editor keeps defaults when the preview snapshot is rejected");
72}
73
75 editor::EditorWorkspace candidate = workspace;
76 struct Panel {
77 const char* id;
78 const char* title;
79 const char* region;
80 const char* context;
81 int order;
82 };
83 constexpr Panel panels[] = {
84 {"biome.layers", "Layers", "left", "list", 100},
85 {"biome.preview", "World Preview", "center", "preview", 100},
86 {"biome.inspector", "Biome Inspector", "right", "inspector", 100},
87 {"biome.assets", "Layer Assets", "bottom", "assets", 100},
88 };
89 for (const auto& panel : panels) {
90 if (!candidate.registerPanel(panel.id, panel.title, panel.region, panel.order) ||
91 !candidate.setPanelCapability(panel.id, "biome.rules") ||
92 !candidate.setPanelContext(panel.id, panel.context))
93 return editorError(biome_editing::EditorStatus::Rejected, "editor.biome.workspace-conflict",
94 "Could not install the biome workspace composition");
95 }
96 if (!candidate.activatePanel("biome.preview"))
97 return editorError(biome_editing::EditorStatus::Rejected, "editor.biome.workspace-activate",
98 "Could not activate the biome preview panel");
99 workspace = std::move(candidate);
100 return eve::editing::applied<void>();
101}
102
103editor::SelectionSnapshot BiomeRulesEditor::selection() const {
105 snapshot.channel = "biome";
107 item.domain = editor::SelectionDomain::Asset;
108 item.target = editor::TargetId(target_.targetId());
109 item.item = editor::StableId(selectedId_);
110 item.type = selectedType_;
111 snapshot.items.push_back(item);
112 snapshot.primary = item;
113 return snapshot;
114}
115
117 std::string label) {
118 if (!operation.ok()) return biome_editing::Result<void>::failure(operation.status());
120 spec.id = editor::TransactionId("biome.rules.tx." + std::to_string(++txSequence_));
121 spec.label = std::move(label);
122 spec.target = editor::TargetId(target_.targetId());
123 spec.baseRevision = target_.revision();
124 auto begun = transactions_.begin(std::move(spec));
125 if (!begun.ok()) return editorError(begun.code(), "editor.biome.begin", "Could not begin the biome transaction");
126 auto appended = transactions_.append(std::move(operation).takeValue());
127 if (!appended.ok()) {
128 auto discarded = transactions_.discard();
129 if (!discarded.ok()) discarded.ignore("pending biome transaction already inactive");
130 return biome_editing::Result<void>::failure(appended.status());
131 }
132 auto committed = transactions_.commit();
133 if (!committed.ok()) return biome_editing::Result<void>::failure(committed.status());
134 return refreshPreview();
135}
136
137biome_editing::Result<void> BiomeRulesEditor::refreshPreview() {
138 auto published = runtime_.publish(target_, resolver_);
139 if (!published.ok()) return biome_editing::Result<void>::failure(published.status());
140 auto generated = runtime_.preview(&forestDomain_, spacing_, seed_, 0.0f, runtime_.revision());
141 if (!generated.ok()) return biome_editing::Result<void>::failure(generated.status());
142 std::vector<PreviewPoint> next;
143 const auto& points = generated.value();
144 if (points) {
145 next.reserve(static_cast<std::size_t>(points->getCount()));
146 for (int i = 0; i < points->getCount(); ++i) {
147 PreviewPoint point;
148 point.x = points->getX(i);
149 point.z = points->getZ(i);
150 point.asset = points->getStringAttribute(i, "asset", {});
151 next.push_back(std::move(point));
152 }
153 }
154 points_ = std::move(next);
155 previewRevision_ = target_.revision();
156 return eve::editing::applied<void>();
157}
158
160 bool found = false;
161 for (const auto& layer : target_.layers())
162 if (layer.id.value() == id) found = true;
163 if (!found)
164 return editorError(biome_editing::EditorStatus::NotFound, "editor.biome.layer", "Biome layer was not found");
165 selectedId_ = std::move(id);
166 selectedType_ = "biome.layer";
167 return eve::editing::applied<void>();
168}
169
171 bool found = false;
172 for (const auto& layer : target_.layers())
173 for (const auto& asset : layer.assets)
174 if (asset.id.value() == id) found = true;
175 if (!found)
176 return editorError(biome_editing::EditorStatus::NotFound, "editor.biome.asset", "Biome asset was not found");
177 selectedId_ = std::move(id);
178 selectedType_ = "biome.asset";
179 return eve::editing::applied<void>();
180}
181
183 if (selectedType_ != "biome.layer")
184 return editorError(biome_editing::EditorStatus::Rejected, "editor.biome.selection",
185 "A layer must be selected to change density");
186 const auto previous = points_;
187 const auto revision = previewRevision_;
188 auto applied =
189 commit(target_.makeSet(selection(), biome_editing::PropertyPath("layer.density"),
190 biome_editing::EditorValue(density), biome_editing::PropertySetMode::Absolute),
191 "Set layer density");
192 if (!applied.ok()) {
193 points_ = previous;
194 previewRevision_ = revision;
195 }
196 return applied;
197}
198
200 if (selectedType_ != "biome.layer")
201 return editorError(biome_editing::EditorStatus::Rejected, "editor.biome.selection",
202 "A layer must be selected to change priority");
203 return commit(
204 target_.makeSet(selection(), biome_editing::PropertyPath("layer.priority"),
205 biome_editing::EditorValue(std::int64_t{priority}), biome_editing::PropertySetMode::Absolute),
206 "Set layer priority");
207}
208
210 if (selectedType_ != "biome.asset")
211 return editorError(biome_editing::EditorStatus::Rejected, "editor.biome.selection",
212 "An asset must be selected to change weight");
213 return commit(target_.makeSet(selection(), biome_editing::PropertyPath("asset.weight"),
214 biome_editing::EditorValue(weight), biome_editing::PropertySetMode::Absolute),
215 "Set asset weight");
216}
217
220 layer.id = biome_editing::ObjectId(std::move(id));
221 layer.name = std::move(name);
222 layer.spatialAsset = "asset://preview/forest.spatial";
223 layer.density = 1.0f;
224 auto created = commit(target_.makeCreateLayer(layer), "Create layer");
225 if (!created.ok()) return created;
226 return selectLayer(layer.id.value());
227}
228
230 if (selectedType_ != "biome.layer")
231 return editorError(biome_editing::EditorStatus::Rejected, "editor.biome.selection",
232 "A layer must be selected to delete it");
233 auto deleted = commit(target_.makeDeleteLayer(biome_editing::ObjectId(selectedId_)), "Delete layer");
234 if (!deleted.ok()) return deleted;
235 if (!target_.layers().empty()) return selectLayer(target_.layers().front().id.value());
236 selectedId_.clear();
237 return eve::editing::applied<void>();
238}
239
241 const auto* layer = selectedLayer();
242 if (!layer)
243 return editorError(biome_editing::EditorStatus::Rejected, "editor.biome.selection",
244 "A layer must be selected to add an asset");
246 value.id = biome_editing::ObjectId(std::move(id));
247 value.asset = std::move(asset);
248 auto created = commit(target_.makeCreateAsset(layer->id, value), "Create asset");
249 if (!created.ok()) return created;
250 return selectAsset(value.id.value());
251}
252
254 if (selectedType_ != "biome.asset")
255 return editorError(biome_editing::EditorStatus::Rejected, "editor.biome.selection",
256 "An asset must be selected to delete it");
257 return commit(target_.makeDeleteAsset(biome_editing::ObjectId(selectedId_)), "Delete asset");
258}
259
261 auto next = target_.exclusions();
262 next.push_back(std::move(spatialAsset));
263 const auto previous = points_;
264 const auto revision = previewRevision_;
265 auto applied = commit(target_.makeSetExclusions(std::move(next)), "Add exclusion");
266 if (!applied.ok()) {
267 points_ = previous;
268 previewRevision_ = revision;
269 }
270 return applied;
271}
272
274 auto next = target_.exclusions();
275 std::erase(next, spatialAsset);
276 return commit(target_.makeSetExclusions(std::move(next)), "Remove exclusion");
277}
278
280 seed_ = seed;
281 return refreshPreview();
282}
283
285 if (!std::isfinite(spacing) || spacing <= 0.0f)
286 return editorError(biome_editing::EditorStatus::Rejected, "editor.biome.spacing",
287 "Biome preview spacing must be positive");
288 spacing_ = spacing;
289 return refreshPreview();
290}
291
293 auto result = transactions_.undo();
294 if (!result.ok()) return result;
295 auto previewed = refreshPreview();
296 if (!previewed.ok()) return biome_editing::Result<editor::TransactionReceipt>::failure(previewed.status());
297 return result;
298}
299
301 auto result = transactions_.redo();
302 if (!result.ok()) return result;
303 auto previewed = refreshPreview();
304 if (!previewed.ok()) return biome_editing::Result<editor::TransactionReceipt>::failure(previewed.status());
305 return result;
306}
307
308const biome_editing::BiomeLayerValue* BiomeRulesEditor::selectedLayer() const {
309 if (selectedType_ == "biome.layer") {
310 for (const auto& layer : target_.layers())
311 if (layer.id.value() == selectedId_) return &layer;
312 }
313 if (selectedType_ == "biome.asset") {
314 for (const auto& layer : target_.layers())
315 for (const auto& asset : layer.assets)
316 if (asset.id.value() == selectedId_) return &layer;
317 }
318 if (!target_.layers().empty()) return &target_.layers().front();
319 return nullptr;
320}
321
322const biome_editing::BiomeAssetValue* BiomeRulesEditor::assetAt(int index) const {
323 const auto* layer = selectedLayer();
324 if (!layer || index < 0 || static_cast<std::size_t>(index) >= layer->assets.size()) return nullptr;
325 return &layer->assets[static_cast<std::size_t>(index)];
326}
327
328std::string BiomeRulesEditor::layerId(int index) const {
329 if (index < 0 || static_cast<std::size_t>(index) >= target_.layers().size()) return {};
330 return target_.layers()[static_cast<std::size_t>(index)].id.value();
331}
332std::string BiomeRulesEditor::layerName(int index) const {
333 if (index < 0 || static_cast<std::size_t>(index) >= target_.layers().size()) return {};
334 return target_.layers()[static_cast<std::size_t>(index)].name;
335}
337 if (index < 0 || static_cast<std::size_t>(index) >= target_.layers().size()) return 0.0f;
338 return target_.layers()[static_cast<std::size_t>(index)].density;
339}
341 if (index < 0 || static_cast<std::size_t>(index) >= target_.layers().size()) return 0;
342 return target_.layers()[static_cast<std::size_t>(index)].priority;
343}
345 return selectedType_ == "biome.layer" && layerId(index) == selectedId_;
346}
347
349 const auto* layer = selectedLayer();
350 return layer ? static_cast<int>(layer->assets.size()) : 0;
351}
352std::string BiomeRulesEditor::assetId(int index) const {
353 const auto* asset = assetAt(index);
354 return asset ? asset->id.value() : std::string{};
355}
356std::string BiomeRulesEditor::assetRef(int index) const {
357 const auto* asset = assetAt(index);
358 return asset ? asset->asset : std::string{};
359}
361 const auto* asset = assetAt(index);
362 return asset ? asset->weight : 0.0f;
363}
365 const auto* asset = assetAt(index);
366 return asset && selectedType_ == "biome.asset" && asset->id.value() == selectedId_;
367}
368
370 if (index < 0 || static_cast<std::size_t>(index) >= target_.exclusions().size()) return {};
371 return target_.exclusions()[static_cast<std::size_t>(index)];
372}
373
375 if (index < 0 || static_cast<std::size_t>(index) >= points_.size()) return 0.0f;
376 return points_[static_cast<std::size_t>(index)].x;
377}
379 if (index < 0 || static_cast<std::size_t>(index) >= points_.size()) return 0.0f;
380 return points_[static_cast<std::size_t>(index)].z;
381}
382std::string BiomeRulesEditor::pointAsset(int index) const {
383 if (index < 0 || static_cast<std::size_t>(index) >= points_.size()) return {};
384 return points_[static_cast<std::size_t>(index)].asset;
385}
386
387} // namespace eve::biome_editor
388
389// BiomeRulesEditorScriptBindings.cpp
390namespace eve::biome_editor {
391namespace {
392
393constexpr const char* kBindingSource = "editor.biome.rules.squirrel";
394
395class ScriptBiomeRulesEditor {
396public:
397 explicit ScriptBiomeRulesEditor(std::string targetId) : editor_(std::move(targetId)) {}
398
399 BiomeRulesEditor& editor() noexcept { return editor_; }
400 const BiomeRulesEditor& editor() const noexcept { return editor_; }
401
402private:
403 BiomeRulesEditor editor_;
404};
405
406} // namespace
407
408void exposeBiomeRulesEditorScriptBindings(ssq::Table& table, ssq::Class& moduleClass) {
409 const editor::ScriptBind bind{table.getHandle(), kBindingSource};
410 auto biomeEditor = editor::addScriptClass<ScriptBiomeRulesEditor>(table, "BiomeRulesEditor");
411 editor::registerEditorWorkspace<ScriptBiomeRulesEditor>(biomeEditor, bind,
412 "biome editor and workspace must not be null");
413 biomeEditor.addFunc("selectLayer", [bind](ScriptBiomeRulesEditor* self, const std::string& id) {
414 return bind.checked(self, "biome editor must not be null", [&] { return self->editor().selectLayer(id); });
415 });
416 biomeEditor.addFunc("selectAsset", [bind](ScriptBiomeRulesEditor* self, const std::string& id) {
417 return bind.checked(self, "biome editor must not be null", [&] { return self->editor().selectAsset(id); });
418 });
419 biomeEditor.addFunc("setLayerDensity", [bind](ScriptBiomeRulesEditor* self, float density) {
420 return bind.checked(self, "biome editor must not be null",
421 [&] { return self->editor().setLayerDensity(static_cast<double>(density)); });
422 });
423 biomeEditor.addFunc("setLayerPriority", [bind](ScriptBiomeRulesEditor* self, int priority) {
424 return bind.checked(self, "biome editor must not be null",
425 [&] { return self->editor().setLayerPriority(priority); });
426 });
427 biomeEditor.addFunc("setAssetWeight", [bind](ScriptBiomeRulesEditor* self, float weight) {
428 return bind.checked(self, "biome editor must not be null",
429 [&] { return self->editor().setAssetWeight(static_cast<double>(weight)); });
430 });
431 biomeEditor.addFunc("createLayer",
432 [bind](ScriptBiomeRulesEditor* self, const std::string& id, const std::string& name) {
433 return bind.checked(self, "biome editor must not be null",
434 [&] { return self->editor().createLayer(id, name); });
435 });
436 biomeEditor.addFunc("deleteSelectedLayer", [bind](ScriptBiomeRulesEditor* self) {
437 return bind.checked(self, "biome editor must not be null",
438 [&] { return self->editor().deleteSelectedLayer(); });
439 });
440 biomeEditor.addFunc("createAsset",
441 [bind](ScriptBiomeRulesEditor* self, const std::string& id, const std::string& asset) {
442 return bind.checked(self, "biome editor must not be null",
443 [&] { return self->editor().createAsset(id, asset); });
444 });
445 biomeEditor.addFunc("deleteSelectedAsset", [bind](ScriptBiomeRulesEditor* self) {
446 return bind.checked(self, "biome editor must not be null",
447 [&] { return self->editor().deleteSelectedAsset(); });
448 });
449 biomeEditor.addFunc("addExclusion", [bind](ScriptBiomeRulesEditor* self, const std::string& spatialAsset) {
450 return bind.checked(self, "biome editor must not be null",
451 [&] { return self->editor().addExclusion(spatialAsset); });
452 });
453 biomeEditor.addFunc("removeExclusion", [bind](ScriptBiomeRulesEditor* self, const std::string& spatialAsset) {
454 return bind.checked(self, "biome editor must not be null",
455 [&] { return self->editor().removeExclusion(spatialAsset); });
456 });
457 biomeEditor.addFunc("setSeed", [bind](ScriptBiomeRulesEditor* self, int seed) {
458 return bind.checked(self, "biome editor must not be null",
459 [&] { return self->editor().setSeed(static_cast<std::uint32_t>(seed)); });
460 });
461 biomeEditor.addFunc("setSpacing", [bind](ScriptBiomeRulesEditor* self, float spacing) {
462 return bind.checked(self, "biome editor must not be null", [&] { return self->editor().setSpacing(spacing); });
463 });
464 editor::registerEditorHistory<ScriptBiomeRulesEditor>(biomeEditor, bind, "biome editor must not be null");
465 biomeEditor.addFunc("getPreviewRevision", [](ScriptBiomeRulesEditor* self) {
466 return self ? static_cast<int>(self->editor().previewRevision()) : 0;
467 });
468 biomeEditor.addFunc(
469 "getSeed", [](ScriptBiomeRulesEditor* self) { return self ? static_cast<int>(self->editor().seed()) : 0; });
470 biomeEditor.addFunc("getSpacing",
471 [](ScriptBiomeRulesEditor* self) { return self ? self->editor().spacing() : 0.0f; });
472 biomeEditor.addFunc("getSelectedId", [](ScriptBiomeRulesEditor* self) {
473 return self ? self->editor().selectedId() : std::string{};
474 });
475 biomeEditor.addFunc("getSelectedType", [](ScriptBiomeRulesEditor* self) {
476 return self ? self->editor().selectedType() : std::string{};
477 });
478 biomeEditor.addFunc("getLayerCount",
479 [](ScriptBiomeRulesEditor* self) { return self ? self->editor().layerCount() : 0; });
480 biomeEditor.addFunc("getLayerId", [](ScriptBiomeRulesEditor* self, int index) {
481 return self ? self->editor().layerId(index) : std::string{};
482 });
483 biomeEditor.addFunc("getLayerName", [](ScriptBiomeRulesEditor* self, int index) {
484 return self ? self->editor().layerName(index) : std::string{};
485 });
486 biomeEditor.addFunc("getLayerDensity", [](ScriptBiomeRulesEditor* self, int index) {
487 return self ? self->editor().layerDensity(index) : 0.0f;
488 });
489 biomeEditor.addFunc("getLayerPriority", [](ScriptBiomeRulesEditor* self, int index) {
490 return self ? self->editor().layerPriority(index) : 0;
491 });
492 biomeEditor.addFunc("getLayerSelected", [](ScriptBiomeRulesEditor* self, int index) {
493 return self && self->editor().isLayerSelected(index);
494 });
495 biomeEditor.addFunc("getAssetCount",
496 [](ScriptBiomeRulesEditor* self) { return self ? self->editor().assetCount() : 0; });
497 biomeEditor.addFunc("getAssetId", [](ScriptBiomeRulesEditor* self, int index) {
498 return self ? self->editor().assetId(index) : std::string{};
499 });
500 biomeEditor.addFunc("getAssetRef", [](ScriptBiomeRulesEditor* self, int index) {
501 return self ? self->editor().assetRef(index) : std::string{};
502 });
503 biomeEditor.addFunc("getAssetWeight", [](ScriptBiomeRulesEditor* self, int index) {
504 return self ? self->editor().assetWeight(index) : 0.0f;
505 });
506 biomeEditor.addFunc("getAssetSelected", [](ScriptBiomeRulesEditor* self, int index) {
507 return self && self->editor().isAssetSelected(index);
508 });
509 biomeEditor.addFunc("getExclusionCount",
510 [](ScriptBiomeRulesEditor* self) { return self ? self->editor().exclusionCount() : 0; });
511 biomeEditor.addFunc("getExclusionAsset", [](ScriptBiomeRulesEditor* self, int index) {
512 return self ? self->editor().exclusionAsset(index) : std::string{};
513 });
514 biomeEditor.addFunc("getPointCount",
515 [](ScriptBiomeRulesEditor* self) { return self ? self->editor().pointCount() : 0; });
516 biomeEditor.addFunc("getPointX", [](ScriptBiomeRulesEditor* self, int index) {
517 return self ? self->editor().pointX(index) : 0.0f;
518 });
519 biomeEditor.addFunc("getPointZ", [](ScriptBiomeRulesEditor* self, int index) {
520 return self ? self->editor().pointZ(index) : 0.0f;
521 });
522 biomeEditor.addFunc("getPointAsset", [](ScriptBiomeRulesEditor* self, int index) {
523 return self ? self->editor().pointAsset(index) : std::string{};
524 });
525
526 editor::registerEditorOwnedCreate<ScriptBiomeRulesEditor, BiomeEditorModule>(moduleClass, bind,
527 "biome target id must not be empty");
528}
529
530} // namespace eve::biome_editor
double z
double x
ActionParameterOperation operation
int root
Definition AnimSmr.cpp:119
Squirrel adapter for the biome rules editor.
UI-neutral biome editor: workspace, PointSet preview, undo.
int priority
std::string title
bool committed
bool applied
std::string name
Definition ECS.cpp:154
float density
ScriptFieldRegion region
std::string message
wgpu::PopErrorScopeStatus status
std::string label
std::string id
Poco::JSON::Object::Ptr result
Snapshot snapshot
std::vector< std::int32_t > order
std::shared_ptr< const OceanSprayFrame > previous
TileLayer * layer
std::unordered_set< std::string > loaded
Definition Plugins.cpp:24
std::uint32_t targetId
std::shared_ptr< const std::vector< glm::vec2 > > points
Object::Ptr value
bool found
int created
int spacing
uint32_t seed
Definition TreeMesh.cpp:276
double weight
uint32_t index
const VegetationPresetContext & context
glm::vec3 point
void ignore(std::string_view reason={}) const noexcept
Explicitly discard this result after documenting the reason.
Definition Result.h:571
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
Result< void > publish(const BiomeDocumentTarget &, const IBiomeSpatialResolver &)
Publish.
Revision revision() const
Revision.
Result< std::unique_ptr< procgen::PointSet > > preview(procgen::SpatialData *domain, float spacing, std::uint32_t seed, float jitter, Revision expectedRevision)
Generate a PointSet from a previously published candidate.
Result< DomainOperation > makeCreateLayer(const BiomeLayerValue &) const
Make create layer.
const std::vector< std::string > & exclusions() const
Exclusions.
const std::vector< BiomeLayerValue > & layers() const
Layers.
Result< void > loadSnapshot(const EditorValue &)
Loads snapshot.
Result< DomainOperation > makeSet(const SelectionSnapshot &, const PropertyPath &, const EditorValue &, PropertySetMode) const override
Make set.
Result< DomainOperation > makeDeleteLayer(const ObjectId &) const
Make delete layer.
Result< DomainOperation > makeDeleteAsset(const ObjectId &) const
Make delete asset.
Result< DomainOperation > makeSetExclusions(std::vector< std::string >) const
Make set exclusions.
TargetId targetId() const override
Target id.
Definition BiomeTarget.h:74
Result< DomainOperation > makeCreateAsset(const ObjectId &layer, const BiomeAssetValue &) const
Make create asset.
std::string assetId(int index) const
Asset id.
int layerPriority(int index) const
Layer priority.
bool isLayerSelected(int index) const
True when layer selected.
biome_editing::Result< void > removeExclusion(std::string spatialAsset)
biome_editing::Result< void > setSeed(std::uint32_t seed)
std::string layerName(int index) const
Layer name.
biome_editing::Result< void > createAsset(std::string id, std::string asset)
std::uint32_t seed() const noexcept
Seed.
biome_editing::Result< void > addExclusion(std::string spatialAsset)
std::string exclusionAsset(int index) const
Exclusion asset.
float pointX(int index) const
Point x.
float pointZ(int index) const
Point z.
biome_editing::Result< void > createLayer(std::string id, std::string name)
biome_editing::Result< void > configureWorkspace(editor::EditorWorkspace &workspace) const
Install Layers / Preview / Inspector / Assets panels.
biome_editing::Result< void > selectLayer(std::string id)
float spacing() const noexcept
Spacing.
float assetWeight(int index) const
Asset weight.
biome_editing::Result< editor::TransactionReceipt > undo()
float layerDensity(int index) const
Layer density.
std::uint64_t revision() const noexcept
Revision.
std::string pointAsset(int index) const
Point asset.
biome_editing::Result< void > setAssetWeight(double weight)
bool isAssetSelected(int index) const
True when asset selected.
std::string layerId(int index) const
Layer id.
std::string assetRef(int index) const
Asset ref.
biome_editing::Result< void > setSpacing(float spacing)
biome_editing::Result< void > selectAsset(std::string id)
biome_editing::Result< void > deleteSelectedAsset()
biome_editing::Result< editor::TransactionReceipt > redo()
biome_editing::Result< void > setLayerDensity(double density)
biome_editing::Result< void > deleteSelectedLayer()
biome_editing::Result< void > setLayerPriority(int priority)
std::uint64_t revision() const override
Return the current revision.
Dotted property path (layout.size) compared and persisted as text.
Definition EditingIds.h:78
Deterministic owning value tree shared by authoring hosts.
std::vector< Value > Array
std::map< std::string, Value > Object
Composition model shared by project-specific developer and runtime editors.
bool setPanelContext(const std::string &id, const std::string &context)
Attach a semantic input context such as scene, graph, or timeline.
Result< WorkspacePanelDescriptor > registerPanel(WorkspacePanelDescriptor descriptor)
Register a checked owning panel descriptor.
Result< WorkspacePanelDescriptor > activatePanel(const StableId &id)
Activate a visible panel with structured not-found/rejected results.
bool setPanelCapability(const std::string &id, const std::string &capability)
Attach a capability requirement used by the host when filtering panels.
Result< TransactionReceipt > commit() override
Preflight and commit all active operations through the authority.
Result< TransactionId > begin(TransactionSpec specification) override
Begin a transaction with a stable id and base revision.
Result< TransactionReceipt > undo() override
Compensate the most recent committed transaction.
Result< void > discard() override
Discard the active, not-yet-committed operation list.
Result< TransactionReceipt > redo() override
Reapply the most recently compensated transaction.
Result< void > append(DomainOperation operation) override
Append an operation to the active transaction without applying it.
Editor facade binder: common script::BindContext plus history/owned-create helpers.
editing::Status EditorStatus
Definition BiomeTarget.h:23
editing::ObjectId ObjectId
Definition BiomeTarget.h:30
editing::RuleId RuleId
Definition BiomeTarget.h:40
editing::Value EditorValue
Definition BiomeTarget.h:24
void exposeBiomeRulesEditorScriptBindings(ssq::Table &table, ssq::Class &moduleClass)
Expose the script-owned BiomeRulesEditor factory on BiomeEditorModule.
eve::editing::StableId StableId
Definition EditorIds.h:36
eve::editing::TargetId TargetId
Definition EditorIds.h:29
eve::editing::TransactionId TransactionId
Definition EditorIds.h:34
constexpr HexDirection next(HexDirection d) noexcept
The next direction clockwise (NW wraps to NE).
Definition HexMetrics.h:76
Stable weighted asset entry in one biome layer.
Definition BiomeTarget.h:45
Stable authored biome layer referencing a spatial asset.
Definition BiomeTarget.h:51
SelectionItem public API.
SelectionSnapshot public API.
TransactionSpec public API.