/// <summary> /// Saves a chunk to disk. /// </summary> /// <param name="chunk">The chunk to save.</param> /// <param name="dimensionID">The ID of the dimension the chunk belongs to.</param> public void SaveChunk(Chunk chunk, Guid dimensionID, AbstractWorldSink sink) { bool dimensionExists = WorldStorage.DimensionPaths.TryGetValue(dimensionID, out string path); if (!dimensionExists) { throw new DirectoryNotFoundException("Dimension save folder does not exist!"); } sink.Receive(chunk, path + Path.DirectorySeparatorChar + chunk.ChunkLocation.ToString() + ".chunk", dimensionID); }
/// <summary> /// Saves a structure to disk. /// </summary> /// <param name="structure">The structure to save.</param> /// <param name="dimensionID">The ID of the dimension the structure belongs to.</param> internal void SaveStructure(Structure structure, Guid dimensionID, AbstractWorldSink sink) { bool dimensionExists = WorldStorage.DimensionPaths.TryGetValue(dimensionID, out string path); if (!dimensionExists) { throw new DirectoryNotFoundException("Dimension save folder does not exist!"); } sink.Receive(structure, path + Path.DirectorySeparatorChar + structure.StructureID + ".struct", dimensionID); }
/// <summary> /// Sends a <see cref="WorldTransferHeaderMessage"/>, then serializes and sends the world of the network. /// </summary> /// <param name="saveName"></param> /// <param name="sink"></param> public static void NetSerializeWorld(string saveName, AbstractWorldSink sink) { List <DimensionHeader> headers = new List <DimensionHeader>(); foreach (KeyValuePair <Guid, string> item in DimensionPaths) { headers.Add(DimensionStorage.LoadDimensionHeader(item.Key)); } //Send header information about all dimensions //This is so that the client can properly handle the incoming parts of the world. sink.Receive(headers, null, Guid.Empty);//No headers //Send the client the world. SerializeWorld(saveName, sink); }
internal void SaveItemRegistry(Dimension dimension, AbstractWorldSink sink) { string result = WorldStorage.DimensionPaths[dimension.ID]; sink.Receive(dimension.Items, result + Path.DirectorySeparatorChar + dimension.ID + ".itemreg", dimension.ID); }
internal void SaveItemRegistry(ItemRegistry registry, AbstractWorldSink sink, Guid dimensionID) { string result = WorldStorage.DimensionPaths[dimensionID]; sink.Receive(registry, result + Path.DirectorySeparatorChar + dimensionID + ".itemreg", dimensionID); }
internal void SerializeDimensionHeader(DimensionHeader header, AbstractWorldSink sink, string dimensionRoot) { sink.Receive(header, dimensionRoot + Path.DirectorySeparatorChar + header.ID + ".header", header.ID); }