use of org.terasology.engine.subsystem.headless.mode.StateHeadlessSetup in project Terasology by MovingBlocks.
the class Terasology method main.
public static void main(String[] args) {
handlePrintUsageRequest(args);
handleLaunchArguments(args);
SplashScreen splashScreen = splashEnabled ? configureSplashScreen() : SplashScreenBuilder.createStub();
splashScreen.post("Java Runtime " + System.getProperty("java.version") + " loaded");
setupLogging();
try {
TerasologyEngineBuilder builder = new TerasologyEngineBuilder();
populateSubsystems(builder);
TerasologyEngine engine = builder.build();
engine.subscribe(newStatus -> {
if (newStatus == StandardGameStatus.RUNNING) {
splashScreen.close();
} else {
splashScreen.post(newStatus.getDescription());
}
});
if (isHeadless) {
engine.subscribeToStateChange(new HeadlessStateChangeListener(engine));
engine.run(new StateHeadlessSetup());
} else {
if (loadLastGame) {
engine.getFromEngineContext(ThreadManager.class).submitTask("loadGame", () -> {
GameManifest gameManifest = getLatestGameManifest();
if (gameManifest != null) {
engine.changeState(new StateLoading(gameManifest, NetworkMode.NONE));
}
});
}
engine.run(new StateMainMenu());
}
} catch (Throwable e) {
// also catch Errors such as UnsatisfiedLink, NoSuchMethodError, etc.
splashScreen.close();
reportException(e);
}
}
Aggregations