Search in sources :

Example 1 with Activity

use of org.terasology.engine.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;
    }
    if (assetTypeManager instanceof AutoReloadAssetTypeManager) {
        ((AutoReloadAssetTypeManager) assetTypeManager).reloadChangedAssets();
    }
    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.core.subsystem.EngineSubsystem) NetworkSystem(org.terasology.engine.network.NetworkSystem) Activity(org.terasology.engine.monitoring.Activity) AutoReloadAssetTypeManager(org.terasology.gestalt.assets.module.autoreload.AutoReloadAssetTypeManager)

Aggregations

EngineSubsystem (org.terasology.engine.core.subsystem.EngineSubsystem)1 Activity (org.terasology.engine.monitoring.Activity)1 NetworkSystem (org.terasology.engine.network.NetworkSystem)1 AutoReloadAssetTypeManager (org.terasology.gestalt.assets.module.autoreload.AutoReloadAssetTypeManager)1