Search in sources :

Example 1 with SectorSimulationComponent

use of org.terasology.engine.entitySystem.sectors.SectorSimulationComponent in project Terasology by MovingBlocks.

the class BaseEntityRef method setScope.

@Override
public void setScope(EntityScope scope) {
    if (exists()) {
        EntityInfoComponent info = getEntityInfo();
        if (!info.scope.equals(scope)) {
            EngineEntityPool newPool;
            switch(scope) {
                case GLOBAL:
                case CHUNK:
                    newPool = entityManager.getGlobalPool();
                    removeComponent(SectorSimulationComponent.class);
                    break;
                case SECTOR:
                    newPool = entityManager.getSectorManager();
                    if (!hasComponent(SectorSimulationComponent.class)) {
                        addComponent(new SectorSimulationComponent());
                    }
                    break;
                default:
                    logger.error("Unrecognised scope {}.", scope);
                    return;
            }
            entityManager.moveToPool(getId(), newPool);
            info.scope = scope;
            saveComponent(info);
        }
    }
}
Also used : SectorSimulationComponent(org.terasology.engine.entitySystem.sectors.SectorSimulationComponent)

Example 2 with SectorSimulationComponent

use of org.terasology.engine.entitySystem.sectors.SectorSimulationComponent in project Terasology by MovingBlocks.

the class BaseEntityRef method setSectorScope.

@Override
public void setSectorScope(long unloadedMaxDelta, long loadedMaxDelta) {
    setScope(SECTOR);
    SectorSimulationComponent simulationComponent = getComponent(SectorSimulationComponent.class);
    simulationComponent.unloadedMaxDelta = unloadedMaxDelta;
    simulationComponent.loadedMaxDelta = loadedMaxDelta;
    saveComponent(simulationComponent);
}
Also used : SectorSimulationComponent(org.terasology.engine.entitySystem.sectors.SectorSimulationComponent)

Example 3 with SectorSimulationComponent

use of org.terasology.engine.entitySystem.sectors.SectorSimulationComponent in project Terasology by MovingBlocks.

the class PojoEntityManager method createSectorEntity.

@Override
public EntityRef createSectorEntity(long unloadedMaxDelta, long loadedMaxDelta) {
    EntityRef entity = sectorManager.create();
    entity.setScope(SECTOR);
    SectorSimulationComponent simulationComponent = entity.getComponent(SectorSimulationComponent.class);
    simulationComponent.unloadedMaxDelta = unloadedMaxDelta;
    simulationComponent.loadedMaxDelta = loadedMaxDelta;
    entity.saveComponent(simulationComponent);
    return entity;
}
Also used : SectorSimulationComponent(org.terasology.engine.entitySystem.sectors.SectorSimulationComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Aggregations

SectorSimulationComponent (org.terasology.engine.entitySystem.sectors.SectorSimulationComponent)3 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1