Search in sources :

Example 1 with Activity

use of org.terasology.monitoring.Activity 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)

Aggregations

EngineSubsystem (org.terasology.engine.subsystem.EngineSubsystem)1 Activity (org.terasology.monitoring.Activity)1 NetworkSystem (org.terasology.network.NetworkSystem)1