本文整理汇总了C++中EntityManager::HasEntitySystem方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::HasEntitySystem方法的具体用法?C++ EntityManager::HasEntitySystem怎么用?C++ EntityManager::HasEntitySystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::HasEntitySystem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnloadAllPlugins
void ComponentPluginManager::UnloadAllPlugins(EntityManager& em)
{
for(PluginFactoryMap::iterator i = mFactories.begin(); i != mFactories.end(); ++i)
{
ComponentType ctype = i->first;
if(em.HasEntitySystem(ctype))
{
dtEntity::EntitySystem* es = em.GetEntitySystem(ctype);
if(es == NULL || !em.RemoveEntitySystem(*es))
{
LOG_ERROR("Could not cleanly remove entity system " << GetStringFromSID(ctype));
}
else
{
delete es;
}
}
}
}
示例2: StartEntitySystem
bool ComponentPluginManager::StartEntitySystem(EntityManager& em, ComponentType ctype)
{
if(em.HasEntitySystem(ctype))
{
return true;
}
LOG_DEBUG("Starting entity system " << GetStringFromSID(ctype));
ComponentPluginFactory* factory = GetPluginFactory(ctype);
if(factory == NULL)
{
LOG_DEBUG("Cannot start entity system "
<< dtEntity::GetStringFromSID(ctype) << ": no factory found");
return false;
}
// start all plugins this plugin depends on
std::list<ComponentType> deps;
factory->GetDependencies(deps);
while(!deps.empty())
{
ComponentType dependency = deps.front();
deps.pop_front();
if(em.HasEntitySystem(dependency))
{
continue;
}
// check if dependency can be fulfilled
if(!FactoryExists(dependency))
{
LOG_ERROR("Cannot start plugin " << dtEntity::GetStringFromSID(ctype) << ": It depends on plugin "
<< GetStringFromSID(dependency) << " which was not found.");
return false;
}
// only start dependency if it is not running now
if(!em.HasEntitySystem(dependency))
{
StartEntitySystem(em, dependency);
}
}
// use factory to create the plugin
EntitySystem* es;
bool success = factory->Create(&em, es);
if(success)
{
// call, although no properties were set yet
es->Finished();
LOG_DEBUG("Created entity system of type " << GetStringFromSID(ctype));
em.AddEntitySystem(*es);
return true;
}
else
{
LOG_ERROR("Error starting entity system " << dtEntity::GetStringFromSID(ctype));
return false;
}
}