use of org.terasology.engine.core.TerasologyEngine in project Terasology by MovingBlocks.
the class Terasology method call.
@Override
public Integer call() throws IOException {
handleLaunchArguments();
setupLogging();
SplashScreen splashScreen;
if (splashEnabled) {
CountDownLatch splashInitLatch = new CountDownLatch(1);
GLFWSplashScreen glfwSplash = new GLFWSplashScreen(splashInitLatch);
Thread thread = new Thread(glfwSplash, "splashscreen-loop");
thread.setDaemon(true);
thread.start();
try {
// wait splash initialize... we will lose some post messages otherwise.
// noinspection ResultOfMethodCallIgnored
splashInitLatch.await(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
// ignore
}
splashScreen = glfwSplash;
} else {
splashScreen = SplashScreenBuilder.createStub();
}
splashScreen.post("Java Runtime " + System.getProperty("java.version") + " loaded");
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) {
// initialize the managers first
engine.initialize();
GameScheduler.scheduleParallel("loadGame", () -> {
GameManifest gameManifest = getLatestGameManifest();
if (gameManifest != null) {
engine.changeState(new StateLoading(gameManifest, NetworkMode.NONE));
}
});
} else {
if (createLastGame) {
engine.initialize();
GameScheduler.scheduleParallel("createLastGame", () -> {
GameManifest gameManifest = getLatestGameManifest();
if (gameManifest != null) {
String title = gameManifest.getTitle();
if (!title.startsWith("New Created")) {
// if first time run
gameManifest.setTitle("New Created " + title + " 1");
} else {
// if not first time run
gameManifest.setTitle(getNewTitle(title));
}
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);
}
return 0;
}
use of org.terasology.engine.core.TerasologyEngine in project Terasology by MovingBlocks.
the class RegisterSystems method step.
@Override
public boolean step() {
componentSystemManager = context.get(ComponentSystemManager.class);
ModuleManager moduleManager = context.get(ModuleManager.class);
TerasologyEngine terasologyEngine = (TerasologyEngine) context.get(GameEngine.class);
for (EngineSubsystem subsystem : terasologyEngine.getSubsystems()) {
subsystem.registerSystems(componentSystemManager);
}
componentSystemManager.loadSystems(moduleManager.getEnvironment(), netMode);
return true;
}
Aggregations