Beispiel #1
0
        public CrappyChunkStorage.RegionData.TileData Serialize()
        {
            lock (_lock)
            {
                var t = new CrappyChunkStorage.RegionData.TileData();

                t._indexX          = Index.X;
                t._indexY          = Index.Y;
                t._indexZ          = Index.Z;
                t._generationState = (int)CompletedPhase;

                if (_gridBlock != null)
                {
                    Array.Copy(_gridBlock, t._gridBlock, _gridBlock.Length);
                }

                if (_heightmap != null)
                {
                    Array.Copy(_heightmap, t._heightmap, _heightmap.Length);
                }

                if (_depthmap != null)
                {
                    Array.Copy(_depthmap, t._depthmap, _depthmap.Length);
                }

                t._gridExtra    = new byte[0][];
                t._gridEntities = new byte[0][];

                return(t);
            }
        }
Beispiel #2
0
        public void Deserialize(CrappyChunkStorage.RegionData.TileData data)
        {
            lock (_lock)
            {
                GeneratingPhase = CompletedPhase = (GenerationStage)data._generationState;

                if (_isSparse)
                {
                    if (data._gridBlock.All(b => b == Block.Air.Key.InternalId))
                    {
                        return;
                    }

                    InitializeStorage();
                }

                Array.Copy(data._gridBlock, _gridBlock, _gridBlock.Length);
                Array.Copy(data._heightmap, _heightmap, _heightmap.Length);
                Array.Copy(data._depthmap, _depthmap, _depthmap.Length);

                IsDirty = true;
            }
        }