use of org.terasology.engine.subsystem.EngineSubsystem in project Terasology by MovingBlocks.
the class Terasology method populateSubsystems.
private static void populateSubsystems(TerasologyEngineBuilder builder) {
if (isHeadless) {
builder.add(new HeadlessGraphics()).add(new HeadlessTimer()).add(new HeadlessAudio()).add(new HeadlessInput());
} else {
EngineSubsystem audio = soundEnabled ? new LwjglAudio() : new HeadlessAudio();
builder.add(audio).add(new LwjglGraphics()).add(new LwjglTimer()).add(new LwjglInput()).add(new BindsSubsystem()).add(new OpenVRInput());
}
builder.add(new HibernationSubsystem());
}
use of org.terasology.engine.subsystem.EngineSubsystem in project Terasology by MovingBlocks.
the class TerasologyEngine method postInitSubsystems.
/**
* Gives a chance to subsystems to do something AFTER managers and Time are initialized.
*/
private void postInitSubsystems() {
for (EngineSubsystem subsystem : getSubsystems()) {
changeStatus(() -> "Post-Initialising " + subsystem.getName() + " subsystem");
subsystem.postInitialise(rootContext);
}
}
use of org.terasology.engine.subsystem.EngineSubsystem in project Terasology by MovingBlocks.
the class TerasologyEngine method cleanup.
public void cleanup() {
logger.info("Shutting down Terasology...");
changeStatus(StandardGameStatus.SHUTTING_DOWN);
if (currentState != null) {
currentState.dispose(true);
currentState = null;
}
Iterator<EngineSubsystem> preshutdownIter = allSubsystems.descendingIterator();
while (preshutdownIter.hasNext()) {
EngineSubsystem subsystem = preshutdownIter.next();
try {
subsystem.preShutdown();
} catch (RuntimeException e) {
logger.error("Error preparing to shutdown {} subsystem", subsystem.getName(), e);
}
}
Iterator<EngineSubsystem> shutdownIter = allSubsystems.descendingIterator();
while (shutdownIter.hasNext()) {
EngineSubsystem subsystem = shutdownIter.next();
try {
subsystem.shutdown();
} catch (RuntimeException e) {
logger.error("Error shutting down {} subsystem", subsystem.getName(), e);
}
}
}
use of org.terasology.engine.subsystem.EngineSubsystem in project Terasology by MovingBlocks.
the class TerasologyEngine method tick.
/**
* Runs a single "tick" of the engine
* @return true if the loop requesting a tick should continue running
*/
public boolean tick() {
if (shutdownRequested) {
return false;
}
assetTypeManager.reloadChangedOnDisk();
processPendingState();
if (currentState == null) {
shutdown();
return false;
}
Iterator<Float> updateCycles = timeSubsystem.getEngineTime().tick();
CoreRegistry.setContext(currentState.getContext());
rootContext.get(NetworkSystem.class).setContext(currentState.getContext());
for (EngineSubsystem subsystem : allSubsystems) {
try (Activity ignored = PerformanceMonitor.startActivity(subsystem.getName() + " PreUpdate")) {
subsystem.preUpdate(currentState, timeSubsystem.getEngineTime().getRealDelta());
}
}
while (updateCycles.hasNext()) {
// gameTime gets updated here!
float updateDelta = updateCycles.next();
try (Activity ignored = PerformanceMonitor.startActivity("Main Update")) {
currentState.update(updateDelta);
}
}
// Waiting processes are set by modules via GameThread.a/synch() methods.
GameThread.processWaitingProcesses();
for (EngineSubsystem subsystem : getSubsystems()) {
try (Activity ignored = PerformanceMonitor.startActivity(subsystem.getName() + " Subsystem postUpdate")) {
subsystem.postUpdate(currentState, timeSubsystem.getEngineTime().getRealDelta());
}
}
assetTypeManager.disposedUnusedAssets();
PerformanceMonitor.rollCycle();
PerformanceMonitor.startActivity("Other");
return true;
}
use of org.terasology.engine.subsystem.EngineSubsystem in project Terasology by MovingBlocks.
the class TerasologyEngine method initSubsystems.
private void initSubsystems() {
changeStatus(TerasologyEngineStatus.INITIALIZING_SUBSYSTEMS);
for (EngineSubsystem subsystem : getSubsystems()) {
changeStatus(() -> "Initialising " + subsystem.getName() + " subsystem");
subsystem.initialise(this, rootContext);
}
}
Aggregations