public void Load() { if (state != ChunkState.Loaded) { state = ChunkState.Loaded; voxelObject.getLoadedChunks().Add(this); } }
public static void SaveVoxelObject(VoxelObject _voxelObject, string _fileName) { String path = @"external/saves/voxel objects/" + _fileName + ".svo"; if (File.Exists(path) == false) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } StreamWriter file = new StreamWriter(path); file.WriteLine(_voxelObject.getName()); file.WriteLine(_voxelObject.chunkSizeX + "," + _voxelObject.chunkSizeY + "," + _voxelObject.chunkSizeZ); for (int x = 0; x < _voxelObject.getLoadedChunks().Count; x++) { Chunk thisChunk = _voxelObject.getLoadedChunks()[x]; Block[] blocks = thisChunk.getRawData(); for (int i = 0; i < blocks.Length; i++) { Block thisBlock = blocks[i]; if (thisBlock != null) { String line = ""; line += "v:" + thisBlock.getType(); line += "/p:" + thisBlock.getWorldX() + "," + thisBlock.getWorldY() + "," + thisBlock.getWorldZ(); if (thisBlock.getBlockData() is Rotatable) { line += "/r:" + ((Rotatable)thisBlock.getBlockData()).getDirection(); } if (thisBlock.getBlockData() is Flippable && ((Flippable)thisBlock.getBlockData()).canFlip()) { line += "/f:" + ((Flippable)thisBlock.getBlockData()).isFlipped(); } if (thisBlock.getBlockData() is Orientated) { line += "/o:" + ((Orientated)thisBlock.getBlockData()).getOrientation(); } file.WriteLine(line); } } } file.Close(); }