载入中...
搜索中...
未找到
VoxelPaletteRuntime.cpp
浏览该文件的文档.
1#include <utility>
4namespace eve::voxel_editing {
5namespace {} // namespace
9 const VoxelPaletteTarget& document) {
10 const auto diagnostics = document.validate();
11 for (const auto& d : diagnostics)
12 if (d.severity() == DiagnosticSeverity::Error)
13 return Result<std::vector<VoxelPalettePublishedEntry>>::failure(
14 eve::Status(EditorStatus::Rejected, diagnostics));
15 auto candidate = std::make_unique<voxel::CubeTypeRegistry>();
16 std::vector<VoxelPalettePublishedEntry> published;
17 for (const auto& entry : document.entries()) {
18 const int base = candidate->add(entry.type);
19 if (base == 0)
20 return eve::editing::failed<std::vector<VoxelPalettePublishedEntry>>(
21 EditorStatus::Failed, RuleId("editor.voxel-palette.publish"),
22 "Voxel registry rejected a validated cube type");
23 published.push_back({entry.id, entry.type.name, base, entry.type.directional ? 4 : 1});
24 }
25 registry_ = std::move(candidate);
26 revision_ = document.revision();
27 return eve::editing::applied<std::vector<VoxelPalettePublishedEntry>>(std::move(published), diagnostics);
28}
29} // namespace eve::voxel_editing
float d
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Structured status and zero or more diagnostics for an operation.
Definition Status.h:68
std::uint64_t revision() const override
Return the current revision.
Result< std::vector< VoxelPalettePublishedEntry > > publish(const VoxelPaletteTarget &)
Build a complete registry before replacing the active generation.
~VoxelPaletteRuntime()
Voxel palette runtime.
VoxelPaletteRuntime()
Voxel palette runtime.
Revisioned Voxel CubeType palette with face-material Inspector.
std::vector< EditorDiagnostic > validate() const
Validate.
const std::vector< VoxelPaletteEntryValue > & entries() const
Entries.
editing::RuleId RuleId