public void OnHandshakeDoneDownloading(HandshakeTerrainData terrainData)
        {
            // Start loading the world from the data
            // downloaded by the server.
            World.LoadServerTerrain(terrainData.SourceData);

            // Hide the background so the user can
            // watch the world load.
            StaticGui.ShowBackground = false;

            // Enable user input, so the user can fly around
            // while waiting for the world to finish loading
            ToggleFPSUserInput(true);
            Camera.Active.LockedToTransform = null;
            Camera.Active.SetMode(CameraMode.FPS);
            Camera.Active.HoldM2ToLook = true;
            Camera.Active.Position     = new Vector3(32, 400, 32);
            Camera.Active.Yaw          = 135;
            Camera.Active.Pitch        = 20;

            Input.IsCursorLocked  = false;
            Input.IsCursorVisible = true;

            // Tell the loading bar we've moved to the next stage.
            loadingBar.SwitchToTerrainLoading(World.Terrain);
        }
Esempio n. 2
0
        public void OnLevelChunkInbound(NetInboundPacket packet)
        {
            ushort dataLength = packet.ReadUInt16();

            terrainData[terrainDataI] = packet.ReadBytes(dataLength);

            terrainDataRead += dataLength;

            if (OnTerrainProgressReported != null)
            {
                OnTerrainProgressReported(terrainDataRead, terrainDataFullSize);
            }

            DashCMD.WriteStandard("[HS] Received terrain data {0}/{1} bytes", terrainDataRead, terrainDataFullSize);
            terrainDataI++;

            if (terrainDataI < terrainData.Length)
            {
                // Send terrain ack to ask for next part
                NetOutboundPacket ack = new NetOutboundPacket(NetDeliveryMethod.ReliableOrdered);
                ack.Write((byte)CustomPacketType.WorldSectionAck);

                client.SendPacket(ack);
            }
            else
            {
                if (OnTerrainProgressReported != null)
                {
                    OnTerrainProgressReported(terrainDataFullSize, terrainDataFullSize);
                }

                // Uncompress the data and notify the screen we are done downloading.
                HandshakeTerrainData data = new HandshakeTerrainData(terrainData, terrainUncompressedSize);
                screen.OnHandshakeDoneDownloading(data);
            }
        }