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;
}
Aggregations