Ejemplo n.º 1
0
CEntity* CEntitySystem::CreateEntity( EntityType entityType )
{
	if(_CheckTypeValid(entityType))
	{
		//the ref will be 1,will not auto release
		CEntity* pEntity = m_allCreateFuncs[entityType]();
		if(pEntity && _AddEntity(pEntity) && pEntity->init())  //init ID and add the entity to manager
		{
			return pEntity;
		}
		else
		{
			pEntity->release();
		}
	}
	return nullptr;
}