Search in sources :

Example 1 with EngineTime

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);
}
Also used : NetworkComponent(org.terasology.network.NetworkComponent) EventLibrary(org.terasology.entitySystem.metadata.EventLibrary) EngineTime(org.terasology.engine.EngineTime) BlockEntityRegistry(org.terasology.world.BlockEntityRegistry) ModuleManager(org.terasology.engine.module.ModuleManager) ComponentSystemManager(org.terasology.engine.ComponentSystemManager) Before(org.junit.Before)

Example 2 with EngineTime

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);
}
Also used : NetworkSystem(org.terasology.network.NetworkSystem) EngineTime(org.terasology.engine.EngineTime) NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl)

Example 3 with EngineTime

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);
}
Also used : EngineTime(org.terasology.engine.EngineTime) Time(org.terasology.engine.Time) EngineTime(org.terasology.engine.EngineTime)

Example 4 with EngineTime

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);
    }
}
Also used : EngineTime(org.terasology.engine.EngineTime) GameEngine(org.terasology.engine.GameEngine) Time(org.terasology.engine.Time) EngineTime(org.terasology.engine.EngineTime)

Example 5 with EngineTime

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());
}
Also used : Game(org.terasology.game.Game) EngineTime(org.terasology.engine.EngineTime) Time(org.terasology.engine.Time) EngineTime(org.terasology.engine.EngineTime) LoadingScreen(org.terasology.rendering.nui.layers.mainMenu.loadingScreen.LoadingScreen) NUIManagerInternal(org.terasology.rendering.nui.internal.NUIManagerInternal)

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