예제 #1
0
파일: Entity.cpp 프로젝트: caocao/naali
 void Entity::AddComponent(const Foundation::ComponentInterfacePtr &component)
 {
     // Must exist and be free
     if (component && component->GetParentEntity() == 0)
     {
         component->SetParentEntity(this);
         components_.push_back(component);
     
         ///\todo Ali: send event
     }
 }
예제 #2
0
파일: Entity.cpp 프로젝트: Chiru/naali
 void Entity::AddComponent(const Foundation::ComponentInterfacePtr &component, AttributeChange::Type change)
 {
     // Must exist and be free
     if (component && component->GetParentEntity() == 0)
     {
         component->SetParentEntity(this);
         components_.push_back(component);
     
         if (scene_)
             scene_->EmitComponentAdded(this, component.get(), change);
     }
 }
예제 #3
0
파일: Entity.cpp 프로젝트: caocao/naali
 void Entity::RemoveComponent(const Foundation::ComponentInterfacePtr &component)
 {
     if (component)
     {
         ComponentVector::iterator iter = std::find(components_.begin(), components_.end(), component);
         if (iter != components_.end())
         {
             (*iter)->SetParentEntity(0);
             components_.erase(iter);
             ///\todo Ali: send event
         } else
         {
             Foundation::RootLogWarning("Failed to remove component: " + component->Name() + " from entity: " + ToString(GetId()));
         }
     }
 }
예제 #4
0
파일: Entity.cpp 프로젝트: Chiru/naali
    void Entity::RemoveComponent(const Foundation::ComponentInterfacePtr &component, AttributeChange::Type change)
    {
        if (component)
        {
            ComponentVector::iterator iter = std::find(components_.begin(), components_.end(), component);
            if (iter != components_.end())
            {
                if (scene_)
                    scene_->EmitComponentRemoved(this, (*iter).get(), change);

                (*iter)->SetParentEntity(0);
                components_.erase(iter);
            }
            else
            {
                LogWarning("Failed to remove component: " + component->TypeName().toStdString() + " from entity: " + ToString(GetId()));
            }
        }
    }