Entity 0 is now a real entity in the world, created by the first entity read while importing. This makes the difference between map files and entity files automatic, since consecutive entity file loads should automatically get the world as parent, as long as the world entity has been created earlier.

This commit is contained in:
2016-01-08 12:42:32 +01:00
parent 24b9e951c2
commit 11d547cde8
6 changed files with 19 additions and 8 deletions
+9 -2
View File
@@ -3,6 +3,11 @@
#define X(str) XS::ToXMLCh(str)
void EntityFileWriter::WriteWorld(World* world)
{
WriteEntity(world, 0);
}
void EntityFileWriter::WriteEntity(World* world, EntityID entity)
{
using namespace xercesc;
DOMDocument* doc = m_DOMImplementation->createDocument(nullptr, X("Entity"), nullptr);
@@ -13,16 +18,18 @@ void EntityFileWriter::WriteWorld(World* world)
DOMElement* componentsElement = doc->createElement(X("Components"));
root->appendChild(componentsElement);
appentEntityComponents(componentsElement, world, 0);
appentEntityComponents(componentsElement, world, entity);
DOMElement* childrenElement = doc->createElement(X("Children"));
root->appendChild(childrenElement);
appendEntityChildren(childrenElement, world, 0);
appendEntityChildren(childrenElement, world, entity);
XMLFormatTarget* target = new StdOutFormatTarget();
DOMLSOutput* output = static_cast<DOMImplementationLS*>(m_DOMImplementation)->createLSOutput();
output->setByteStream(target);
m_DOMLSSerializer->write(doc, output);
doc->release();
}
void EntityFileWriter::appendEntityChildren(xercesc::DOMElement* parentElement, const World* world, EntityID entity)