using System.Collections.Generic;
using System.IO;
using Substrate.Nbt;
namespace Substrate.Core
{
public interface IRegion : IChunkContainer
{
///
/// Gets the global X-coordinate of the region.
///
int X { get; }
///
/// Gets the global Z-coordinate of the region.
///
int Z { get; }
///
/// Get the appropriate filename for this region.
///
/// The filename of the region with encoded coordinates.
string GetFileName ();
///
/// Gets the full path of the region's backing file.
///
/// Gets the path of the region's file based on the 's region path and the region's on filename.
string GetFilePath ();
///
/// Gets the for a chunk given local coordinates into the region.
///
/// The local X-coordinate of a chunk within the region.
/// The local Z-coordinate of a chunk within the region.
/// An for a local chunk, or null if there is no chunk at the given coordinates.
NbtTree GetChunkTree (int lcx, int lcz);
///
/// Saves an for a chunk back to the region's data store at the given local coordinates.
///
/// The local X-coordinate of the chunk within the region.
/// The local Z-coordinate of the chunk within the region.
/// The of a chunk to write back to the region.
/// True if the save succeeded.
/// It is up to the programmer to ensure that the global coordinates defined within the chunk's tree
/// are consistent with the local coordinates of the region being written into.
bool SaveChunkTree (int lcx, int lcz, NbtTree tree);
///
/// Saves an for a chunk back to the region's data store at the given local coordinates and with the given timestamp.
///
/// The local X-coordinate of the chunk within the region.
/// The local Z-coordinate of the chunk within the region.
/// The of a chunk to write back to the region.
/// The timestamp to write to the underlying region file for this chunk.
/// True if the save succeeded.
/// It is up to the programmer to ensure that the global coordinates defined within the chunk's tree
/// are consistent with the local coordinates of the region being written into.
bool SaveChunkTree (int lcx, int lcz, NbtTree tree, int timestamp);
///
/// Gets an output stream for replacing chunk data at the given coordinates within the region.
///
/// The local X-coordinate of the chunk to replace within the region.
/// The local Z-coordinate of the chunk to replace within the region.
/// An output stream that can be written to on demand.
/// There is no guarantee that any data will be saved until the stream is closed.
Stream GetChunkOutStream (int lcx, int lcz);
///
/// Returns the count of valid chunks stored in this region.
///
/// The count of currently stored chunks.
int ChunkCount ();
///
/// Gets a for a chunk at the given local coordinates relative to this region.
///
/// The local X-coordinate of a chunk relative to this region.
/// The local Z-coordinate of a chunk relative to this region.
/// A at the given local coordinates, or null if no chunk exists.
/// The local coordinates do not strictly need to be within the bounds of the region. If coordinates are detected
/// as being out of bounds, the lookup will be delegated to the correct region and the lookup will be performed there
/// instead. This allows any to perform a similar task to , but with a
/// region-local frame of reference instead of a global frame of reference.
ChunkRef GetChunkRef (int lcx, int lcz);
///
/// Creates a new chunk at the given local coordinates relative to this region and returns a new for it.
///
/// The local X-coordinate of a chunk relative to this region.
/// The local Z-coordinate of a chunk relative to this region.
/// A for the newly created chunk.
/// If the local coordinates are out of bounds for this region, the action will be forwarded to the correct region
/// transparently.
ChunkRef CreateChunk (int lcx, int lcz);
///
/// Gets the timestamp of a chunk from the underlying region file.
///
/// The local X-coordinate of a chunk relative to this region.
/// The local Z-coordinate of a chunk relative to this region.
/// The timestamp of the chunk slot in the region.
/// The value returned may differ from any timestamp stored in the chunk data itself.
int GetChunkTimestamp (int lcx, int lcz);
///
/// Sets the timestamp of a chunk in the underlying region file.
///
/// The local X-coordinate of a chunk relative to this region.
/// The local Z-coordinate of a chunk relative to this region.
/// The new timestamp value.
/// This function will only update the timestamp of the chunk slot in the underlying region file. It will not update
/// any timestamp information in the chunk data itself.
void SetChunkTimestamp (int lcx, int lcz, int timestamp);
}
public interface IRegionContainer
{
///
/// Determines if a region exists at the given coordinates.
///
/// The global X-coordinate of a region.
/// The global Z-coordinate of a region.
/// True if a region exists at the given global region coordinates; false otherwise.
bool RegionExists (int rx, int rz);
///
/// Gets an for the given region filename.
///
/// The filename of the region to get.
/// A corresponding to the coordinates encoded in the filename.
IRegion GetRegion (int rx, int rz);
///
/// Creates a new empty region at the given coordinates, if no region exists.
///
/// The global X-coordinate of a region.
/// The global Z-coordinate of a region.
/// A new empty object for the given coordinates, or an existing if one exists.
IRegion CreateRegion (int rx, int rz);
///
/// Deletes a region at the given coordinates.
///
/// The global X-coordinate of a region.
/// The global Z-coordinate of a region.
/// True if a region was deleted; false otherwise.
bool DeleteRegion (int rx, int rz);
}
public interface IRegionManager : IRegionContainer, IEnumerable
{
}
}