Exemplo n.º 1
0
        public static void SetChunkData(Vector2Int chunkPos, List <CSBlock> blockList)
        {
            MemoryStream keyStream = new MemoryStream();

            formatter.Serialize(keyStream, chunkPos);

            MemoryStream  valueStream = new MemoryStream();
            BlobChunkData chunkData   = new BlobChunkData();

            chunkData.BlockList.AddRange(blockList);
            ProtoBuf.Serializer.Serialize(valueStream, chunkData);

            database.HashSet(KEY_CHUNK_DICT, keyStream.ToArray(), valueStream.ToArray());
        }
Exemplo n.º 2
0
        public static bool GetChunkData(Vector2Int chunkPos, out List <CSBlock> blockList)
        {
            MemoryStream keyStream = new MemoryStream();

            formatter.Serialize(keyStream, chunkPos);

            byte[] data = database.HashGet(KEY_CHUNK_DICT, keyStream.ToArray());
            if (data != null)
            {
                MemoryStream  valueStream = new MemoryStream(data);
                BlobChunkData chunkData   = new BlobChunkData();
                chunkData = ProtoBuf.Serializer.Deserialize <BlobChunkData> (valueStream);
                blockList = chunkData.BlockList;
                return(true);
            }
            else
            {
                blockList = null;
                return(false);
            }
        }