Search in sources :

Example 1 with WorldClientCommon

use of io.xol.chunkstories.world.WorldClientCommon in project chunkstories by Hugobros3.

the class Client method changeWorld.

@Override
public void changeWorld(WorldClient world2) {
    WorldClientCommon world = (WorldClientCommon) world2;
    Runnable job = new Runnable() {

        @Override
        public void run() {
            // Setup the new world and make a controller for it
            Client.this.world = world;
            player = new PlayerClientImplementation(Client.this, world);
            // Change the scene
            Ingame ingameScene = new Ingame(gameWindow, world);
            // We want to keep the connection overlay when getting into a server
            if (gameWindow.getLayer() instanceof ConnectionOverlay) {
                ConnectionOverlay overlay = (ConnectionOverlay) gameWindow.getLayer();
                // If that happen, we want this connection overlay to forget he was originated from a server browser or whatever
                overlay.setParentScene(ingameScene);
            } else
                gameWindow.setLayer(ingameScene);
            // Switch scene but keep the overlay
            // ingameScene.changeOverlay(overlay);
            // Start only the logic after all that
            world.startLogic();
        }
    };
    if (gameWindow.isInstanceMainGLWindow())
        job.run();
    else {
        Fence fence = gameWindow.queueSynchronousTask(job);
        fence.traverse();
    }
}
Also used : ConnectionOverlay(io.xol.chunkstories.gui.layer.ingame.ConnectionOverlay) WorldClientCommon(io.xol.chunkstories.world.WorldClientCommon) Ingame(io.xol.chunkstories.gui.layer.ingame.Ingame) SimpleFence(io.xol.chunkstories.util.concurrency.SimpleFence) Fence(io.xol.chunkstories.api.util.concurrency.Fence)

Aggregations

Fence (io.xol.chunkstories.api.util.concurrency.Fence)1 ConnectionOverlay (io.xol.chunkstories.gui.layer.ingame.ConnectionOverlay)1 Ingame (io.xol.chunkstories.gui.layer.ingame.Ingame)1 SimpleFence (io.xol.chunkstories.util.concurrency.SimpleFence)1 WorldClientCommon (io.xol.chunkstories.world.WorldClientCommon)1