示例#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()));
            }
        }
    }