Make BlockColor.Index a property and other fixes
This commit is contained in:
parent
abbb83da26
commit
4701b3577d
2 changed files with 6 additions and 6 deletions
|
@ -7,7 +7,10 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
{
|
{
|
||||||
public BlockColors Color;
|
public BlockColors Color;
|
||||||
public byte Darkness;
|
public byte Darkness;
|
||||||
public byte Index;
|
|
||||||
|
public byte Index => Color == BlockColors.Default
|
||||||
|
? byte.MaxValue
|
||||||
|
: (byte) (Darkness * 10 + Color);
|
||||||
|
|
||||||
public BlockColor(byte index)
|
public BlockColor(byte index)
|
||||||
{
|
{
|
||||||
|
@ -23,8 +26,6 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
Color = (BlockColors) (index % 10);
|
Color = (BlockColors) (index % 10);
|
||||||
Darkness = (byte) (index / 10);
|
Darkness = (byte) (index / 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
Index = index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockColor(BlockColors color, byte darkness)
|
public BlockColor(BlockColors color, byte darkness)
|
||||||
|
@ -33,8 +34,6 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
throw new ArgumentOutOfRangeException(nameof(darkness), "Darkness must be 0-9 where 0 is default.");
|
throw new ArgumentOutOfRangeException(nameof(darkness), "Darkness must be 0-9 where 0 is default.");
|
||||||
Color = color;
|
Color = color;
|
||||||
Darkness = darkness;
|
Darkness = darkness;
|
||||||
if (color == BlockColors.Default) Index = byte.MaxValue;
|
|
||||||
else Index = (byte) (darkness * 10 + color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float4 RGBA => Block.BlockEngine.ConvertBlockColor(Index);
|
public float4 RGBA => Block.BlockEngine.ConvertBlockColor(Index);
|
||||||
|
|
|
@ -31,9 +31,9 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value == null) value = "";
|
||||||
BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) =>
|
BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) =>
|
||||||
{
|
{
|
||||||
if (val == null) val = "";
|
|
||||||
tbds.textCurrent.Set(val);
|
tbds.textCurrent.Set(val);
|
||||||
tbds.textStored.Set(val);
|
tbds.textStored.Set(val);
|
||||||
}, value);
|
}, value);
|
||||||
|
@ -51,6 +51,7 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value == null) value = "";
|
||||||
BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) =>
|
BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) =>
|
||||||
tbds.textBlockID.Set(val), value);
|
tbds.textBlockID.Set(val), value);
|
||||||
BlockEngine.SetBlockInfo(this,
|
BlockEngine.SetBlockInfo(this,
|
||||||
|
|
Loading…
Reference in a new issue