Exemplo n.º 1
0
uint Entity::RemoveComponents(u32 typeId, AttributeChange::Type change)
{
    Vector<component_id_t> removeIds;
    for(ComponentMap::ConstIterator it = components_.Begin(); it != components_.End(); ++it)
        if (it->second_->TypeId() == typeId)
            removeIds.Push(it->first_);

    foreach(component_id_t id, removeIds)
        RemoveComponentById(id, change);

    return removeIds.Size();
}
Exemplo n.º 2
0
void Entity::ChangeComponentId(component_id_t old_id, component_id_t new_id)
{
    if (old_id == new_id)
        return;
    
    ComponentPtr old_comp = ComponentById(old_id);
    if (!old_comp)
        return;
    
    if (ComponentById(new_id))
    {
        LogWarning("Purged component " + QString::number(new_id) + " to make room for a ChangeComponentId request. This should not happen.");
        RemoveComponentById(new_id, AttributeChange::LocalOnly);
    }
    
    old_comp->SetNewId(new_id);
    components_.erase(old_id);
    components_[new_id] = old_comp;
}