2011-04-06 04:43:54 +00:00
using System ;
2011-06-29 02:58:34 +00:00
namespace Substrate.Core
2011-04-06 04:43:54 +00:00
{
2011-05-13 03:09:57 +00:00
public enum BlockCollectionEdge
{
EAST = 0 ,
NORTH = 1 ,
WEST = 2 ,
SOUTH = 3
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// A basic block type.
/// </summary>
2011-04-06 04:43:54 +00:00
public interface IBlock
2011-04-08 02:16:06 +00:00
{
2011-07-07 04:27:48 +00:00
/// <summary>
/// Gets a variety of info and attributes on the block's type.
/// </summary>
2011-04-08 02:16:06 +00:00
BlockInfo Info { get ; }
2011-07-07 04:27:48 +00:00
/// <summary>
/// Gets or sets the block's id (type).
/// </summary>
2011-04-08 02:16:06 +00:00
int ID { get ; set ; }
2011-05-13 03:09:57 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// A block type supporting a data field.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface IDataBlock : IBlock
{
2011-07-07 04:27:48 +00:00
/// <summary>
/// Gets or sets a data value on the block.
/// </summary>
2011-04-08 02:16:06 +00:00
int Data { get ; set ; }
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// A block type supporting dual-source lighting.
/// </summary>
2011-04-08 02:16:06 +00:00
public interface ILitBlock : IBlock
{
2011-07-07 04:27:48 +00:00
/// <summary>
/// Gets or sets the block-source light value on this block.
/// </summary>
2011-04-08 02:16:06 +00:00
int BlockLight { get ; set ; }
2011-07-07 04:27:48 +00:00
/// <summary>
/// Gets or sets the sky-source light value on this block.
/// </summary>
2011-04-08 02:16:06 +00:00
int SkyLight { get ; set ; }
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// A block type supporting properties.
/// </summary>
2011-04-08 02:16:06 +00:00
public interface IPropertyBlock : IBlock
{
2011-07-07 04:27:48 +00:00
/// <summary>
/// Gets a tile entity attached to this block.
/// </summary>
/// <returns>A <see cref="TileEntity"/> for this block, or null if this block type does not support a tile entity.</returns>
2011-04-08 02:16:06 +00:00
TileEntity GetTileEntity ( ) ;
2011-07-07 04:27:48 +00:00
/// <summary>
/// Sets the tile entity attached to this block.
/// </summary>
/// <param name="te">A <see cref="TileEntity"/> supported by this block type.</param>
/// <exception cref="ArgumentException">Thrown when the <see cref="TileEntity"/> being passed is of the wrong type for the given block.</exception>
/// <exception cref="InvalidOperationException">Thrown when the given block is of a type that does not support a <see cref="TileEntity"/> record.</exception>
2011-05-13 03:09:57 +00:00
void SetTileEntity ( TileEntity te ) ;
2011-07-07 04:27:48 +00:00
/// <summary>
/// Creates a default tile entity for this block consistent with its type.
/// </summary>
/// <remarks>This method will overwrite any existing <see cref="TileEntity"/> attached to the block.</remarks>
/// <exception cref="InvalidOperationException">Thrown when the given block is of a type that does not support a <see cref="TileEntity"/> record.</exception>
/// <exception cref="UnknownTileEntityException">Thrown when the block type requests a <see cref="TileEntity"/> that has not been registered with the <see cref="TileEntityFactory"/>.</exception>
void CreateTileEntity ( ) ;
/// <summary>
/// Deletes the tile entity attached to this block if one exists.
/// </summary>
2011-05-13 03:09:57 +00:00
void ClearTileEntity ( ) ;
2011-04-08 02:16:06 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// An Alpha-compatible context-free block type supporting data and properties.
/// </summary>
2011-06-10 16:08:36 +00:00
public interface IAlphaBlock : IDataBlock , IPropertyBlock
{
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// An Alpha-compatible block reference type supporting data, lighting, and properties.
/// </summary>
2011-06-10 16:08:36 +00:00
public interface IAlphaBlockRef : IDataBlock , ILitBlock , IPropertyBlock
{
2011-07-07 04:27:48 +00:00
/// <summary>
/// Checks if the reference and its backing container are currently valid.
/// </summary>
2011-06-30 03:59:20 +00:00
bool IsValid { get ; }
2011-06-10 16:08:36 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// A basic unconstrained container of blocks.
/// </summary>
2011-07-09 01:36:13 +00:00
/// <remarks>The scope of coordinates is undefined for unconstrained block containers.</remarks>
2011-05-13 03:09:57 +00:00
public interface IBlockCollection
2011-04-08 02:16:06 +00:00
{
2011-07-07 04:27:48 +00:00
/// <summary>
/// Gets a basic block from a block container..
/// </summary>
2011-07-09 01:36:13 +00:00
/// <param name="x">The global X-coordinate of a block.</param>
/// <param name="y">The global Y-coordinate of a block.</param>
/// <param name="z">The global Z-coordinate of a block.</param>
2011-07-07 04:27:48 +00:00
/// <returns>A basic <see cref="IBlock"/> from the collection at the given coordinates.</returns>
2011-04-08 02:16:06 +00:00
IBlock GetBlock ( int x , int y , int z ) ;
2011-07-07 04:27:48 +00:00
/// <summary>
/// Gets a reference object to a basic within a block container.
/// </summary>
2011-07-09 01:36:13 +00:00
/// <param name="x">The global X-coordinate of a block.</param>
/// <param name="y">The global Y-coordinate of a block.</param>
/// <param name="z">The global Z-coordinate of a block.</param>
2011-07-07 04:27:48 +00:00
/// <returns>A basic <see cref="IBlock"/> acting as a reference directly into the container at the given coordinates.</returns>
2011-04-08 02:16:06 +00:00
IBlock GetBlockRef ( int x , int y , int z ) ;
2011-07-07 04:27:48 +00:00
/// <summary>
/// Updates a block in a block container with data from an existing <see cref="IBlock"/> object.
/// </summary>
2011-07-09 01:36:13 +00:00
/// <param name="x">The global X-coordinate of a block.</param>
/// <param name="y">The global Y-coordinate of a block.</param>
/// <param name="z">The global Z-coordinate of a block.</param>
2011-07-07 04:27:48 +00:00
/// <param name="block">The <see cref="IBlock"/> to copy basic data from.</param>
2011-04-08 02:16:06 +00:00
void SetBlock ( int x , int y , int z , IBlock block ) ;
2011-07-07 04:27:48 +00:00
/// <summary>
/// Gets a block's id (type) from a block container.
/// </summary>
2011-07-09 01:36:13 +00:00
/// <param name="x">The global X-coordinate of a block.</param>
/// <param name="y">The global Y-coordinate of a block.</param>
/// <param name="z">The global Z-coordinate of a block.</param>
2011-07-07 04:27:48 +00:00
/// <returns>The block id (type) from the block container at the given coordinates.</returns>
2011-05-13 03:21:53 +00:00
int GetID ( int x , int y , int z ) ;
2011-07-07 04:27:48 +00:00
/// <summary>
/// Sets a block's id (type) within a block container.
/// </summary>
2011-07-09 01:36:13 +00:00
/// <param name="x">The global X-coordinate of a block.</param>
/// <param name="y">The global Y-coordinate of a block.</param>
/// <param name="z">The global Z-coordinate of a block.</param>
2011-07-07 04:27:48 +00:00
/// <param name="id">The id (type) to assign to a block at the given coordinates.</param>
2011-05-13 03:21:53 +00:00
void SetID ( int x , int y , int z , int id ) ;
2011-04-08 02:16:06 +00:00
2011-07-07 04:27:48 +00:00
/// <summary>
/// Gets info and attributes on a block's type within a block container.
/// </summary>
2011-07-09 01:36:13 +00:00
/// <param name="x">The global X-coordinate of a block.</param>
/// <param name="y">The global Y-coordinate of a block.</param>
/// <param name="z">The global Z-coordinate of a block.</param>
2011-07-07 04:27:48 +00:00
/// <returns>A <see cref="BlockInfo"/> instance for the block's type.</returns>
2011-05-13 03:21:53 +00:00
BlockInfo GetInfo ( int x , int y , int z ) ;
2011-04-08 02:16:06 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// A container of blocks with set dimensions.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface IBoundedBlockCollection : IBlockCollection
2011-04-08 02:16:06 +00:00
{
2011-07-09 01:36:13 +00:00
/// <summary>
/// Gets the length of the X-dimension of the container.
/// </summary>
2011-04-08 02:16:06 +00:00
int XDim { get ; }
2011-07-09 01:36:13 +00:00
/// <summary>
/// Gets the length of the Y-dimension of the container.
/// </summary>
2011-04-08 02:16:06 +00:00
int YDim { get ; }
2011-07-09 01:36:13 +00:00
/// <summary>
/// Gets the length of the Z-dimension of the container.
/// </summary>
2011-04-08 02:16:06 +00:00
int ZDim { get ; }
2011-05-13 03:09:57 +00:00
2011-07-09 01:36:13 +00:00
/// <summary>
/// Counts all instances of a block with the given type in the container.
/// </summary>
/// <param name="id">The id (type) of the block to count.</param>
/// <returns>The count of blocks in the container matching the given id (type).</returns>
2011-05-13 03:21:53 +00:00
int CountByID ( int id ) ;
2011-07-09 01:36:13 +00:00
#region Local Overrides
/// <summary>
/// Gets a basic block from a block container..
/// </summary>
/// <param name="x">The container-local X-coordinate of a block.</param>
/// <param name="y">The container-local Y-coordinate of a block.</param>
/// <param name="z">The container-local Z-coordinate of a block.</param>
/// <returns>A basic <see cref="IBlock"/> from the collection at the given coordinates.</returns>
new IBlock GetBlock ( int x , int y , int z ) ;
/// <summary>
/// Gets a reference object to a basic within a block container.
/// </summary>
/// <param name="x">The container-local X-coordinate of a block.</param>
/// <param name="y">The container-local Y-coordinate of a block.</param>
/// <param name="z">The container-local Z-coordinate of a block.</param>
/// <returns>A basic <see cref="IBlock"/> acting as a reference directly into the container at the given coordinates.</returns>
new IBlock GetBlockRef ( int x , int y , int z ) ;
/// <summary>
/// Updates a block in a block container with data from an existing <see cref="IBlock"/> object.
/// </summary>
/// <param name="x">The container-local X-coordinate of a block.</param>
/// <param name="y">The container-local Y-coordinate of a block.</param>
/// <param name="z">The container-local Z-coordinate of a block.</param>
/// <param name="block">The <see cref="IBlock"/> to copy basic data from.</param>
new void SetBlock ( int x , int y , int z , IBlock block ) ;
/// <summary>
/// Gets a block's id (type) from a block container.
/// </summary>
/// <param name="x">The container-local X-coordinate of a block.</param>
/// <param name="y">The container-local Y-coordinate of a block.</param>
/// <param name="z">The container-local Z-coordinate of a block.</param>
/// <returns>The block id (type) from the block container at the given coordinates.</returns>
new int GetID ( int x , int y , int z ) ;
/// <summary>
/// Sets a block's id (type) within a block container.
/// </summary>
/// <param name="x">The container-local X-coordinate of a block.</param>
/// <param name="y">The container-local Y-coordinate of a block.</param>
/// <param name="z">The container-local Z-coordinate of a block.</param>
/// <param name="id">The id (type) to assign to a block at the given coordinates.</param>
new void SetID ( int x , int y , int z , int id ) ;
/// <summary>
/// Gets info and attributes on a block's type within a block container.
/// </summary>
/// <param name="x">The container-local X-coordinate of a block.</param>
/// <param name="y">The container-local Y-coordinate of a block.</param>
/// <param name="z">The container-local Z-coordinate of a block.</param>
/// <returns>A <see cref="BlockInfo"/> instance for the block's type.</returns>
new BlockInfo GetInfo ( int x , int y , int z ) ;
#endregion
2011-04-08 02:16:06 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// An unbounded container of blocks supporting data fields.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface IDataBlockCollection : IBlockCollection
2011-04-08 02:16:06 +00:00
{
2011-05-13 03:09:57 +00:00
new IDataBlock GetBlock ( int x , int y , int z ) ;
new IDataBlock GetBlockRef ( int x , int y , int z ) ;
void SetBlock ( int x , int y , int z , IDataBlock block ) ;
2011-05-13 03:21:53 +00:00
int GetData ( int x , int y , int z ) ;
void SetData ( int x , int y , int z , int data ) ;
2011-04-08 02:16:06 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// A bounded version of the <see cref="IDataBlockCollection"/> interface.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface IBoundedDataBlockCollection : IDataBlockCollection , IBoundedBlockCollection
{
2011-07-09 01:36:13 +00:00
new IDataBlock GetBlock ( int x , int y , int z ) ;
new IDataBlock GetBlockRef ( int x , int y , int z ) ;
new void SetBlock ( int x , int y , int z , IDataBlock block ) ;
new int GetData ( int x , int y , int z ) ;
new void SetData ( int x , int y , int z , int data ) ;
2011-05-13 03:21:53 +00:00
int CountByData ( int id , int data ) ;
2011-05-13 03:09:57 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// An unbounded container of blocks supporting dual-source lighting.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface ILitBlockCollection : IBlockCollection
2011-04-08 02:16:06 +00:00
{
new ILitBlock GetBlock ( int x , int y , int z ) ;
new ILitBlock GetBlockRef ( int x , int y , int z ) ;
void SetBlock ( int x , int y , int z , ILitBlock block ) ;
2011-05-13 03:09:57 +00:00
// Local Light
2011-04-08 02:16:06 +00:00
int GetBlockLight ( int x , int y , int z ) ;
2011-05-13 03:21:53 +00:00
int GetSkyLight ( int x , int y , int z ) ;
2011-04-08 02:16:06 +00:00
2011-05-13 03:09:57 +00:00
void SetBlockLight ( int x , int y , int z , int light ) ;
2011-05-13 03:21:53 +00:00
void SetSkyLight ( int x , int y , int z , int light ) ;
2011-05-13 03:09:57 +00:00
int GetHeight ( int x , int z ) ;
void SetHeight ( int x , int z , int height ) ;
// Update and propagate light at a single block
void UpdateBlockLight ( int x , int y , int z ) ;
2011-05-13 03:21:53 +00:00
void UpdateSkyLight ( int x , int y , int z ) ;
2011-05-13 03:09:57 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// A bounded version of the <see cref="ILitBlockCollection"/> interface.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface IBoundedLitBlockCollection : ILitBlockCollection , IBoundedBlockCollection
{
2011-07-09 01:36:13 +00:00
new ILitBlock GetBlock ( int x , int y , int z ) ;
new ILitBlock GetBlockRef ( int x , int y , int z ) ;
new void SetBlock ( int x , int y , int z , ILitBlock block ) ;
// Local Light
new int GetBlockLight ( int x , int y , int z ) ;
new int GetSkyLight ( int x , int y , int z ) ;
new void SetBlockLight ( int x , int y , int z , int light ) ;
new void SetSkyLight ( int x , int y , int z , int light ) ;
new int GetHeight ( int x , int z ) ;
new void SetHeight ( int x , int z , int height ) ;
// Update and propagate light at a single block
new void UpdateBlockLight ( int x , int y , int z ) ;
new void UpdateSkyLight ( int x , int y , int z ) ;
2011-05-13 03:09:57 +00:00
// Zero out light in entire collection
void ResetBlockLight ( ) ;
2011-05-13 03:21:53 +00:00
void ResetSkyLight ( ) ;
2011-05-13 03:09:57 +00:00
// Recalculate light in entire collection
void RebuildBlockLight ( ) ;
2011-05-13 03:21:53 +00:00
void RebuildSkyLight ( ) ;
2011-05-13 03:09:57 +00:00
void RebuildHeightMap ( ) ;
2011-04-19 01:24:26 +00:00
2011-05-13 03:09:57 +00:00
// Reconcile inconsistent lighting between the edges of two containers of same size
void StitchBlockLight ( ) ;
2011-05-13 03:21:53 +00:00
void StitchSkyLight ( ) ;
2011-04-19 01:24:26 +00:00
2011-05-13 03:09:57 +00:00
void StitchBlockLight ( IBoundedLitBlockCollection blockset , BlockCollectionEdge edge ) ;
2011-05-13 03:21:53 +00:00
void StitchSkyLight ( IBoundedLitBlockCollection blockset , BlockCollectionEdge edge ) ;
2011-04-08 02:16:06 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// An unbounded container for blocks supporting additional properties.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface IPropertyBlockCollection : IBlockCollection
2011-04-08 02:16:06 +00:00
{
new IPropertyBlock GetBlock ( int x , int y , int z ) ;
new IPropertyBlock GetBlockRef ( int x , int y , int z ) ;
void SetBlock ( int x , int y , int z , IPropertyBlock block ) ;
TileEntity GetTileEntity ( int x , int y , int z ) ;
2011-05-13 03:09:57 +00:00
void SetTileEntity ( int x , int y , int z , TileEntity te ) ;
void CreateTileEntity ( int x , int y , int z ) ;
void ClearTileEntity ( int x , int y , int z ) ;
2011-04-08 02:16:06 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// A bounded version of the <see cref="IPropertyBlockCollection"/> interface.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface IBoundedPropertyBlockCollection : IPropertyBlockCollection , IBoundedBlockCollection
{
2011-07-09 01:36:13 +00:00
new IPropertyBlock GetBlock ( int x , int y , int z ) ;
new IPropertyBlock GetBlockRef ( int x , int y , int z ) ;
new void SetBlock ( int x , int y , int z , IPropertyBlock block ) ;
new TileEntity GetTileEntity ( int x , int y , int z ) ;
new void SetTileEntity ( int x , int y , int z , TileEntity te ) ;
new void CreateTileEntity ( int x , int y , int z ) ;
new void ClearTileEntity ( int x , int y , int z ) ;
2011-05-13 03:09:57 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// An unbounded container of blocks supporting data, lighting, and properties.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface IAlphaBlockCollection : IDataBlockCollection , ILitBlockCollection , IPropertyBlockCollection
2011-04-08 02:16:06 +00:00
{
2011-06-30 03:59:20 +00:00
new AlphaBlock GetBlock ( int x , int y , int z ) ;
new AlphaBlockRef GetBlockRef ( int x , int y , int z ) ;
2011-05-13 03:09:57 +00:00
2011-06-30 03:59:20 +00:00
void SetBlock ( int x , int y , int z , AlphaBlock block ) ;
2011-05-13 03:09:57 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// A bounded version of the <see cref="IAlphaBlockCollection"/> interface.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface IBoundedAlphaBlockCollection : IAlphaBlockCollection , IBoundedDataBlockCollection , IBoundedLitBlockCollection , IBoundedPropertyBlockCollection
{
2011-07-09 01:36:13 +00:00
new AlphaBlock GetBlock ( int x , int y , int z ) ;
new AlphaBlockRef GetBlockRef ( int x , int y , int z ) ;
new void SetBlock ( int x , int y , int z , AlphaBlock block ) ;
2011-04-08 02:16:06 +00:00
}
2011-07-07 04:27:48 +00:00
/// <summary>
/// Provides a common interface for block containers that provide global management.
/// </summary>
2011-05-13 03:09:57 +00:00
public interface IBlockManager : IAlphaBlockCollection
2011-04-10 21:04:33 +00:00
{
2011-04-08 02:16:06 +00:00
}
2011-04-06 04:43:54 +00:00
}