Exemplo n.º 1
0
 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
     }
 }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 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()));
         }
     }
 }
Exemplo n.º 4
0
    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()));
            }
        }
    }