feat: 实体出生即挂 TransformComponent(UUID + Transform 固有化)

- CreateEntity 自动挂 IdComponent(已有)+ TransformComponent(identity),
  对齐 UE/Unity 语义(GameObject↔Transform 不可分离 / AActor 必有
  RootComponent)——游戏实体的本质是"空间中存在的东西"
- 调用点 AddComponent<Transform> 改 GetComponent(重复 emplace 会断言)
- 遗留不一致记录在案:CameraComponent 位置存于 Camera 内部而非
  Transform,后续统一
This commit is contained in:
2026-09-23 15:07:00 +08:00
parent 0ed7b4c5b8
commit 019c17c7e7
2 changed files with 9 additions and 4 deletions
+2 -1
View File
@@ -11,8 +11,9 @@ namespace Engine::ECS {
EntityHandle Scene::CreateEntity(std::string name)
{
Entity e = m_Registry.create();
// IdComponent 自动挂载:每个实体出生即有稳定 UUID
// 出生即有:UUID(稳定身份)+ Transform(空间存在性,Unity 语义)
m_Registry.emplace<IdComponent>(e, IdComponent{UUID::New()});
m_Registry.emplace<TransformComponent>(e);
if (!name.empty()) {
m_Registry.emplace<NameComponent>(e, NameComponent{std::move(name)});
}