use of org.terasology.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);
}
use of org.terasology.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);
}
}
}
use of org.terasology.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;
}
Aggregations