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:
@@ -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));
|
||||
}
|
||||
Reference in New Issue
Block a user