载入中...
搜索中...
未找到
ScriptComponentStore.h
浏览该文件的文档.
1#pragma once
2
5#include "common/Export.h"
6#include "common/Result.h"
8#include "common/Value.h"
9
10#include <cstddef>
11#include <cstdint>
12#include <string>
13#include <vector>
14
15namespace eve {
16
24 std::uint64_t entityId = 0;
26 std::string name;
29
30 friend bool operator<(const ScriptComponentStoreKey& a, const ScriptComponentStoreKey& b) noexcept {
31 if (a.entityId != b.entityId) return a.entityId < b.entityId;
32 if (a.name != b.name) return a.name < b.name;
33 return a.version < b.version;
34 }
35};
36
46[[nodiscard]] EVENGINE_API_FOUNDATION Result<void> setScriptComponentValues(const ScriptComponentStoreKey& key,
47 Value values);
48
56[[nodiscard]] EVENGINE_API_FOUNDATION const Value* findScriptComponentValues(const ScriptComponentStoreKey& key);
57
62[[nodiscard]] EVENGINE_API_FOUNDATION Result<Value> scriptComponentField(const ScriptComponentStoreKey& key,
63 const std::string& field);
64
71[[nodiscard]] EVENGINE_API_FOUNDATION Result<void> setScriptComponentField(const ScriptComponentStoreKey& key,
72 const std::string& field, Value value);
73
83
89[[nodiscard]] EVENGINE_API_FOUNDATION std::vector<ScriptComponentStoreEntry> scriptComponentStoreEntries();
90
97EVENGINE_API_FOUNDATION void replaceScriptComponentValues(std::vector<ScriptComponentStoreEntry> entries);
98
113 const std::vector<std::string>& fields,
114 const std::vector<Value>& defaults);
115
120EVENGINE_API_FOUNDATION std::size_t removeScriptComponentValues(std::uint64_t entityId);
121
124
126[[nodiscard]] EVENGINE_API_FOUNDATION std::size_t scriptComponentStoreSize();
127
137[[nodiscard]] EVENGINE_API_FOUNDATION std::uint64_t scriptComponentStoreRevision();
138
139} // namespace eve
std::unordered_map< std::string, QuestRuntime > entries
std::vector< Value > defaults
Definition ECS.cpp:49
SQObjectPtr key
Definition ECS.cpp:155
std::string name
Definition ECS.cpp:154
std::vector< std::string > fields
Definition ECS.cpp:42
#define EVENGINE_API_FOUNDATION_INLINE
仅供"只有内联成员"的类型使用的组宏:拥有者 dllexport,消费方不导入。
Definition Export.h:170
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
std::set< std::string > values
Object::Ptr value
Move-only, checked operation results for the common layer.
Persistent data-contract version identity.
Owning, renderer-independent dynamic values.
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
std::size_t removeScriptComponentValues(std::uint64_t entityId)
实体销毁时清掉它的全部组件数据。
std::size_t scriptComponentStoreSize()
当前数据条数(诊断与测试用)。
const Value * findScriptComponentValues(const ScriptComponentStoreKey &key)
读一条组件数据。
void replaceScriptComponentValues(std::vector< ScriptComponentStoreEntry > entries)
用给定条目**整体替换**存储(恢复快照用)。
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)
写一个字段(脚本侧的写入与原生侧的写入都走这里)。
void clearScriptComponentStore()
换 VM 时清空:脚本世界连同它的组件数据一起消失。
std::vector< ScriptComponentStoreEntry > scriptComponentStoreEntries()
列出存储里的全部条目,按 (实体, 组件名, 版本) 升序。
void reconcileScriptComponentValues(const std::string &name, SchemaVersion version, const std::vector< std::string > &fields, const std::vector< Value > &defaults)
把某个组件(名字 + 版本)在**所有实体**上的数据重建到新 schema 上(热重载换代)。
Result< Value > scriptComponentField(const ScriptComponentStoreKey &key, const std::string &field)
读一个字段。
存储里的一条数据:键 + 一份字段对象。
Value values
字段名 → 值(必须是 Object)。
一条脚本组件数据的键:实体 + 组件名 + 版本。
std::string name
脚本侧声明的组件名。
friend bool operator<(const ScriptComponentStoreKey &a, const ScriptComponentStoreKey &b) noexcept
SchemaVersion version
脚本侧声明的版本。