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