Search in sources :

Example 1 with UpdateSubscriberSystem

use of org.terasology.entitySystem.systems.UpdateSubscriberSystem in project Terasology by MovingBlocks.

the class StateIngame method update.

@Override
public void update(float delta) {
    eventSystem.process();
    for (UpdateSubscriberSystem system : componentSystemManager.iterateUpdateSubscribers()) {
        PerformanceMonitor.startActivity(system.getClass().getSimpleName());
        system.update(delta);
        PerformanceMonitor.endActivity();
    }
    if (worldRenderer != null && shouldUpdateWorld()) {
        worldRenderer.update(delta);
    }
    if (storageManager != null) {
        storageManager.update();
    }
    updateUserInterface(delta);
    storageServiceWorker.flushNotificationsToConsole(console);
}
Also used : UpdateSubscriberSystem(org.terasology.entitySystem.systems.UpdateSubscriberSystem)

Example 2 with UpdateSubscriberSystem

use of org.terasology.entitySystem.systems.UpdateSubscriberSystem in project Terasology by MovingBlocks.

the class AwaitCharacterSpawn method step.

@Override
public boolean step() {
    ComponentSystemManager componentSystemManager = context.get(ComponentSystemManager.class);
    for (UpdateSubscriberSystem updater : componentSystemManager.iterateUpdateSubscribers()) {
        updater.update(0.0f);
    }
    LocalPlayer localPlayer = context.get(LocalPlayer.class);
    ClientComponent client = localPlayer.getClientEntity().getComponent(ClientComponent.class);
    if (client != null && client.character.exists()) {
        client.character.send(new AwaitedLocalCharacterSpawnEvent());
        return true;
    } else {
        chunkProvider.completeUpdate();
        chunkProvider.beginUpdate();
    }
    return false;
}
Also used : LocalPlayer(org.terasology.logic.players.LocalPlayer) UpdateSubscriberSystem(org.terasology.entitySystem.systems.UpdateSubscriberSystem) ClientComponent(org.terasology.network.ClientComponent) ComponentSystemManager(org.terasology.engine.ComponentSystemManager)

Example 3 with UpdateSubscriberSystem

use of org.terasology.entitySystem.systems.UpdateSubscriberSystem in project Terasology by MovingBlocks.

the class ComponentSystemManagerTest method testRegisterUpdateSubscriberAddsSubscriber.

@Test
public void testRegisterUpdateSubscriberAddsSubscriber() {
    UpdateSubscriberSystem system = mock(UpdateSubscriberSystem.class);
    systemUnderTest.register(system);
    assertThat(Iterables.size(systemUnderTest.iterateUpdateSubscribers()), is(1));
}
Also used : UpdateSubscriberSystem(org.terasology.entitySystem.systems.UpdateSubscriberSystem) Test(org.junit.Test)

Example 4 with UpdateSubscriberSystem

use of org.terasology.entitySystem.systems.UpdateSubscriberSystem in project Terasology by MovingBlocks.

the class ComponentSystemManagerTest method testShutdownRemovesUpdateSubscribers.

@Test
public void testShutdownRemovesUpdateSubscribers() {
    UpdateSubscriberSystem system = mock(UpdateSubscriberSystem.class);
    systemUnderTest.register(system);
    systemUnderTest.shutdown();
    assertThat(Iterables.size(systemUnderTest.iterateUpdateSubscribers()), is(0));
}
Also used : UpdateSubscriberSystem(org.terasology.entitySystem.systems.UpdateSubscriberSystem) Test(org.junit.Test)

Aggregations

UpdateSubscriberSystem (org.terasology.entitySystem.systems.UpdateSubscriberSystem)4 Test (org.junit.Test)2 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)1 LocalPlayer (org.terasology.logic.players.LocalPlayer)1 ClientComponent (org.terasology.network.ClientComponent)1