Search in sources :

Example 1 with UpdateSubscriberSystem

use of org.terasology.engine.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.update();
    }
    return false;
}
Also used : LocalPlayer(org.terasology.engine.logic.players.LocalPlayer) UpdateSubscriberSystem(org.terasology.engine.entitySystem.systems.UpdateSubscriberSystem) ClientComponent(org.terasology.engine.network.ClientComponent) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager)

Example 2 with UpdateSubscriberSystem

use of org.terasology.engine.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();
    }
    if (nuiManager != null) {
        updateUserInterface(delta);
    }
    storageServiceWorker.flushNotificationsToConsole(console);
}
Also used : UpdateSubscriberSystem(org.terasology.engine.entitySystem.systems.UpdateSubscriberSystem)

Example 3 with UpdateSubscriberSystem

use of org.terasology.engine.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);
    assertEquals(Iterables.size(systemUnderTest.iterateUpdateSubscribers()), 1);
}
Also used : UpdateSubscriberSystem(org.terasology.engine.entitySystem.systems.UpdateSubscriberSystem) Test(org.junit.jupiter.api.Test)

Example 4 with UpdateSubscriberSystem

use of org.terasology.engine.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();
    assertEquals(Iterables.size(systemUnderTest.iterateUpdateSubscribers()), 0);
}
Also used : UpdateSubscriberSystem(org.terasology.engine.entitySystem.systems.UpdateSubscriberSystem) Test(org.junit.jupiter.api.Test)

Aggregations

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