Small bit of Anvil support.

This commit is contained in:
Justin Aquadro 2012-02-21 00:57:19 -05:00
parent 33e8cf2174
commit d9832544ce

View file

@ -151,4 +151,73 @@ namespace Substrate.Core
#endregion
}
public sealed class YZXNibbleArray : NibbleArray
{
private readonly int _xdim;
private readonly int _ydim;
private readonly int _zdim;
public YZXNibbleArray (int xdim, int ydim, int zdim)
: base(xdim * ydim * zdim)
{
_xdim = xdim;
_ydim = ydim;
_zdim = zdim;
}
public YZXNibbleArray (int xdim, int ydim, int zdim, byte[] data)
: base(data)
{
_xdim = xdim;
_ydim = ydim;
_zdim = zdim;
if (xdim * ydim * zdim != data.Length * 2) {
throw new ArgumentException("Product of dimensions must equal half length of raw data");
}
}
public byte this[int x, int y, int z]
{
get
{
int index = _xdim * (y * _zdim + z) + x;
return this[index];
}
set
{
int index = _xdim * (y * _zdim + z) + x;
this[index] = value;
}
}
public int XDim
{
get { return _xdim; }
}
public int YDim
{
get { return _ydim; }
}
public int ZDim
{
get { return _zdim; }
}
#region ICopyable<NibbleArray> Members
public override NibbleArray Copy ()
{
byte[] data = new byte[Data.Length];
Data.CopyTo(data, 0);
return new YZXNibbleArray(_xdim, _ydim, _zdim, data);
}
#endregion
}
}