mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-04 22:10:34 +03:00
Now instancing prefab from trenchbroom correctly
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace Nuake
|
||||
|
||||
FGDPointEntity pointEntity = FGDPointEntity(name);
|
||||
pointEntity.Description = "A Prefab entity";
|
||||
|
||||
pointEntity.Prefab = p->GetRelativePath();
|
||||
file->PointEntities.push_back(pointEntity);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user