コード例 #1
0
ファイル: ECBrowser.cpp プロジェクト: katik/naali
void ECBrowser::RemoveEntity(EntityPtr entity)
{
    if (!entity)
        return;

    for(EntityWeakPtrList::iterator iter = entities_.begin(); iter != entities_.end(); ++iter)
        if (iter->lock() == entity)
        {
            EntityPtr ent_ptr = iter->lock();

            disconnect(entity.get(), SIGNAL(ComponentAdded(IComponent*, AttributeChange::Type)), this,
                SLOT(OnComponentAdded(IComponent*, AttributeChange::Type)));
            disconnect(entity.get(), SIGNAL(ComponentRemoved(IComponent*, AttributeChange::Type)), this,
                SLOT(OnComponentRemoved(IComponent*, AttributeChange::Type)));

            const Entity::ComponentMap components = ent_ptr->Components();
            for (Entity::ComponentMap::const_iterator i = components.begin(); i != components.end(); ++i)
                RemoveComponentFromGroup(i->second);

            entities_.erase(iter);
            break;
        }
コード例 #2
0
ファイル: ECBrowser.cpp プロジェクト: 360degrees-fi/tundra
void ECBrowser::RemoveEntity(const EntityPtr &entity)
{
    if (!entity)
        return;

    EntityMap::iterator iter = entities_.find(entity->Id());
    if (iter != entities_.end())
    {
        Entity *entity = iter->second.lock().get();
        if (entity)
        {
            disconnect(entity, SIGNAL(ComponentAdded(IComponent*, AttributeChange::Type)), this,
                SLOT(OnComponentAdded(IComponent*, AttributeChange::Type)));
            disconnect(entity, SIGNAL(ComponentRemoved(IComponent*, AttributeChange::Type)), this,
                SLOT(OnComponentRemoved(IComponent*, AttributeChange::Type)));

            const Entity::ComponentMap components = entity->Components();
            for (Entity::ComponentMap::const_iterator i = components.begin(); i != components.end(); ++i)
                RemoveComponentFromGroup(i->second);
        }

        entities_.erase(iter);
    }