use of org.terasology.engine.core.modes.loadProcesses.AwaitCharacterSpawn in project Terasology by MovingBlocks.
the class StateLoading method initClient.
private void initClient() {
loadProcesses.add(new JoinServer(context, gameManifest, joinStatus));
if (!headless) {
loadProcesses.add(new InitialiseRendering(context));
}
loadProcesses.add(new InitialiseEntitySystem(context));
loadProcesses.add(new RegisterBlocks(context, gameManifest));
if (!headless) {
loadProcesses.add(new InitialiseGraphics(context));
}
loadProcesses.add(new LoadPrefabs(context));
loadProcesses.add(new ProcessBlockPrefabs(context));
loadProcesses.add(new LoadExtraBlockData(context));
loadProcesses.add(new InitialiseComponentSystemManager(context));
if (!headless) {
loadProcesses.add(new RegisterInputSystem(context));
}
loadProcesses.add(new RegisterSystems(context, netMode));
loadProcesses.add(new InitialiseCommandSystem(context));
loadProcesses.add(new InitialiseRemoteWorld(context, gameManifest));
loadProcesses.add(new InitialisePhysics(context));
loadProcesses.add(new InitialiseSystems(context));
loadProcesses.add(new PreBeginSystems(context));
loadProcesses.add(new CreateRemoteWorldEntity(context));
loadProcesses.add(new PostBeginSystems(context));
loadProcesses.add(new SetupRemotePlayer(context));
loadProcesses.add(new AwaitCharacterSpawn(context));
loadProcesses.add(new RegisterBlockFamilies(context));
loadProcesses.add(new PrepareWorld(context));
}
use of org.terasology.engine.core.modes.loadProcesses.AwaitCharacterSpawn in project Terasology by MovingBlocks.
the class StateLoading method initHost.
private void initHost() {
loadProcesses.add(new RegisterMods(context, gameManifest));
if (!headless) {
loadProcesses.add(new InitialiseRendering(context));
}
loadProcesses.add(new InitialiseEntitySystem(context));
loadProcesses.add(new RegisterBlocks(context, gameManifest));
if (!headless) {
loadProcesses.add(new InitialiseGraphics(context));
}
loadProcesses.add(new LoadPrefabs(context));
loadProcesses.add(new ProcessBlockPrefabs(context));
loadProcesses.add(new InitialiseComponentSystemManager(context));
if (!headless) {
loadProcesses.add(new RegisterInputSystem(context));
}
loadProcesses.add(new RegisterSystems(context, netMode));
loadProcesses.add(new InitialiseCommandSystem(context));
loadProcesses.add(new LoadExtraBlockData(context));
loadProcesses.add(new InitialiseWorld(gameManifest, context));
loadProcesses.add(new RegisterBlockFamilies(context));
loadProcesses.add(new EnsureSaveGameConsistency(context));
loadProcesses.add(new InitialisePhysics(context));
loadProcesses.add(new InitialiseSystems(context));
loadProcesses.add(new PreBeginSystems(context));
loadProcesses.add(new LoadEntities(context));
loadProcesses.add(new InitialiseBlockTypeEntities(context));
loadProcesses.add(new CreateWorldEntity(context, gameManifest));
loadProcesses.add(new InitialiseWorldGenerator(context));
loadProcesses.add(new InitialiseRecordAndReplay(context));
if (netMode.isServer()) {
boolean dedicated;
if (netMode == NetworkMode.DEDICATED_SERVER) {
dedicated = true;
} else if (netMode == NetworkMode.LISTEN_SERVER) {
dedicated = false;
} else {
throw new IllegalStateException("Invalid server mode: " + netMode);
}
loadProcesses.add(new StartServer(context, dedicated));
}
loadProcesses.add(new PostBeginSystems(context));
if (netMode.hasLocalClient()) {
loadProcesses.add(new SetupLocalPlayer(context));
loadProcesses.add(new AwaitCharacterSpawn(context));
}
loadProcesses.add(new PrepareWorld(context));
}
use of org.terasology.engine.core.modes.loadProcesses.AwaitCharacterSpawn 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()) {
try {
if (current.step()) {
popStep();
}
} catch (Exception e) {
logger.error("Error while loading {}", current, e);
String errorMessage = String.format("Failed to load game. There was an error during \"%s\".", current == null ? "the last part" : current.getMessage());
gameEngine.changeState(new StateMainMenu(errorMessage));
CrashReporter.report(e, LoggingContext.getLoggingPath());
return;
}
}
if (current == null) {
if (nuiManager != 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;
if (nuiManager != null) {
loadingScreen.updateStatus(current.getMessage(), progressValue);
nuiManager.update(delta);
}
// chunk generation begins at the AwaitCharacterSpawn step
if (current instanceof AwaitCharacterSpawn && !chunkGenerationStarted) {
chunkGenerationStarted = true;
// in case no chunks generate, this should be set for a basis
timeLastChunkGenerated = time.getRealTimeInMs();
}
if (chunkGenerationStarted) {
long timeSinceLastChunk = time.getRealTimeInMs() - timeLastChunkGenerated;
long chunkGenerationTimeout = systemConfig.chunkGenerationFailTimeoutInMs.get();
if (timeSinceLastChunk > chunkGenerationTimeout) {
String errorMessage = "World generation timed out, check the log for more info";
gameEngine.changeState(new StateMainMenu(errorMessage));
}
}
}
}
Aggregations