Search in sources :

Example 6 with Fence

use of io.xol.chunkstories.api.util.concurrency.Fence 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)6 ChunkHolder (io.xol.chunkstories.api.world.chunk.ChunkHolder)2 CompoundFence (io.xol.chunkstories.util.concurrency.CompoundFence)2 LocalPlayer (io.xol.chunkstories.api.client.LocalPlayer)1 OnlineContentTranslator (io.xol.chunkstories.api.content.OnlineContentTranslator)1 PlayerLogoutEvent (io.xol.chunkstories.api.events.player.PlayerLogoutEvent)1 Player (io.xol.chunkstories.api.player.Player)1 VertexBuffer (io.xol.chunkstories.api.rendering.vertex.VertexBuffer)1 Voxel (io.xol.chunkstories.api.voxel.Voxel)1 WorldSize (io.xol.chunkstories.api.world.WorldInfo.WorldSize)1 WorldMaster (io.xol.chunkstories.api.world.WorldMaster)1 WorldUser (io.xol.chunkstories.api.world.WorldUser)1 CellData (io.xol.chunkstories.api.world.cell.CellData)1 Heightmap (io.xol.chunkstories.api.world.heightmap.Heightmap)1 Client (io.xol.chunkstories.client.Client)1 ClientPacketsContext (io.xol.chunkstories.client.net.ClientPacketsContext)1 ConverterWorkerThread (io.xol.chunkstories.converter.ConverterWorkers.ConverterWorkerThread)1 SerializedEntityFile (io.xol.chunkstories.entity.SerializedEntityFile)1 ConnectionOverlay (io.xol.chunkstories.gui.layer.ingame.ConnectionOverlay)1 Ingame (io.xol.chunkstories.gui.layer.ingame.Ingame)1