diff --git a/Substrate/SubstrateCS/Source/AlphaBlock.cs b/Substrate/SubstrateCS/Source/AlphaBlock.cs index 42777c2..d56c289 100644 --- a/Substrate/SubstrateCS/Source/AlphaBlock.cs +++ b/Substrate/SubstrateCS/Source/AlphaBlock.cs @@ -146,6 +146,9 @@ namespace Substrate _tileEntity = te; } + /// + /// Creates a default Tile Entity record appropriate for the block. + /// public void CreateTileEntity () { BlockInfoEx info = BlockInfo.BlockTable[_id] as BlockInfoEx; diff --git a/Substrate/SubstrateCS/Source/AlphaBlockRef.cs b/Substrate/SubstrateCS/Source/AlphaBlockRef.cs index b4dc9b9..54d9007 100644 --- a/Substrate/SubstrateCS/Source/AlphaBlockRef.cs +++ b/Substrate/SubstrateCS/Source/AlphaBlockRef.cs @@ -35,6 +35,9 @@ namespace Substrate _index = index; } + /// + /// Checks if this object is currently a valid ref into another . + /// public bool IsValid { get { return _collection != null; } @@ -140,6 +143,9 @@ namespace Substrate _collection.SetTileEntity(_index, te); } + /// + /// Creates a default Tile Entity record appropriate for the block. + /// public void CreateTileEntity () { _collection.CreateTileEntity(_index); diff --git a/Substrate/SubstrateCS/Source/BlockManager.cs b/Substrate/SubstrateCS/Source/BlockManager.cs index 56d4711..ea49014 100644 --- a/Substrate/SubstrateCS/Source/BlockManager.cs +++ b/Substrate/SubstrateCS/Source/BlockManager.cs @@ -3,6 +3,9 @@ using Substrate.Core; namespace Substrate { + /// + /// Represents an Alpha-compatible interface for globally managing blocks. + /// public class BlockManager : IBlockManager { public const int MIN_X = -32000000; @@ -29,18 +32,28 @@ namespace Substrate private bool _autoLight = true; private bool _autoFluid = false; + /// + /// Gets or sets a value indicating whether changes to blocks will trigger automatic lighting updates. + /// public bool AutoLight { get { return _autoLight; } set { _autoLight = value; } } + /// + /// Gets or sets a value indicating whether changes to blocks will trigger automatic fluid updates. + /// public bool AutoFluid { get { return _autoFluid; } set { _autoFluid = value; } } + /// + /// Constructs a new instance on top of the given . + /// + /// An instance. public BlockManager (IChunkManager cm) { chunkMan = cm; @@ -58,6 +71,15 @@ namespace Substrate chunkZLog = Log2(chunkZDim); } + /// + /// Returns a new object from global coordinates. + /// + /// Global X-coordinate of block. + /// Global Y-coordinate of block. + /// Global Z-coordiante of block. + /// A new object representing context-independent data of a single block. + /// Context-independent data excludes data such as lighting. object actually contain a copy + /// of the data they represent, so changes to the will not affect this container, and vice-versa. public AlphaBlock GetBlock (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -68,6 +90,16 @@ namespace Substrate return cache.Blocks.GetBlock(x & chunkXMask, y & chunkYMask, z & chunkZMask); } + /// + /// Returns a new object from global coordaintes. + /// + /// Global X-coordinate of block. + /// Global Y-coordinate of block. + /// Global Z-coordinate of block. + /// A new object representing context-dependent data of a single block. + /// Context-depdendent data includes all data associated with this block. Since a represents + /// a view of a block within this container, any updates to data in the container will be reflected in the , + /// and vice-versa for updates to the . public AlphaBlockRef GetBlockRef (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -78,6 +110,13 @@ namespace Substrate return cache.Blocks.GetBlockRef(x & chunkXMask, y & chunkYMask, z & chunkZMask); } + /// + /// Updates a block with values from a object. + /// + /// Global X-coordinate of a block. + /// Global Y-coordinate of a block. + /// Global Z-coordinate of a block. + /// A object to copy block data from. public void SetBlock (int x, int y, int z, AlphaBlock block) { cache = GetChunk(x, y, z); @@ -88,6 +127,13 @@ namespace Substrate cache.Blocks.SetBlock(x & chunkXMask, y & chunkYMask, z & chunkZMask, block); } + /// + /// Gets a reference object to a single chunk given global coordinates to a block within that chunk. + /// + /// Global X-coordinate of a block. + /// Global Y-coordinate of a block. + /// Global Z-coordinate of a block. + /// A to a single chunk containing the given block. protected ChunkRef GetChunk (int x, int y, int z) { x >>= chunkXLog; @@ -129,11 +175,13 @@ namespace Substrate return GetBlockRef(x, y, z); } + /// public void SetBlock (int x, int y, int z, IBlock block) { cache.Blocks.SetBlock(x, y, z, block); } + /// public BlockInfo GetInfo (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -144,6 +192,7 @@ namespace Substrate return cache.Blocks.GetInfo(x & chunkXMask, y & chunkYMask, z & chunkZMask); } + /// public int GetID (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -154,6 +203,7 @@ namespace Substrate return cache.Blocks.GetID(x & chunkXMask, y & chunkYMask, z & chunkZMask); } + /// public void SetID (int x, int y, int z, int id) { cache = GetChunk(x, y, z); @@ -188,11 +238,13 @@ namespace Substrate return GetBlockRef(x, y, z); } + /// public void SetBlock (int x, int y, int z, IDataBlock block) { cache.Blocks.SetBlock(x, y, z, block); } + /// public int GetData (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -203,6 +255,7 @@ namespace Substrate return cache.Blocks.GetData(x & chunkXMask, y & chunkYMask, z & chunkZMask); } + /// public void SetData (int x, int y, int z, int data) { cache = GetChunk(x, y, z); @@ -228,11 +281,13 @@ namespace Substrate return GetBlockRef(x, y, z); } + /// public void SetBlock (int x, int y, int z, ILitBlock block) { cache.Blocks.SetBlock(x, y, z, block); } + /// public int GetBlockLight (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -243,6 +298,7 @@ namespace Substrate return cache.Blocks.GetBlockLight(x & chunkXMask, y & chunkYMask, z & chunkZMask); } + /// public int GetSkyLight (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -253,6 +309,7 @@ namespace Substrate return cache.Blocks.GetSkyLight(x & chunkXMask, y & chunkYMask, z & chunkZMask); } + /// public void SetBlockLight (int x, int y, int z, int light) { cache = GetChunk(x, y, z); @@ -263,6 +320,7 @@ namespace Substrate cache.Blocks.SetBlockLight(x & chunkXMask, y & chunkYMask, z & chunkZMask, light); } + /// public void SetSkyLight (int x, int y, int z, int light) { cache = GetChunk(x, y, z); @@ -273,6 +331,7 @@ namespace Substrate cache.Blocks.SetSkyLight(x & chunkXMask, y & chunkYMask, z & chunkZMask, light); } + /// public int GetHeight (int x, int z) { cache = GetChunk(x, 0, z); @@ -283,6 +342,7 @@ namespace Substrate return cache.Blocks.GetHeight(x & chunkXMask, z & chunkZMask); } + /// public void SetHeight (int x, int z, int height) { cache = GetChunk(x, 0, z); @@ -293,6 +353,7 @@ namespace Substrate cache.Blocks.SetHeight(x & chunkXMask, z & chunkZMask, height); } + /// public void UpdateBlockLight (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -303,6 +364,7 @@ namespace Substrate cache.Blocks.UpdateBlockLight(x & chunkXMask, y & chunkYMask, z & chunkZMask); } + /// public void UpdateSkyLight (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -328,11 +390,13 @@ namespace Substrate return GetBlockRef(x, y, z); } + /// public void SetBlock (int x, int y, int z, IPropertyBlock block) { cache.Blocks.SetBlock(x, y, z, block); } + /// public TileEntity GetTileEntity (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -343,6 +407,7 @@ namespace Substrate return cache.Blocks.GetTileEntity(x & chunkXMask, y & chunkYMask, z & chunkZMask); } + /// public void SetTileEntity (int x, int y, int z, TileEntity te) { cache = GetChunk(x, y, z); @@ -353,6 +418,7 @@ namespace Substrate cache.Blocks.SetTileEntity(x & chunkXMask, y & chunkYMask, z & chunkZMask, te); } + /// public void CreateTileEntity (int x, int y, int z) { cache = GetChunk(x, y, z); @@ -363,6 +429,7 @@ namespace Substrate cache.Blocks.CreateTileEntity(x & chunkXMask, y & chunkYMask, z & chunkZMask); } + /// public void ClearTileEntity (int x, int y, int z) { cache = GetChunk(x, y, z); diff --git a/Substrate/SubstrateCS/Source/Core/ChunkFile.cs b/Substrate/SubstrateCS/Source/Core/ChunkFile.cs index 14bc642..06997dc 100644 --- a/Substrate/SubstrateCS/Source/Core/ChunkFile.cs +++ b/Substrate/SubstrateCS/Source/Core/ChunkFile.cs @@ -30,17 +30,17 @@ namespace Substrate.Core string dir1 = Base36.Encode(cx % 64); string dir2 = Base36.Encode(cz % 64); - _filename = Path.Combine(path, dir1); - if (!Directory.Exists(_filename)) { - Directory.CreateDirectory(_filename); + FileName = Path.Combine(path, dir1); + if (!Directory.Exists(FileName)) { + Directory.CreateDirectory(FileName); } - _filename = Path.Combine(_filename, dir2); - if (!Directory.Exists(_filename)) { - Directory.CreateDirectory(_filename); + FileName = Path.Combine(FileName, dir2); + if (!Directory.Exists(FileName)) { + Directory.CreateDirectory(FileName); } - _filename = Path.Combine(_filename, file); + FileName = Path.Combine(FileName, file); } } } diff --git a/Substrate/SubstrateCS/Source/Core/Interface.cs b/Substrate/SubstrateCS/Source/Core/Interface.cs index b4239b5..b40647f 100644 --- a/Substrate/SubstrateCS/Source/Core/Interface.cs +++ b/Substrate/SubstrateCS/Source/Core/Interface.cs @@ -4,8 +4,16 @@ using System.Text; namespace Substrate.Core { + /// + /// Provides a virtual deep copy capability to implementors. + /// + /// public interface ICopyable { + /// + /// Performs a virtual deep copy of the object instance. + /// + /// An independent copy of the object instance. T Copy (); } } diff --git a/Substrate/SubstrateCS/Source/Core/NBTFile.cs b/Substrate/SubstrateCS/Source/Core/NBTFile.cs index 4995a9d..58d5670 100644 --- a/Substrate/SubstrateCS/Source/Core/NBTFile.cs +++ b/Substrate/SubstrateCS/Source/Core/NBTFile.cs @@ -9,13 +9,19 @@ namespace Substrate.Core { public class NBTFile { - protected string _filename; + private string _filename; public NBTFile (string path) { _filename = path; } + public string FileName + { + get { return _filename; } + protected set { _filename = value; } + } + public bool Exists () { return File.Exists(_filename); diff --git a/Substrate/SubstrateCS/Source/Core/NibbleArray.cs b/Substrate/SubstrateCS/Source/Core/NibbleArray.cs index bc6fc92..aebc206 100644 --- a/Substrate/SubstrateCS/Source/Core/NibbleArray.cs +++ b/Substrate/SubstrateCS/Source/Core/NibbleArray.cs @@ -7,7 +7,7 @@ namespace Substrate.Core public class NibbleArray : ICopyable { - protected readonly byte[] _data = null; + private readonly byte[] _data = null; public NibbleArray (int length) { @@ -56,6 +56,11 @@ namespace Substrate.Core } } + protected byte[] Data + { + get { return _data; } + } + public void Clear () { for (int i = 0; i < _data.Length; i++) @@ -138,8 +143,8 @@ namespace Substrate.Core public override NibbleArray Copy () { - byte[] data = new byte[_data.Length]; - _data.CopyTo(data, 0); + byte[] data = new byte[Data.Length]; + Data.CopyTo(data, 0); return new XZYNibbleArray(_xdim, _ydim, _zdim, data); } diff --git a/Substrate/SubstrateCS/Source/Core/PlayerFile.cs b/Substrate/SubstrateCS/Source/Core/PlayerFile.cs index d80ff9c..8436abe 100644 --- a/Substrate/SubstrateCS/Source/Core/PlayerFile.cs +++ b/Substrate/SubstrateCS/Source/Core/PlayerFile.cs @@ -21,7 +21,7 @@ namespace Substrate.Core } string file = name + ".dat"; - _filename = Path.Combine(path, file); + FileName = Path.Combine(path, file); } } } diff --git a/Substrate/SubstrateCS/Source/ImportExport/Schematic.cs b/Substrate/SubstrateCS/Source/ImportExport/Schematic.cs index a87a27c..98ebd07 100644 --- a/Substrate/SubstrateCS/Source/ImportExport/Schematic.cs +++ b/Substrate/SubstrateCS/Source/ImportExport/Schematic.cs @@ -6,6 +6,9 @@ using Substrate.Nbt; namespace Substrate.ImportExport { + /// + /// Provides import and export support for the 3rd party schematic file format. + /// public class Schematic { private static SchemaNodeCompound _schema = new SchemaNodeCompound() @@ -36,12 +39,23 @@ namespace Substrate.ImportExport { } + /// + /// Create an exportable schematic wrapper around existing blocks and entities. + /// + /// An existing . + /// An existing . public Schematic (AlphaBlockCollection blocks, EntityCollection entities) { _blockset = blocks; _entityset = entities; } + /// + /// Create an empty, exportable schematic of given dimensions. + /// + /// The length of the X-dimension in blocks. + /// The length of the Y-dimension in blocks. + /// The length of the Z-dimension in blocks. public Schematic (int xdim, int ydim, int zdim) { _blocks = new XZYByteArray(xdim, ydim, zdim); @@ -59,12 +73,18 @@ namespace Substrate.ImportExport #region Properties + /// + /// Gets or sets the underlying block collection. + /// public AlphaBlockCollection Blocks { get { return _blockset; } set { _blockset = value; } } + /// + /// Gets or sets the underlying entity collection. + /// public EntityCollection Entities { get { return _entityset; } @@ -73,6 +93,11 @@ namespace Substrate.ImportExport #endregion + /// + /// Imports a schematic file at the given path and returns in as a object. + /// + /// The path to the schematic file. + /// A object containing the decoded schematic file data. public static Schematic Import (string path) { NBTFile schematicFile = new NBTFile(path); @@ -128,6 +153,10 @@ namespace Substrate.ImportExport return self; } + /// + /// Exports the object to a schematic file. + /// + /// The path to write out the schematic file to. public void Export (string path) { int xdim = _blockset.XDim; diff --git a/Substrate/SubstrateCS/Source/Nbt/NbtIOException.cs b/Substrate/SubstrateCS/Source/Nbt/NbtIOException.cs index ed62e31..2033148 100644 --- a/Substrate/SubstrateCS/Source/Nbt/NbtIOException.cs +++ b/Substrate/SubstrateCS/Source/Nbt/NbtIOException.cs @@ -6,7 +6,7 @@ namespace Substrate.Nbt /// /// The exception that is thrown when errors occur during Nbt IO operations. /// - /// In most cases, the property will contain more detailed information on the + /// In most cases, the property will contain more detailed information on the /// error that occurred. [Serializable] public class NbtIOException : SubstrateException diff --git a/Substrate/SubstrateCS/Source/Region.cs b/Substrate/SubstrateCS/Source/Region.cs index ff3512e..962830f 100644 --- a/Substrate/SubstrateCS/Source/Region.cs +++ b/Substrate/SubstrateCS/Source/Region.cs @@ -555,6 +555,9 @@ namespace Substrate return chunk.Save(GetChunkOutStream(ForeignX(chunk.X), ForeignZ(chunk.Z))); } + /// + /// Checks if this container supports delegating an action on out-of-bounds coordinates to another container. + /// public bool CanDelegateCoordinates { get { return true; }