Search in sources :

Example 6 with EngineTime

use of org.terasology.engine.EngineTime in project Terasology by MovingBlocks.

the class PrepareWorld method begin.

@Override
public void begin() {
    worldRenderer = context.get(WorldRenderer.class);
    EngineTime time = (EngineTime) context.get(Time.class);
    startTime = time.getRealTimeInMs();
}
Also used : EngineTime(org.terasology.engine.EngineTime) EngineTime(org.terasology.engine.EngineTime) Time(org.terasology.engine.Time) WorldRenderer(org.terasology.rendering.world.WorldRenderer)

Example 7 with EngineTime

use of org.terasology.engine.EngineTime in project Terasology by MovingBlocks.

the class PrepareWorld method step.

@Override
public boolean step() {
    if (worldRenderer.pregenerateChunks()) {
        return true;
    }
    EngineTime time = (EngineTime) context.get(Time.class);
    long totalTime = time.getRealTimeInMs() - startTime;
    return totalTime > 5000;
}
Also used : EngineTime(org.terasology.engine.EngineTime) EngineTime(org.terasology.engine.EngineTime) Time(org.terasology.engine.Time)

Example 8 with EngineTime

use of org.terasology.engine.EngineTime in project Terasology by MovingBlocks.

the class TestNetwork method testEntityNetworkIdChangedOnServerStart.

@Test
public void testEntityNetworkIdChangedOnServerStart() throws HostingFailedException {
    EngineEntityManager entityManager = getEntityManager();
    NetworkComponent netComp = new NetworkComponent();
    netComp.setNetworkId(122);
    EntityRef entity = entityManager.create(netComp);
    EngineTime time = mock(EngineTime.class);
    NetworkSystem server = new NetworkSystemImpl(time, context);
    server.setContext(context);
    netSystems.add(server);
    server.connectToEntitySystem(entityManager, context.get(EventLibrary.class), null);
    server.host(7777, true);
    assertFalse(122 == entity.getComponent(NetworkComponent.class).getNetworkId());
    server.shutdown();
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) EventLibrary(org.terasology.entitySystem.metadata.EventLibrary) EngineTime(org.terasology.engine.EngineTime) EntityRef(org.terasology.entitySystem.entity.EntityRef) NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl) Test(org.junit.Test)

Example 9 with EngineTime

use of org.terasology.engine.EngineTime in project Terasology by MovingBlocks.

the class TestNetwork method testNetwork.

@Test
public void testNetwork() throws Exception {
    EngineEntityManager entityManager = getEntityManager();
    EngineTime time = mock(EngineTime.class);
    NetworkSystem server = new NetworkSystemImpl(time, context);
    server.setContext(context);
    netSystems.add(server);
    server.connectToEntitySystem(entityManager, context.get(EventLibrary.class), null);
    server.host(7777, true);
    Thread.sleep(500);
    NetworkSystem client = new NetworkSystemImpl(time, context);
    client.setContext(context);
    netSystems.add(client);
    client.join("localhost", 7777);
    Thread.sleep(500);
    server.shutdown();
    client.shutdown();
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) EventLibrary(org.terasology.entitySystem.metadata.EventLibrary) EngineTime(org.terasology.engine.EngineTime) NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl) Test(org.junit.Test)

Aggregations

EngineTime (org.terasology.engine.EngineTime)9 Time (org.terasology.engine.Time)5 EventLibrary (org.terasology.entitySystem.metadata.EventLibrary)3 NetworkSystemImpl (org.terasology.network.internal.NetworkSystemImpl)3 Test (org.junit.Test)2 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)2 Before (org.junit.Before)1 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)1 GameEngine (org.terasology.engine.GameEngine)1 ModuleManager (org.terasology.engine.module.ModuleManager)1 EntityRef (org.terasology.entitySystem.entity.EntityRef)1 Game (org.terasology.game.Game)1 NetworkComponent (org.terasology.network.NetworkComponent)1 NetworkSystem (org.terasology.network.NetworkSystem)1 NUIManagerInternal (org.terasology.rendering.nui.internal.NUIManagerInternal)1 LoadingScreen (org.terasology.rendering.nui.layers.mainMenu.loadingScreen.LoadingScreen)1 WorldRenderer (org.terasology.rendering.world.WorldRenderer)1 BlockEntityRegistry (org.terasology.world.BlockEntityRegistry)1