using System;
namespace Substrate.Core
{
public enum BlockCollectionEdge
{
EAST = 0,
NORTH = 1,
WEST = 2,
SOUTH = 3
}
///
/// A basic block type.
///
public interface IBlock
{
///
/// Gets a variety of info and attributes on the block's type.
///
BlockInfo Info { get; }
///
/// Gets or sets the block's id (type).
///
int ID { get; set; }
}
///
/// A block type supporting a data field.
///
public interface IDataBlock : IBlock
{
///
/// Gets or sets a data value on the block.
///
int Data { get; set; }
}
///
/// A block type supporting dual-source lighting.
///
public interface ILitBlock : IBlock
{
///
/// Gets or sets the block-source light value on this block.
///
int BlockLight { get; set; }
///
/// Gets or sets the sky-source light value on this block.
///
int SkyLight { get; set; }
}
///
/// A block type supporting properties.
///
public interface IPropertyBlock : IBlock
{
///
/// Gets a tile entity attached to this block.
///
/// A for this block, or null if this block type does not support a tile entity.
TileEntity GetTileEntity ();
///
/// Sets the tile entity attached to this block.
///
/// A supported by this block type.
/// Thrown when the being passed is of the wrong type for the given block.
/// Thrown when the given block is of a type that does not support a record.
void SetTileEntity (TileEntity te);
///
/// Creates a default tile entity for this block consistent with its type.
///
/// This method will overwrite any existing attached to the block.
/// Thrown when the given block is of a type that does not support a record.
/// Thrown when the block type requests a that has not been registered with the .
void CreateTileEntity ();
///
/// Deletes the tile entity attached to this block if one exists.
///
void ClearTileEntity ();
}
///
/// An Alpha-compatible context-free block type supporting data and properties.
///
public interface IAlphaBlock : IDataBlock, IPropertyBlock
{
}
///
/// An Alpha-compatible block reference type supporting data, lighting, and properties.
///
public interface IAlphaBlockRef : IDataBlock, ILitBlock, IPropertyBlock
{
///
/// Checks if the reference and its backing container are currently valid.
///
bool IsValid { get; }
}
///
/// A basic unconstrained container of blocks.
///
public interface IBlockCollection
{
///
/// Gets a basic block from a block container..
///
/// The X-coordinate of a block.
/// The Y-coordinate of a block.
/// The Z-coordinate of a block.
/// A basic from the collection at the given coordinates.
IBlock GetBlock (int x, int y, int z);
///
/// Gets a reference object to a basic within a block container.
///
/// The X-coordinate of a block.
/// The Y-coordinate of a block.
/// The Z-coordinate of a block.
/// A basic acting as a reference directly into the container at the given coordinates.
IBlock GetBlockRef (int x, int y, int z);
///
/// Updates a block in a block container with data from an existing object.
///
/// The X-coordinate of a block.
/// The Y-coordinate of a block.
/// The Z-coordinate of a block.
/// The to copy basic data from.
void SetBlock (int x, int y, int z, IBlock block);
///
/// Gets a block's id (type) from a block container.
///
/// The X-coordinate of a block.
/// The Y-coordinate of a block.
/// The Z-coordinate of a block.
/// The block id (type) from the block container at the given coordinates.
int GetID (int x, int y, int z);
///
/// Sets a block's id (type) within a block container.
///
/// The X-coordinate of a block.
/// The Y-coordinate of a block.
/// The Z-coordinate of a block.
/// The id (type) to assign to a block at the given coordinates.
void SetID (int x, int y, int z, int id);
///
/// Gets info and attributes on a block's type within a block container.
///
/// The X-coordinate of a block.
/// The Y-coordinate of a block.
/// The Z-coordinate of a block.
/// A instance for the block's type.
BlockInfo GetInfo (int x, int y, int z);
}
///
/// A container of blocks with set dimensions.
///
public interface IBoundedBlockCollection : IBlockCollection
{
int XDim { get; }
int YDim { get; }
int ZDim { get; }
int CountByID (int id);
}
///
/// An unbounded container of blocks supporting data fields.
///
public interface IDataBlockCollection : IBlockCollection
{
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);
int GetData (int x, int y, int z);
void SetData (int x, int y, int z, int data);
}
///
/// A bounded version of the interface.
///
public interface IBoundedDataBlockCollection : IDataBlockCollection, IBoundedBlockCollection
{
int CountByData (int id, int data);
}
///
/// An unbounded container of blocks supporting dual-source lighting.
///
public interface ILitBlockCollection : IBlockCollection
{
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);
// Local Light
int GetBlockLight (int x, int y, int z);
int GetSkyLight (int x, int y, int z);
void SetBlockLight (int x, int y, int z, int light);
void SetSkyLight (int x, int y, int z, int light);
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);
void UpdateSkyLight (int x, int y, int z);
}
///
/// A bounded version of the interface.
///
public interface IBoundedLitBlockCollection : ILitBlockCollection, IBoundedBlockCollection
{
// Zero out light in entire collection
void ResetBlockLight ();
void ResetSkyLight ();
// Recalculate light in entire collection
void RebuildBlockLight ();
void RebuildSkyLight ();
void RebuildHeightMap ();
// Reconcile inconsistent lighting between the edges of two containers of same size
void StitchBlockLight ();
void StitchSkyLight ();
void StitchBlockLight (IBoundedLitBlockCollection blockset, BlockCollectionEdge edge);
void StitchSkyLight (IBoundedLitBlockCollection blockset, BlockCollectionEdge edge);
}
///
/// An unbounded container for blocks supporting additional properties.
///
public interface IPropertyBlockCollection : IBlockCollection
{
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);
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);
}
///
/// A bounded version of the interface.
///
public interface IBoundedPropertyBlockCollection : IPropertyBlockCollection, IBoundedBlockCollection
{
}
///
/// An unbounded container of blocks supporting data, lighting, and properties.
///
public interface IAlphaBlockCollection : IDataBlockCollection, ILitBlockCollection, IPropertyBlockCollection
{
new AlphaBlock GetBlock (int x, int y, int z);
new AlphaBlockRef GetBlockRef (int x, int y, int z);
void SetBlock (int x, int y, int z, AlphaBlock block);
}
///
/// A bounded version of the interface.
///
public interface IBoundedAlphaBlockCollection : IAlphaBlockCollection, IBoundedDataBlockCollection, IBoundedLitBlockCollection, IBoundedPropertyBlockCollection
{
}
///
/// Provides a common interface for block containers that provide global management.
///
public interface IBlockManager : IAlphaBlockCollection
{
}
}