Created EntityFile which loads an EntityXMLFile into a temporary world to be merged with another world when you want to create a copy of the entity loaded from disk. This allows us to free EntityXMLFile once it's loaded into an EntityFile.

This commit is contained in:
2016-03-02 19:52:11 +01:00
parent 44b4a597d4
commit 069583e09f
3 changed files with 46 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
#include "Core/EntityFile.h"
EntityFile::EntityFile(std::string path)
{
EntityXMLFile* xml = ResourceManager::Load<EntityXMLFile>(path);
EntityXMLFilePreprocessor preprocessor(xml);
preprocessor.RegisterComponents(this);
EntityXMLFileParser parser(xml);
m_RootEntity = parser.MergeEntities(this);
if (m_RootEntity == EntityID_Invalid) {
throw Resource::FailedLoadingException("Failed to merge entities; root entity is invalid");
}
}
EntityWrapper EntityFile::MergeInto(World* other)
{
auto mapping = other->Merge(this);
return EntityWrapper(other, mapping.at(m_RootEntity));
}