Пример #1
0
        private void SendChunkDataTo(EndPoint ep, GenericMessage msg)
        {
            var chp   = new ChunkPos((int)msg.ReadSignedInteger(), (int)msg.ReadSignedInteger());
            var chunk = _world.GetChunk(chp);

            if (!chunk.HasData)
            {
                _world.LoadChunk(chp);
            }

            var raw = chunk.GetRaw();

            var m = new GenericMessage();

            m.WriteUnsignedInteger(1);
            m.WriteSignedInteger((uint)chp.x);
            m.WriteSignedInteger((uint)chp.z);

            var data = new byte[raw.Length];

            Buffer.BlockCopy(raw, 0, data, 0, data.Length);

            m.WriteUnsignedInteger((uint)data.Length);
            m.WriteByteArray(data);

            _server.SendToAsync(ep, m);
        }
Пример #2
0
        public void RequestChunk(ChunkPos pos)
        {
            var m = new GenericMessage();

            m.WriteUnsignedInteger(2);

            m.WriteSignedInteger(pos.x);
            m.WriteSignedInteger(pos.z);

            client.Send(m);
        }