Now instancing prefab from trenchbroom correctly

This commit is contained in:
antopilo
2024-12-01 13:49:06 -05:00
parent 5b4d6d915a
commit 82459a6e4c
3 changed files with 16 additions and 15 deletions

View File

@@ -69,7 +69,7 @@ std::vector<Ref<File>> FileSystem::GetAllFiles(const FileType fileType)
std::vector<Ref<File>> foundFiles;
std::function<void(Ref<Directory>)> scanDir;
scanDir = [scanDir, &foundFiles, fileType](Ref<Directory> dir)
scanDir = [&scanDir, &foundFiles, &fileType](Ref<Directory> dir)
{
// All the files matching the filetype
for (auto& f : dir->Files)

View File

@@ -224,7 +224,7 @@ namespace Nuake
FGDPointEntity pointEntity = FGDPointEntity(name);
pointEntity.Description = "A Prefab entity";
pointEntity.Prefab = p->GetRelativePath();
file->PointEntities.push_back(pointEntity);
}

View File

@@ -211,22 +211,23 @@ namespace Nuake {
}
}
}
else
else if(!pointEntity->Prefab.empty())
{
Entity newPrefab = Engine::GetCurrentScene()->CreateEntity(pointEntity->Name);
pointEntities[pointEntity->Name].AddChild(newPrefab);
auto& prefabComponent = currentNonWorldEntity.AddComponent<PrefabComponent>();
Ref<Prefab> prefab = Prefab::InstanceInScene(pointEntity->Prefab, m_Scene);
auto& prefabComponent = newPrefab.AddComponent<PrefabComponent>();
prefabComponent.SetPrefab(Prefab::New(pointEntity->Prefab));
newPrefab.GetComponent<TransformComponent>().SetLocalPosition(brushLocalPosition);
prefabComponent.SetPrefab(prefab);
prefabComponent.isInitialized = true;
currentNonWorldEntity.AddChild(prefabComponent.PrefabInstance->Root);
currentNonWorldEntity.GetComponent<TransformComponent>().SetLocalPosition(brushLocalPosition);
for (auto& e : prefabComponent.PrefabInstance->Entities)
{
if (!e.GetComponent<ParentComponent>().HasParent)
{
newPrefab.AddChild(e);
}
}
//for (auto& e : prefabComponent.PrefabInstance->Entities)
//{
// if (!e.GetComponent<ParentComponent>().HasParent)
// {
// newPrefab.AddChild(e);
// }
//}
}
}
else