载入中...
搜索中...
未找到
ScriptComponentPayloadProvider.cpp
浏览该文件的文档.
2
3#include "common/ECS.h"
6#include "scene/Scene.h"
7
8#include <simplesquirrel/simplesquirrel.hpp>
9
10#include <algorithm>
11#include <cstdint>
12#include <memory>
13#include <string>
14#include <string_view>
15#include <utility>
16#include <vector>
17
18namespace eve::scene_editor {
19namespace {
20
22using scene_editing::DomainOperation;
26using scene_editing::PropertyDescriptor;
28using scene_editing::PropertyPath;
29using scene_editing::PropertyReadResult;
31using scene_editing::PropertySchema;
35using scene_editing::SceneComponentPayloadRef;
36using scene_editing::SelectionSnapshot;
39
41constexpr char kNodeSeparator = '|';
42constexpr char kVersionSeparator = '@';
43
45constexpr char kSetOperationType[] = "eve.script-component.field.set.v1";
46
52std::string encodeComponentId(std::string_view nodeId, std::string_view name, std::uint64_t version) {
53 return std::string(nodeId) + kNodeSeparator + std::string(name) + kVersionSeparator + std::to_string(version);
54}
55
56bool decodeComponentId(std::string_view text, std::string& nodeId, std::string& name, std::uint64_t& version) {
57 const std::size_t nodeEnd = text.find(kNodeSeparator);
58 if (nodeEnd == std::string_view::npos || nodeEnd == 0) return false;
59 const std::size_t versionPos = text.rfind(kVersionSeparator);
60 if (versionPos == std::string_view::npos || versionPos <= nodeEnd + 1 || versionPos + 1 >= text.size())
61 return false;
62 nodeId = std::string(text.substr(0, nodeEnd));
63 name = std::string(text.substr(nodeEnd + 1, versionPos - nodeEnd - 1));
64 if (name.empty()) return false;
65 std::uint64_t parsed = 0;
66 for (const char digit : text.substr(versionPos + 1)) {
67 if (digit < '0' || digit > '9') return false;
68 parsed = parsed * 10u + static_cast<std::uint64_t>(digit - '0');
69 }
70 if (parsed == 0) return false;
71 version = parsed;
72 return true;
73}
74
76PropertyType propertyTypeOf(const Value& value) {
77 switch (value.type()) {
78 case Value::Type::Bool: return PropertyType::Bool;
79 case Value::Type::Int64: return PropertyType::Int;
80 case Value::Type::Double: return PropertyType::Float;
81 case Value::Type::String: return PropertyType::String;
82 case Value::Type::Array: return PropertyType::Array;
83 case Value::Type::Object: return PropertyType::Struct;
84 case Value::Type::Null: break;
85 }
86 return PropertyType::ReadOnlyText;
87}
88
90const EditorValue* payloadField(const EditorValue& payload, const char* name) {
91 const auto* object = payload.getIf<EditorValue::Object>();
92 if (object == nullptr) return nullptr;
93 const auto found = object->find(name);
94 return found == object->end() ? nullptr : &found->second;
95}
96
98bool readPositiveNumber(const EditorValue& value, std::uint64_t& out) {
99 if (const auto* integer = value.getIf<std::int64_t>()) {
100 if (*integer <= 0) return false;
101 out = static_cast<std::uint64_t>(*integer);
102 return true;
103 }
104 if (const auto* number = value.getIf<double>()) {
105 if (!(*number > 0.0)) return false;
106 out = static_cast<std::uint64_t>(*number);
107 return true;
108 }
109 return false;
110}
111
112template <class T>
113Result<T> editRefusal(EditorStatus status, const char* rule, std::string message) {
114 return eve::editing::failed<T>(status, RuleId(rule), std::move(message));
115}
116
117} // namespace
118
119std::string_view ScriptComponentOperationTarget::setOperationType() { return kSetOperationType; }
120
121void ScriptComponentOperationTarget::bind(const TargetId& target, std::string nodeId, std::uint64_t entityId,
123 target_ = target;
124 nodeId_ = std::move(nodeId);
125 entityId_ = entityId;
126 name_ = std::move(name);
127 version_ = version;
128 generation_ = generation;
129 staging_ = false;
130 bound_ = true;
131
132 const Value* stored = eve::findScriptComponentValues(ScriptComponentStoreKey{entityId_, name_, version_});
133 fields_ = stored != nullptr && stored->isObject() ? *stored->getIf<Value::Object>() : Value::Object{};
134}
135
137 // 脚本组件的字段值不在场景文档里,文档版本号对它没有意义:用引擎侧存储的写版本号,
138 // 脚本写、原生写、恢复快照都会让它变。
139 return static_cast<std::uint64_t>(eve::scriptComponentStoreRevision());
140}
141
142Result<void> ScriptComponentOperationTarget::writeField(const std::string& field, const Value& value) {
143 if (staging_) {
144 // 候选副本只改自己那份字段:撤销要能"先在候选上试算",失败不留半套状态。
145 const auto found = fields_.find(field);
146 if (found == fields_.end())
147 return editRefusal<void>(EditorStatus::NotFound, "editor.scene.script-component.candidate-field",
148 "staged candidate has no declared field: " + field);
149 found->second = value;
150 return eve::editing::applied<void>();
151 }
152
153 const auto written =
154 eve::setScriptComponentField(ScriptComponentStoreKey{entityId_, name_, version_}, field, value);
155 if (!written.ok())
156 return editRefusal<void>(EditorStatus::NotFound, "editor.scene.script-component.storage",
157 "engine-side script component data is gone or has no such field: " + field);
158 return eve::editing::applied<void>();
159}
160
162 if (!bound_)
163 return editRefusal<void>(EditorStatus::Rejected, "editor.scene.script-component.unbound",
164 "script component operation target is not bound to a component");
165 if (std::string_view(operation.type) != setOperationType() || operation.target != target_)
166 return editRefusal<void>(EditorStatus::Rejected, "editor.scene.script-component.operation",
167 "operation does not write a field of this script component target");
168
169 const EditorValue* node = payloadField(operation.payload, "node");
170 const EditorValue* name = payloadField(operation.payload, "name");
171 const EditorValue* version = payloadField(operation.payload, "version");
172 const EditorValue* field = payloadField(operation.payload, "field");
173 const EditorValue* value = payloadField(operation.payload, "value");
174 const auto* nodeText = node != nullptr ? node->getIf<std::string>() : nullptr;
175 const auto* nameText = name != nullptr ? name->getIf<std::string>() : nullptr;
176 const auto* fieldText = field != nullptr ? field->getIf<std::string>() : nullptr;
177 std::uint64_t payloadVersion = 0;
178 if (nodeText == nullptr || nameText == nullptr || fieldText == nullptr || value == nullptr || version == nullptr ||
179 !readPositiveNumber(*version, payloadVersion))
180 return editRefusal<void>(EditorStatus::Rejected, "editor.scene.script-component.payload",
181 "script component operation payload is malformed");
182
183 // 载荷自带身份:绑定被后来的选中项改写过的过期目标只会被拒绝,不会写到别的组件上。
184 if (*nodeText != nodeId_ || *nameText != name_ || payloadVersion != version_.value())
185 return editRefusal<void>(EditorStatus::Conflict, "editor.scene.script-component.stale-target",
186 "operation belongs to another script component than the bound one");
187 return writeField(*fieldText, eve::editing::toPresentationValue(*value));
188}
189
190std::unique_ptr<scene_editing::IDomainOperationTarget> ScriptComponentOperationTarget::cloneDomainState() const {
191 auto candidate = std::make_unique<ScriptComponentOperationTarget>(*this);
192 candidate->staging_ = true;
193 // 候选从**权威状态**重新克隆字段:撤销/重做要整份发布候选,所以它必须握有一份完整字段,
194 // 而不是绑定当时那份可能已经过期的拷贝。数据已移除时不保留旧字段,候选写入返回 NotFound。
195 const Value* stored = eve::findScriptComponentValues(ScriptComponentStoreKey{entityId_, name_, version_});
196 if (stored != nullptr && stored->isObject()) candidate->fields_ = *stored->getIf<Value::Object>();
197 else
198 candidate->fields_.clear();
199 return candidate;
200}
201
203 std::unique_ptr<scene_editing::IDomainOperationTarget> candidate) {
204 auto* typed = dynamic_cast<ScriptComponentOperationTarget*>(candidate.get());
205 if (typed == nullptr || !typed->staging_ || !bound_ || !typed->bound_ || typed->target_ != target_ ||
206 typed->entityId_ != entityId_ || typed->name_ != name_ || typed->version_ != version_)
207 return editRefusal<void>(EditorStatus::Conflict, "editor.scene.script-component.candidate",
208 "staged candidate belongs to another script component");
209 if (eve::findScriptComponentValues(ScriptComponentStoreKey{entityId_, name_, version_}) == nullptr)
210 return editRefusal<void>(EditorStatus::Conflict, "editor.scene.script-component.missing-data",
211 "script component data is gone, so the edit cannot be published");
212 // 换代(同名同版本重新登记)之后这份数据属于旧 schema:宁可拒绝,也不按新 schema 发布。
213 const auto declared = eve::scriptComponentDeclaredSchema(name_, version_);
214 if (!declared.ok() || declared.value().generation != generation_)
215 return editRefusal<void>(EditorStatus::Conflict, "editor.scene.script-component.stale-generation",
216 "script component was re-registered since the reference, so the edit is refused");
217
218 // 整份发布:候选是按权威状态克隆的,事务两侧又都有版本号校验,所以这一次
219 // `setScriptComponentValues` 就是"原子发布"——不存在写了一半的字段表。
220 const auto published = eve::setScriptComponentValues(ScriptComponentStoreKey{entityId_, name_, version_},
221 Value::object(typed->fields_));
222 if (!published.ok())
223 return editRefusal<void>(EditorStatus::Failed, "editor.scene.script-component.publish",
224 "engine-side store refused the staged script component candidate");
225 fields_ = typed->fields_;
226 return eve::editing::applied<void>();
227}
228
230 static const std::string type = "eve.script-component";
231 return type;
232}
233
236
237std::string ScriptComponentPayloadProvider::hostNameOf(const scene_editing::TargetId& target) const {
238 if (resolver_) {
239 std::string resolved = resolver_(target);
240 if (!resolved.empty()) return resolved;
241 }
242 return target.value();
243}
244
245const std::string& ScriptComponentPayloadProvider::componentType() const { return payloadType(); }
246
247std::vector<SceneComponentPayloadRef> ScriptComponentPayloadProvider::components(const TargetId& scene,
248 const ObjectId& object) const {
249 std::vector<SceneComponentPayloadRef> out;
250 if (scene.empty() || object.empty()) return out;
251 scene::Scene* sceneModule = scene::Scene::create();
252 if (sceneModule == nullptr) return out;
253
254 const std::string host = hostNameOf(scene);
255 for (const ScriptComponentInstanceState& state : sceneModule->scriptComponentStatesAt(host, object.value())) {
256 SceneComponentPayloadRef ref;
257 ref.target = scene;
258 ref.object = object;
259 ref.component = StableId(encodeComponentId(object.value(), state.name, state.version.value()));
260 ref.type = payloadType();
261 ref.generation = state.generation.value();
262 ref.revision = scriptComponentStoreRevision();
263 out.push_back(std::move(ref));
264 }
265 return out;
266}
267
269 const SelectionSnapshot& selection) const {
270 auto resolved = resolve(selection);
272 const Resolved& target = resolved.value();
273 operationTarget_.bind(target.target, target.nodeId, target.state.entityId, target.state.name, target.state.version,
274 target.state.generation);
275 return eve::editing::applied<scene_editing::IDomainOperationTarget*>(&operationTarget_);
276}
277
278std::vector<scene_editing::EditorDiagnostic> ScriptComponentPayloadProvider::validateComponent(
279 const SceneComponentPayloadRef& component) const {
280 std::string nodeId;
281 std::string name;
282 std::uint64_t version = 0;
283 if (component.type != payloadType() || !decodeComponentId(component.component.value(), nodeId, name, version))
285 RuleId("editor.scene.script-component.reference"),
286 DiagnosticSeverity::Error, "Script component reference is malformed")};
287
288 scene::Scene* sceneModule = scene::Scene::create();
289 if (sceneModule == nullptr)
291 RuleId("editor.scene.script-component.no-scene"),
292 DiagnosticSeverity::Error, "Scene module is not available")};
293
295 sceneModule->scriptComponentStatesAt(hostNameOf(component.target), nodeId)) {
296 if (state.name != name || state.version.value() != version) continue;
297 if (state.generation.value() != component.generation)
299 eve::DiagnosticCode::Conflict, RuleId("editor.scene.script-component.stale"),
300 DiagnosticSeverity::Error, "Script component generation changed since the reference")};
301 return {};
302 }
303 return {eve::editing::ruleDiagnostic(eve::DiagnosticCode::NotFound, RuleId("editor.scene.script-component.missing"),
304 DiagnosticSeverity::Error, "Script component is no longer on this node")};
305}
306
308 // 脚本组件的字段不在场景文档里,文档版本号对它没有意义;用引擎侧存储的写版本号,
309 // 任何一次写(脚本、原生、恢复)都会让它变,inspector 据此刷新。
311}
312
313PropertySchema ScriptComponentPayloadProvider::schemaOf(const ScriptComponentInstanceState& state) const {
314 PropertySchema out;
316
317 const auto declared = eve::scriptComponentDeclaredSchema(state.name, state.version);
318 // 声明 schema 拿不到(例如登记已经丢了)时,退回当前值那张表:工具至少看得见"有组件、有这些
319 // 数据",而不是一个空面板;这些字段全部只读(没有声明就没有类型可校验)。
320 std::vector<std::string> fallback;
321 const std::vector<std::string>* fields = nullptr;
322 if (declared.ok() && !declared.value().fields.empty()) {
323 fields = &declared.value().fields;
324 } else {
325 fallback.reserve(state.fields.size());
326 for (const auto& [field, value] : state.fields) fallback.push_back(field);
327 fields = &fallback;
328 }
329
330 for (std::size_t index = 0; index < fields->size(); ++index) {
331 const std::string& field = (*fields)[index];
332 const Value* declaredDefault =
333 declared.ok() && index < declared.value().defaults.size() ? &declared.value().defaults[index] : nullptr;
334 const auto current = state.fields.find(field);
335 const bool hasCurrent = current != state.fields.end();
336
337 // 可写 = 脚本里给了非 null 的默认值:那才是类型与默认值的来源。声明成 null 的字段只读,
338 // 但当前值照样显示(类型从当前值取)。
339 const bool writable = declaredDefault != nullptr && declaredDefault->type() != Value::Type::Null;
340 const Value* typeSource = writable ? declaredDefault : (hasCurrent ? &current->second : nullptr);
341
342 PropertyDescriptor descriptor;
343 descriptor.path = PropertyPath(field);
344 descriptor.displayNameKey = field;
345 descriptor.category = state.name;
346 descriptor.type = typeSource != nullptr ? propertyTypeOf(*typeSource) : PropertyType::ReadOnlyText;
348 declaredDefault != nullptr ? *declaredDefault : (hasCurrent ? current->second : Value::null()));
349 if (!writable) descriptor.flags = PropertyFlag::ReadOnly;
350 out.properties.push_back(std::move(descriptor));
351 }
352 return out;
353}
354
355PropertySchema ScriptComponentPayloadProvider::schema(const SelectionSnapshot& selection) const {
356 PropertySchema out;
358 auto resolved = resolve(selection);
359 if (!resolved.ok()) return out;
360 return schemaOf(resolved.value().state);
361}
362
363PropertyReadResult ScriptComponentPayloadProvider::read(const SelectionSnapshot& selection,
364 const PropertyPath& path) const {
365 auto resolved = resolve(selection);
366 if (!resolved.ok()) return {PropertyReadState::Missing, {}, {}};
367 const auto found = resolved.value().state.fields.find(path.value());
368 if (found == resolved.value().state.fields.end()) return {PropertyReadState::Missing, {}, {}};
369 return {PropertyReadState::Value, eve::editing::toEditingValue(found->second), {}};
370}
371
372Result<DomainOperation> ScriptComponentPayloadProvider::planWrite(const Resolved& target, const PropertyPath& path,
373 const EditorValue& value) const {
374 const auto current = target.state.fields.find(path.value());
375 const EditorValue previous =
376 current != target.state.fields.end() ? eve::editing::toEditingValue(current->second) : EditorValue{};
377
378 DomainOperation operation;
380 operation.inverseType = operation.type;
381 operation.target = target.target;
382 // 载荷里带着组件身份:过期的操作目标据此拒绝写错组件;撤销用的反向值也一起进去。
383 operation.payload = EditorValue::Object{
384 {"node", EditorValue(target.nodeId)},
385 {"name", EditorValue(target.state.name)},
386 {"version", EditorValue(static_cast<std::int64_t>(target.state.version.value()))},
387 {"field", EditorValue(path.value())},
388 {"value", value},
389 };
390 operation.inverse = EditorValue::Object{
391 {"node", EditorValue(target.nodeId)},
392 {"name", EditorValue(target.state.name)},
393 {"version", EditorValue(static_cast<std::int64_t>(target.state.version.value()))},
394 {"field", EditorValue(path.value())},
395 {"value", previous},
396 };
397 operation.hasInverse = true;
398 operation.affectedObjects.push_back({target.target, target.nodeId, target.state.generation.value()});
399 operation.affectedProperties.push_back(path.value());
400 operation.mergeKey = "script-component:" + target.nodeId + ":" + target.state.name + "@" +
401 std::to_string(target.state.version.value()) + ":" + path.value();
402 return eve::editing::applied<DomainOperation>(std::move(operation));
403}
404
406 const PropertyPath& path, const EditorValue& value,
407 PropertySetMode mode) const {
408 if (mode == PropertySetMode::Reset) return makeReset(selection, path);
409 if (mode != PropertySetMode::Absolute)
410 return editRefusal<DomainOperation>(EditorStatus::Rejected, "editor.scene.script-component.mode",
411 "script component fields accept absolute edits only");
412
413 auto resolved = resolve(selection);
414 if (!resolved.ok()) return Result<DomainOperation>::failure(resolved.status());
415 const Resolved& target = resolved.value();
416
417 const auto descriptor = schemaOf(target.state).find(path);
418 if (!descriptor)
419 return editRefusal<DomainOperation>(EditorStatus::NotFound, "editor.scene.script-component.field",
420 "script component has no declared field: " + path.value());
421 if (hasPropertyFlag(descriptor->flags, PropertyFlag::ReadOnly))
422 return editRefusal<DomainOperation>(
423 EditorStatus::Rejected, "editor.scene.script-component.untyped",
424 "field has no declared non-null default, so its type is unknown and it stays read-only: " + path.value());
425 const auto validation = validatePropertyValue(*descriptor, value);
426 if (!validation.ok()) return Result<DomainOperation>::failure(validation.status());
427 return planWrite(target, path, value);
428}
429
431 const PropertyPath& path) const {
432 auto resolved = resolve(selection);
433 if (!resolved.ok()) return Result<DomainOperation>::failure(resolved.status());
434 const Resolved& target = resolved.value();
435
436 const auto descriptor = schemaOf(target.state).find(path);
437 if (!descriptor)
438 return editRefusal<DomainOperation>(EditorStatus::NotFound, "editor.scene.script-component.field",
439 "script component has no declared field: " + path.value());
440 if (hasPropertyFlag(descriptor->flags, PropertyFlag::ReadOnly))
441 return editRefusal<DomainOperation>(EditorStatus::Rejected, "editor.scene.script-component.untyped",
442 "field has no declared non-null default to reset to: " + path.value());
443 return planWrite(target, path, descriptor->defaultValue);
444}
445
446eve::Result<ScriptComponentPayloadProvider::Resolved> ScriptComponentPayloadProvider::resolve(
447 const SelectionSnapshot& selection) const {
448 const auto failure = [](eve::DiagnosticCode code, std::string message, std::string path) {
450 eve::Diagnostic::error(code, std::move(message), std::move(path), {}, "scene.script-component"));
451 };
452
453 if (selection.items.size() != 1)
455 "script component properties are edited one component at a time", "selection");
456 const scene_editing::SelectionItem& item = selection.items.front();
457 if (item.type != payloadType())
459 "selection does not belong to the script component provider", item.type);
460
461 std::string nodeId;
462 std::string name;
463 std::uint64_t version = 0;
464 if (!decodeComponentId(item.item.value(), nodeId, name, version))
465 return failure(eve::DiagnosticCode::InvalidArgument, "script component reference is malformed",
466 item.item.value());
467
468 scene::Scene* sceneModule = scene::Scene::create();
469 if (sceneModule == nullptr)
470 return failure(eve::DiagnosticCode::Failed, "scene module is not available", item.target.value());
471
472 for (const ScriptComponentInstanceState& state :
473 sceneModule->scriptComponentStatesAt(hostNameOf(item.target), nodeId)) {
474 if (state.name != name || state.version.value() != version) continue;
475 return eve::Result<Resolved>::success(Resolved{item.target, nodeId, state});
476 }
477 return failure(eve::DiagnosticCode::NotFound, "script component is no longer on this node", item.item.value());
478}
479
480} // namespace eve::scene_editor
LogicalId target
ActionParameterOperation operation
Value::Object payload
std::string descriptor
std::string nodeId
Generation generation
Definition ECS.cpp:40
std::string name
Definition ECS.cpp:154
std::vector< std::string > fields
Definition ECS.cpp:42
std::vector< std::uint8_t > stored
Definition Evpack.cpp:171
std::string message
DiagnosticCode code
wgpu::PopErrorScopeStatus status
std::int32_t second
std::shared_ptr< const OceanSprayFrame > previous
std::string path
Definition PlayHost.cpp:111
std::weak_ptr< PrimitiveScene > scene
Object::Ptr value
RoadNetwork resolved
const RoadNode * node
double number
bool found
让编辑器 inspector 读写脚本组件的字段(J-3 编辑器通路)。
脚本组件数据的持久化信封(方案文档实施顺序第 4 步 / J-3 的存档通路)。
脚本组件字段的引擎侧权威存储。
std::string text
ScriptStructure out
double current
Json object
UIHostHandle host
uint32_t index
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
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
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
std::map< std::string, Value > Object
Definition Value.h:34
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:209
static Value object(Object value)
Compatibility factory for an object value.
Definition Value.cpp:129
constexpr std::uint64_t value() const noexcept
Returns the underlying value at an explicit protocol boundary.
const T * getIf() const
Return an immediately borrowed typed value.
Declarative scene module (eve.Scene).
Definition Scene.h:52
std::vector< ScriptComponentInstanceState > scriptComponentStatesAt(const std::string &hostName, const std::string &nodeId) const
一个节点上所有脚本实体的**已登记**组件状态(编辑器/工具面)。
Definition Scene.cpp:1006
脚本组件字段的域操作目标:往引擎侧存储写字段的**唯一**通路。
eve::Result< void > applyDomainOperation(const scene_editing::DomainOperation &operation) override
Apply one validated domain operation.
eve::Result< void > commitDomainState(std::unique_ptr< scene_editing::IDomainOperationTarget > candidate) override
static std::string_view setOperationType()
域操作类型:一个脚本组件字段的绝对赋值。
std::unique_ptr< scene_editing::IDomainOperationTarget > cloneDomainState() const override
Clone the complete target state into an owning detached candidate.
void bind(const scene_editing::TargetId &target, std::string nodeId, std::uint64_t entityId, std::string name, eve::SchemaVersion version, eve::Generation generation)
绑定到一个组件实例(编辑器每次解析选中项时重新绑定)。
eve::Result< eve::Revision > currentRevision(const scene_editing::SelectionSnapshot &selection) const override
引擎侧存储的写版本号(任何一次写都会让它变),供 inspector 判断要不要刷新。
std::vector< scene_editing::EditorDiagnostic > validateComponent(const scene_editing::SceneComponentPayloadRef &component) const override
引用还在不在:组件名+版本还登记着、且实例上仍挂着它。
eve::Result< scene_editing::DomainOperation > makeSet(const scene_editing::SelectionSnapshot &selection, const scene_editing::PropertyPath &path, const scene_editing::EditorValue &value, scene_editing::PropertySetMode mode) const override
计划一次字段写入(Reset 模式转给 makeReset)。
std::function< std::string(const scene_editing::TargetId &)> HostResolver
编辑器目标 id → 场景**宿主名**。
scene_editing::PropertySchema schema(const scene_editing::SelectionSnapshot &selection) const override
选中组件的字段表:类型与默认值来自声明 schema,当前值只在声明值为空时兜底。
eve::Result< scene_editing::DomainOperation > makeReset(const scene_editing::SelectionSnapshot &selection, const scene_editing::PropertyPath &path) const override
计划一次"恢复声明默认值";默认值来自注册表的声明 schema,不是当前值。
static const std::string & payloadType()
稳定组件类型槽:所有脚本组件共用。
eve::Result< scene_editing::IDomainOperationTarget * > payloadOperationTarget(const scene_editing::SelectionSnapshot &selection) const override
选中组件的域操作目标(写回的唯一入口)。
std::vector< scene_editing::SceneComponentPayloadRef > components(const scene_editing::TargetId &scene, const scene_editing::ObjectId &object) const override
节点上每个脚本实体实例的**已登记**组件各一条;未登记组件不出现(§9.62.1)。
const std::string & componentType() const override
Stable component type handled by this provider.
scene_editing::PropertyReadResult read(const scene_editing::SelectionSnapshot &selection, const scene_editing::PropertyPath &path) const override
读一个字段:值来自引擎侧存储,不是脚本实例的槽位。
eve::Severity DiagnosticSeverity
eve::Value toPresentationValue(const Value &value)
To presentation value.
StrongId< TargetIdTag > TargetId
Definition EditingIds.h:57
StrongId< ObjectIdTag > ObjectId
Definition EditingIds.h:65
PropertyType
PropertyType public API.
StrongId< StableIdTag > StableId
Definition EditingIds.h:64
StrongId< RuleIdTag > RuleId
Definition EditingIds.h:60
PropertySetMode
PropertySetMode public API.
PropertyFlag
PropertyFlag public API.
Value toEditingValue(const eve::Value &value)
To editing value.
Diagnostic ruleDiagnostic(eve::DiagnosticCode code, RuleId rule, DiagnosticSeverity severity, std::string message)
Build an owning common diagnostic carrying an open editing rule identity.
PropertyReadState
PropertyReadState public API.
DiagnosticCode
Stable machine-readable diagnostic codes.
Definition Diagnostic.h:47
const Value * findScriptComponentValues(const ScriptComponentStoreKey &key)
读一条组件数据。
Result< ScriptComponentDeclaredSchema > scriptComponentDeclaredSchema(const std::string &name, SchemaVersion version)
读一条已登记组件的声明 schema(字段名 + 声明默认值)。
Definition ECS.cpp:1573
Result< void > setScriptComponentValues(const ScriptComponentStoreKey &key, Value values)
写入一条组件的引擎侧数据(创建实体、或迁移到新代时调用)。
std::uint64_t scriptComponentStoreRevision()
存储的单调版本号:任何一次写(含恢复、换代对齐、实体销毁)都会 +1。
Result< void > setScriptComponentField(const ScriptComponentStoreKey &key, const std::string &field, Value value)
写一个字段(脚本侧的写入与原生侧的写入都走这里)。
一个脚本实体实例上某个组件的**当前状态**(供引擎工具读取)。
一条脚本组件数据的键:实体 + 组件名 + 版本。
PropertyDescriptorLookup find(const PropertyPath &path) const
Finds find.