use of org.terasology.engine.Time in project Terasology by MovingBlocks.
the class ReadWriteStorageManager method addGameManifestToSaveTransaction.
private void addGameManifestToSaveTransaction(SaveTransactionBuilder saveTransactionBuilder) {
BlockManager blockManager = CoreRegistry.get(BlockManager.class);
BiomeManager biomeManager = CoreRegistry.get(BiomeManager.class);
WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
Time time = CoreRegistry.get(Time.class);
Game game = CoreRegistry.get(Game.class);
GameManifest gameManifest = new GameManifest(game.getName(), game.getSeed(), time.getGameTimeInMs());
for (Module module : CoreRegistry.get(ModuleManager.class).getEnvironment()) {
gameManifest.addModule(module.getId(), module.getVersion());
}
List<String> registeredBlockFamilies = Lists.newArrayList();
for (BlockFamily family : blockManager.listRegisteredBlockFamilies()) {
registeredBlockFamilies.add(family.getURI().toString());
}
gameManifest.setRegisteredBlockFamilies(registeredBlockFamilies);
gameManifest.setBlockIdMap(blockManager.getBlockIdMap());
List<Biome> biomes = biomeManager.getBiomes();
Map<String, Short> biomeIdMap = new HashMap<>(biomes.size());
for (Biome biome : biomes) {
short shortId = biomeManager.getBiomeShortId(biome);
String id = biomeManager.getBiomeId(biome);
biomeIdMap.put(id, shortId);
}
gameManifest.setBiomeIdMap(biomeIdMap);
gameManifest.addWorld(worldProvider.getWorldInfo());
saveTransactionBuilder.setGameManifest(gameManifest);
}
use of org.terasology.engine.Time in project Terasology by MovingBlocks.
the class StateLoading method dispose.
@Override
public void dispose(boolean shuttingDown) {
EngineTime time = (EngineTime) context.get(Time.class);
time.setPaused(false);
}
use of org.terasology.engine.Time in project Terasology by MovingBlocks.
the class StateLoading method update.
@Override
public void update(float delta) {
GameEngine gameEngine = context.get(GameEngine.class);
EngineTime time = (EngineTime) context.get(Time.class);
long startTime = time.getRealTimeInMs();
while (current != null && time.getRealTimeInMs() - startTime < 20 && !gameEngine.hasPendingState()) {
if (current.step()) {
popStep();
}
}
if (current == null) {
nuiManager.closeScreen(loadingScreen);
nuiManager.setHUDVisible(true);
context.get(GameEngine.class).changeState(new StateIngame(gameManifest, context));
} else {
float progressValue = (progress + current.getExpectedCost() * current.getProgress()) / maxProgress;
loadingScreen.updateStatus(current.getMessage(), progressValue);
nuiManager.update(delta);
}
}
use of org.terasology.engine.Time in project Terasology by MovingBlocks.
the class StateLoading method init.
@Override
public void init(GameEngine engine) {
this.context = engine.createChildContext();
CoreRegistry.setContext(context);
this.nuiManager = new NUIManagerInternal(context.get(CanvasRenderer.class), context);
context.put(NUIManager.class, nuiManager);
EngineTime time = (EngineTime) context.get(Time.class);
time.setPaused(true);
time.setGameTime(gameManifest.getTime());
context.get(Game.class).load(gameManifest);
switch(netMode) {
case CLIENT:
initClient();
break;
default:
initHost();
break;
}
progress = 0;
maxProgress = 0;
for (LoadProcess process : loadProcesses) {
maxProgress += process.getExpectedCost();
}
popStep();
loadingScreen = nuiManager.pushScreen("engine:loadingScreen", LoadingScreen.class);
loadingScreen.updateStatus(current.getMessage(), current.getProgress());
}
use of org.terasology.engine.Time in project Terasology by MovingBlocks.
the class PrepareWorld method begin.
@Override
public void begin() {
worldRenderer = context.get(WorldRenderer.class);
EngineTime time = (EngineTime) context.get(Time.class);
startTime = time.getRealTimeInMs();
}
Aggregations