载入中...
搜索中...
未找到
EditorRuntimeManifest.cpp
浏览该文件的文档.
2
3#include <algorithm>
4#include <deque>
5#include <unordered_set>
6
7namespace eve::editor {
8namespace {
9
10template <class Id>
11bool selected(const std::vector<Id>& values, const Id& id) {
12 return std::find(values.begin(), values.end(), id) != values.end();
13}
14
15Result<RuntimeEditorPackage> manifestError(const char* rule, std::string message) {
16 return eve::editing::failed<RuntimeEditorPackage>(EditorStatus::Rejected, RuleId(rule), std::move(message));
17}
18
19} // namespace
20
23 const EditorExtensionRegistry& extensions,
24 const MemoryAssetDatabase& assets) const {
27 if ((manifest.features & forbidden) != HostFeature::None)
28 return manifestError("editor.runtime.forbidden-feature",
29 "Runtime editor manifest requests a developer-only feature");
30
33 package.profile.setFeatures(manifest.features);
35 for (const CommandId& id : manifest.commands) {
36 const CommandDescriptor* descriptor = commands.find(id);
37 if (!descriptor)
38 return manifestError("editor.runtime.command-not-found",
39 "Manifest command is not registered: " + id.value());
40 if (!descriptor->automationAllowed)
41 return manifestError("editor.runtime.command-not-publishable",
42 "Manifest command is not publishable: " + id.value());
43 if (!package.profile.hasFeatures(descriptor->requiredFeatures))
44 return manifestError("editor.runtime.command-feature-missing",
45 "Manifest omits a feature required by command: " + id.value());
46 package.profile.allowCommand(id);
47 package.commands.push_back(*descriptor);
48 }
49
50 HostProfile audienceProfile = HostProfile::runtimeBuilder();
51 audienceProfile.setAllowAllCommands(true);
52 for (const auto& descriptor : extensions.tools(audienceProfile))
53 if (selected(manifest.tools, descriptor.id)) package.tools.push_back(descriptor);
54 for (const ToolId& id : manifest.tools)
55 if (std::none_of(package.tools.begin(), package.tools.end(), [&](const auto& value) { return value.id == id; }))
56 return manifestError("editor.runtime.tool-not-found", "Manifest tool is unavailable: " + id.value());
57 for (const auto& descriptor : extensions.palettes(audienceProfile))
58 if (selected(manifest.palettes, descriptor.id)) package.palettes.push_back(descriptor);
59 for (const StableId& id : manifest.palettes)
60 if (std::none_of(package.palettes.begin(), package.palettes.end(),
61 [&](const auto& value) { return value.id == id; }))
62 return manifestError("editor.runtime.palette-not-found", "Manifest palette is unavailable: " + id.value());
63 for (const auto& descriptor : extensions.rules(audienceProfile))
64 if (selected(manifest.rules, descriptor.id)) package.rules.push_back(descriptor);
65 for (const RuleId& id : manifest.rules)
66 if (std::none_of(package.rules.begin(), package.rules.end(), [&](const auto& value) { return value.id == id; }))
67 return manifestError("editor.runtime.rule-not-found", "Manifest rule is unavailable: " + id.value());
68
69 std::deque<AssetGuid> pending(manifest.rootAssets.begin(), manifest.rootAssets.end());
70 std::unordered_set<AssetGuid, StrongEditorIdHash<AssetGuid>> visited;
71 while (!pending.empty()) {
72 AssetGuid current = pending.front();
73 pending.pop_front();
74 if (!visited.emplace(current).second) continue;
75 if (!assets.find(current).ok())
76 return manifestError("editor.runtime.asset-not-found", "Manifest asset is unavailable: " + current.value());
77 package.assetClosure.push_back(current);
78 for (const AssetDependency& dependency : assets.dependencies(current))
79 if (dependency.kind != DependencyKind::EditorOnly && dependency.kind != DependencyKind::Source)
80 pending.push_back(dependency.to);
81 }
82 std::sort(package.assetClosure.begin(), package.assetClosure.end());
83 return eve::editing::applied<RuntimeEditorPackage>(std::move(package));
84}
85
86} // namespace eve::editor
double value
std::string descriptor
std::vector< QuestEvent > pending
std::map< std::string, Var > values
std::string message
double current
std::vector< VegetationPresetCommand > commands
Move-only operation result carrying either a value or Status.
Definition Result.h:155
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:314
Registry and execution gate for UI-, script- and automation-neutral commands.
Loads game extensions and filters their descriptors for each host.
std::vector< ExtensionToolDescriptor > tools(const HostProfile &profile) const
Return tool descriptors visible to a host.
std::vector< ExtensionRuleDescriptor > rules(const HostProfile &profile) const
Return validation descriptors visible to a host.
std::vector< ExtensionPaletteDescriptor > palettes(const HostProfile &profile) const
Return palette descriptors visible to a host.
Upper capability boundary for one editor host.
static HostProfile runtimeBuilder()
Safe runtime profile that denies commands unless allow-listed.
void setMaxPayloadBytes(size_t bytes)
Sets the max payload bytes.
void setAllowAllCommands(bool allow)
Sets the allow all commands.
bool hasFeatures(HostFeature required) const
True when features.
void setFeatures(HostFeature features)
Sets the features.
void allowCommand(CommandId id)
Allow command.
Thread-neutral in-memory asset index used by editor hosts and tests.
Result< AssetRecord > find(const AssetGuid &guid) const
Find one asset by stable GUID.
std::vector< AssetDependency > dependencies(const AssetGuid &guid, bool incoming=false) const
Query outgoing or incoming dependencies for one asset.
Result< RuntimeEditorPackage > publish(const RuntimeEditorManifest &manifest, const EditorCommandService &commands, const EditorExtensionRegistry &extensions, const MemoryAssetDatabase &assets) const
Build a deny-by-default runtime package.
eve::editing::RuleId RuleId
Definition EditorIds.h:32
HostFeature
Coarse host features used to discover and gate editor extensions.
Directed dependency between two stable asset identities.
Presentation and execution metadata for a registered command.
Explicit publish allow-list for a player-facing editor build.
Resolved editor package embedded into a game build.
std::vector< CommandDescriptor > commands
std::vector< ExtensionToolDescriptor > tools
std::vector< ExtensionRuleDescriptor > rules
std::vector< ExtensionPaletteDescriptor > palettes