void EntitySimulation::addEntity(EntityItem* entity) {
    assert(entity);
    if (entity->isMortal()) {
        _mortalEntities.insert(entity);
        quint64 expiry = entity->getExpiry();
        if (expiry < _nextExpiry) {
            _nextExpiry = expiry;
        }
    }
    if (entity->needsToCallUpdate()) {
        _updateableEntities.insert(entity);
    }
    addEntityInternal(entity);

    // DirtyFlags are used to signal changes to entities that have already been added, 
    // so we can clear them for this entity which has just been added.
    entity->clearDirtyFlags();
}
void EntityEngine::processPendingEntityOperations()
{
    for (auto entityOperation : entityOperations)
    {
        auto entity = entityOperation->entity;
        
        switch (entityOperation->type)
        {
            case EntityOperation::ADD:
                addEntityInternal(entity);
                updateFamilyMembership(entity);
                break;

            case EntityOperation::REMOVE:
                removeEntityInternal(entity);
                updateFamilyMembership(entity, true);
                break;
        }
    }

    entityOperations.clear();
}
Exemple #3
0
void EntitySimulation::addEntity(EntityItemPointer entity) {
    QMutexLocker lock(&_mutex);
    assert(entity);
    entity->deserializeActions();
    if (entity->isMortal()) {
        _mortalEntities.insert(entity);
        quint64 expiry = entity->getExpiry();
        if (expiry < _nextExpiry) {
            _nextExpiry = expiry;
        }
    }
    if (entity->needsToCallUpdate()) {
        _entitiesToUpdate.insert(entity);
    }
    addEntityInternal(entity);

    _allEntities.insert(entity);
    entity->setSimulated(true);

    // DirtyFlags are used to signal changes to entities that have already been added,
    // so we can clear them for this entity which has just been added.
    entity->clearDirtyFlags();
}