Ejemplo n.º 1
0
        public Chunk Deserialize()
        {
            var chunk = new Chunk(this.Position);

            for (int i = 0; i < this.Cells.Length; i++) {
                if (this.Cells[i] != null) {
                    var cellPos = this.Position + Chunk.ConvertIndexToRelPosition(i);

                    SerializedCellDefinition.Deserialize(cellPos, chunk, this.Cells[i]);
                }
            }

            return chunk;
        }
Ejemplo n.º 2
0
        public static SerializedChunk Serialize(Chunk chunk)
        {
            if (chunk == null) {
                return null;
            }

            var cells = chunk.GetAllCells();
            var serializedChunk = new SerializedChunk();

            serializedChunk.Position = chunk.Bounds.Position.ToIntVector3();
            serializedChunk.Cells = new SerializedCellDefinition[cells.Length];

            for (int i = 0; i < cells.Length; i++) {
                serializedChunk.Cells[i] = SerializedCellDefinition.Serialize(cells[i]);
            }

            return serializedChunk;
        }