Skip to content

Commit

Permalink
#93: Added Block.IsWaterProof property
Browse files Browse the repository at this point in the history
Defines whether the block should stop the liquid flow
  • Loading branch information
taugit committed Nov 11, 2011
1 parent 67059be commit a0c7e19
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Chraft/World/Blocks/Base/BlockBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ public bool IsIgnitable
/// </summary>
public byte Luminance { get; protected set; }

public bool IsWaterProof { get; protected set; }

public List<ItemStack> LootTable { get; protected set; }

/// <summary>
Expand All @@ -168,6 +170,7 @@ protected BlockBase()
BurnEfficiency = 0;
LootTable = new List<ItemStack>();
Luminance = 0;
IsWaterProof = false;
BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 1, 1);
}

Expand Down
14 changes: 14 additions & 0 deletions Chraft/World/Blocks/BlockHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static class BlockHelper
private static ConcurrentDictionary<byte, byte> _blocksOpacity;
private static ConcurrentDictionary<byte, byte> _blocksLuminance;
private static ConcurrentDictionary<byte, short> _blocksBurnEfficiency;
private static ConcurrentDictionary<byte, byte> _waterProofBlocks;

static BlockHelper()
{
Expand All @@ -56,6 +57,7 @@ private static void Init()
_blocksOpacity = new ConcurrentDictionary<byte, byte>();
_blocksLuminance = new ConcurrentDictionary<byte, byte>();
_blocksBurnEfficiency = new ConcurrentDictionary<byte, short>();
_waterProofBlocks = new ConcurrentDictionary<byte, byte>();

BlockBase block;
byte blockId;
Expand All @@ -80,6 +82,8 @@ where t.GetInterfaces().Contains(typeof(IBlockBase)) && !t.IsAbstract
_solidBlocks.TryAdd(blockId, blockId);
if (block.IsSingleHit)
_singleHitBlocks.TryAdd(blockId, blockId);
if (block.IsWaterProof)
_waterProofBlocks.TryAdd(blockId, blockId);
_blocksOpacity.TryAdd(blockId, block.Opacity);
_blocksLuminance.TryAdd(blockId, block.Luminance);
_blocksBurnEfficiency.TryAdd(blockId, block.BurnEfficiency);
Expand Down Expand Up @@ -239,5 +243,15 @@ public static short BurnEfficiency(BlockData.Blocks blockType)
_blocksBurnEfficiency.TryGetValue((byte)blockType, out burnEfficiency);
return burnEfficiency;
}

public static bool IsWaterProof(byte blockId)
{
return _waterProofBlocks.ContainsKey(blockId);
}

public static bool IsWaterProof(BlockData.Blocks blockType)
{
return _waterProofBlocks.ContainsKey((byte)blockType);
}
}
}
1 change: 1 addition & 0 deletions Chraft/World/Blocks/BlockIronDoor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public BlockIronDoor()
{
Name = "IronDoor";
Type = BlockData.Blocks.Iron_Door;
IsWaterProof = true;
}
}
}
1 change: 1 addition & 0 deletions Chraft/World/Blocks/BlockLadder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public BlockLadder()
Name = "Ladder";
Type = BlockData.Blocks.Ladder;
IsAir = true;
IsWaterProof = true;
LootTable.Add(new ItemStack((short)Type, 1));
Opacity = 0x0;
}
Expand Down
1 change: 1 addition & 0 deletions Chraft/World/Blocks/BlockReed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public BlockReed()
IsAir = true;
IsSolid = true;
IsSingleHit = true;
IsWaterProof = true;
LootTable.Add(new ItemStack((short)BlockData.Items.Reeds, 1));
BlockBoundsOffset = new BoundingBox(0.125, 0, 0.125, 0.875, 1, 0.875);
}
Expand Down
1 change: 1 addition & 0 deletions Chraft/World/Blocks/BlockSignPost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public BlockSignPost()
Type = BlockData.Blocks.Sign_Post;
IsAir = true;
IsSolid = true;
IsWaterProof = true;
LootTable.Add(new ItemStack((short)BlockData.Items.Sign, 1));
Opacity = 0x0;
}
Expand Down
1 change: 1 addition & 0 deletions Chraft/World/Blocks/BlockWoodenDoor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public BlockWoodenDoor()
{
Name = "WoodenDoor";
Type = BlockData.Blocks.Wooden_Door;
IsWaterProof = true;
}
}
}

0 comments on commit a0c7e19

Please sign in to comment.