Example #1
0
QList<NPC*> GameLoader::loadNpcs(const QDomElement& element)
{
	QList<NPC*> npcs;
	QString source = element.attribute("source");
	if (!source.isNull())
	{
		QDomDocument document = load(path()+"/"+source);
		npcs = loadNpcs(document.documentElement());
		_paths.pop();
		return npcs;
	}

	QDomNodeList children = element.childNodes();
	for (int i=0; i<children.size(); ++i)
	{
		QDomElement child = children.at(i).toElement();
		if (child.tagName()=="npc")
		{
			NPC* npc = new NPC();
			npc->setName(child.attribute("name"));
			initializeObject(child, npc);
			npcs << npc;
		}
	}

	return npcs;
}