Clock::Clock(const std::string& name, Clock* parent) : m_name(name), m_id(GetStringID(name)), m_parent(parent) { // if (m_parent) { // AddChild(m_parent); // } m_timers.clear(); }
///===================================================== /// ///===================================================== bool NPCFactory::LoadAllNPCFactories(OpenGLRenderer* renderer){ std::vector<std::string> factories; bool foundFiles = FindAllFilesOfType("Data/NPCs/", "*.npc.xml", factories); RECOVERABLE_ASSERT(foundFiles == true); for (std::vector<std::string>::const_iterator factoryIter = factories.cbegin(); factoryIter != factories.cend(); ++factoryIter){ XMLNode npcNode = XMLNode::parseFile(factoryIter->c_str(), "NPC"); NPCFactory* newFactory = new NPCFactory(npcNode, renderer); s_factories.emplace(GetStringID(newFactory->m_npcBlueprint->m_name), newFactory); } return foundFiles; }
Clock* Clock::GetChild(const std::string& name){ Clock* outClock = NULL; if (m_children.size() > 0){ for (ClocksIterator it = m_children.begin(); it != m_children.end(); ++it){ Clock* clock = (*it); if (clock->m_id == GetStringID(name)){ outClock = clock; break; } }//end of for } return outClock; }
///===================================================== /// ///===================================================== NPCFactory* NPCFactory::FindFactoryByName(const std::string& name){ NPCFactoryRegistry::iterator factoryIter = s_factories.find(GetStringID(name)); if (factoryIter == s_factories.end()) return nullptr; return factoryIter->second; }