use of org.terasology.engine.EngineTime in project Terasology by MovingBlocks.
the class NetworkOwnershipTest method setup.
@Before
public void setup() throws Exception {
super.setup();
ModuleManager moduleManager = ModuleManagerFactory.create();
context.put(ModuleManager.class, moduleManager);
EngineTime mockTime = mock(EngineTime.class);
networkSystem = new NetworkSystemImpl(mockTime, context);
networkSystem.setContext(context);
context.put(NetworkSystem.class, networkSystem);
EntitySystemSetupUtil.addReflectionBasedLibraries(context);
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
entityManager = (PojoEntityManager) context.get(EntityManager.class);
context.put(ComponentSystemManager.class, new ComponentSystemManager(context));
entityManager.clear();
client = mock(NetClient.class);
NetworkComponent clientNetComp = new NetworkComponent();
clientNetComp.replicateMode = NetworkComponent.ReplicateMode.OWNER;
clientEntity = entityManager.create(clientNetComp);
when(client.getEntity()).thenReturn(clientEntity);
when(client.getId()).thenReturn("dummyID");
networkSystem.mockHost();
networkSystem.connectToEntitySystem(entityManager, context.get(EventLibrary.class), mock(BlockEntityRegistry.class));
networkSystem.registerNetworkEntity(clientEntity);
}
use of org.terasology.engine.EngineTime in project Terasology by MovingBlocks.
the class HeadlessEnvironment method setupNetwork.
@Override
protected void setupNetwork() {
EngineTime mockTime = mock(EngineTime.class);
context.put(Time.class, mockTime);
NetworkSystem networkSystem = new NetworkSystemImpl(mockTime, getContext());
context.put(NetworkSystem.class, networkSystem);
}
use of org.terasology.engine.EngineTime in project Terasology by MovingBlocks.
the class StateLoading method dispose.
@Override
public void dispose(boolean shuttingDown) {
EngineTime time = (EngineTime) context.get(Time.class);
time.setPaused(false);
}
use of org.terasology.engine.EngineTime in project Terasology by MovingBlocks.
the class StateLoading method update.
@Override
public void update(float delta) {
GameEngine gameEngine = context.get(GameEngine.class);
EngineTime time = (EngineTime) context.get(Time.class);
long startTime = time.getRealTimeInMs();
while (current != null && time.getRealTimeInMs() - startTime < 20 && !gameEngine.hasPendingState()) {
if (current.step()) {
popStep();
}
}
if (current == null) {
nuiManager.closeScreen(loadingScreen);
nuiManager.setHUDVisible(true);
context.get(GameEngine.class).changeState(new StateIngame(gameManifest, context));
} else {
float progressValue = (progress + current.getExpectedCost() * current.getProgress()) / maxProgress;
loadingScreen.updateStatus(current.getMessage(), progressValue);
nuiManager.update(delta);
}
}
use of org.terasology.engine.EngineTime in project Terasology by MovingBlocks.
the class StateLoading method init.
@Override
public void init(GameEngine engine) {
this.context = engine.createChildContext();
CoreRegistry.setContext(context);
this.nuiManager = new NUIManagerInternal(context.get(CanvasRenderer.class), context);
context.put(NUIManager.class, nuiManager);
EngineTime time = (EngineTime) context.get(Time.class);
time.setPaused(true);
time.setGameTime(gameManifest.getTime());
context.get(Game.class).load(gameManifest);
switch(netMode) {
case CLIENT:
initClient();
break;
default:
initHost();
break;
}
progress = 0;
maxProgress = 0;
for (LoadProcess process : loadProcesses) {
maxProgress += process.getExpectedCost();
}
popStep();
loadingScreen = nuiManager.pushScreen("engine:loadingScreen", LoadingScreen.class);
loadingScreen.updateStatus(current.getMessage(), current.getProgress());
}
Aggregations