Search in sources :

Example 1 with EngineSubsystem

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());
}
Also used : LwjglAudio(org.terasology.engine.subsystem.lwjgl.LwjglAudio) HeadlessTimer(org.terasology.engine.subsystem.headless.HeadlessTimer) BindsSubsystem(org.terasology.engine.subsystem.config.BindsSubsystem) HeadlessGraphics(org.terasology.engine.subsystem.headless.HeadlessGraphics) EngineSubsystem(org.terasology.engine.subsystem.EngineSubsystem) OpenVRInput(org.terasology.engine.subsystem.openvr.OpenVRInput) LwjglTimer(org.terasology.engine.subsystem.lwjgl.LwjglTimer) LwjglInput(org.terasology.engine.subsystem.lwjgl.LwjglInput) LwjglGraphics(org.terasology.engine.subsystem.lwjgl.LwjglGraphics) HeadlessInput(org.terasology.engine.subsystem.headless.HeadlessInput) HeadlessAudio(org.terasology.engine.subsystem.headless.HeadlessAudio) HibernationSubsystem(org.terasology.engine.subsystem.common.hibernation.HibernationSubsystem)

Example 2 with EngineSubsystem

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);
    }
}
Also used : EngineSubsystem(org.terasology.engine.subsystem.EngineSubsystem)

Example 3 with EngineSubsystem

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);
        }
    }
}
Also used : EngineSubsystem(org.terasology.engine.subsystem.EngineSubsystem)

Example 4 with EngineSubsystem

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;
}
Also used : EngineSubsystem(org.terasology.engine.subsystem.EngineSubsystem) NetworkSystem(org.terasology.network.NetworkSystem) Activity(org.terasology.monitoring.Activity)

Example 5 with EngineSubsystem

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);
    }
}
Also used : EngineSubsystem(org.terasology.engine.subsystem.EngineSubsystem)

Aggregations

EngineSubsystem (org.terasology.engine.subsystem.EngineSubsystem)8 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)1 GameEngine (org.terasology.engine.GameEngine)1 TerasologyEngine (org.terasology.engine.TerasologyEngine)1 ModuleManager (org.terasology.engine.module.ModuleManager)1 HibernationSubsystem (org.terasology.engine.subsystem.common.hibernation.HibernationSubsystem)1 BindsSubsystem (org.terasology.engine.subsystem.config.BindsSubsystem)1 HeadlessAudio (org.terasology.engine.subsystem.headless.HeadlessAudio)1 HeadlessGraphics (org.terasology.engine.subsystem.headless.HeadlessGraphics)1 HeadlessInput (org.terasology.engine.subsystem.headless.HeadlessInput)1 HeadlessTimer (org.terasology.engine.subsystem.headless.HeadlessTimer)1 LwjglAudio (org.terasology.engine.subsystem.lwjgl.LwjglAudio)1 LwjglGraphics (org.terasology.engine.subsystem.lwjgl.LwjglGraphics)1 LwjglInput (org.terasology.engine.subsystem.lwjgl.LwjglInput)1 LwjglTimer (org.terasology.engine.subsystem.lwjgl.LwjglTimer)1 OpenVRInput (org.terasology.engine.subsystem.openvr.OpenVRInput)1 Prefab (org.terasology.entitySystem.prefab.Prefab)1 PrefabData (org.terasology.entitySystem.prefab.PrefabData)1 PojoPrefab (org.terasology.entitySystem.prefab.internal.PojoPrefab)1 BehaviorTree (org.terasology.logic.behavior.asset.BehaviorTree)1