From 314884d9bbd5ec1edf0ec473a1c29b493964f955 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 21 Nov 2013 22:44:18 +0000 Subject: Multiple enhancements [SEE DESC] + Added lever location checking * Fixed button location checking * Fixed button pressing/unpressing * Fixed repeaters updating * Minor enhancements --- source/Simulator/RedstoneSimulator.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'source/Simulator/RedstoneSimulator.h') diff --git a/source/Simulator/RedstoneSimulator.h b/source/Simulator/RedstoneSimulator.h index ab88f51e2..10d87505c 100644 --- a/source/Simulator/RedstoneSimulator.h +++ b/source/Simulator/RedstoneSimulator.h @@ -106,7 +106,7 @@ private: ///Marks all blocks immediately surrounding a coordinate as powered void SetAllDirsAsPowered(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_SourceBlock); - ///Returns if a coordiante is powered or linked powered + ///Returns if a coordinate is powered or linked powered bool AreCoordsPowered(int a_BlockX, int a_BlockY, int a_BlockZ); ///Returns if a repeater is powered bool IsRepeaterPowered(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta); @@ -117,6 +117,29 @@ private: bool IsButtonOn(NIBBLETYPE a_BlockMeta); /* ============================== */ + /* ====== Misc Functions ====== */ + + ///Returns if a block is viable to be the MiddleBlock of a SetLinkedPowered operation + inline static bool IsViableMiddleBlock(BLOCKTYPE Block) + { + if (!g_BlockIsSolid[Block]) { return false; } + + switch (Block) + { + // Add SOLID but not viable middle blocks here + case E_BLOCK_REDSTONE_REPEATER_ON: + case E_BLOCK_REDSTONE_REPEATER_OFF: + { + return false; + } + default: + { + return true; + } + } + } + + ///Returns if a block is a mechanism (something that accepts power and does something) inline static bool IsMechanism(BLOCKTYPE Block) { switch (Block) @@ -145,6 +168,7 @@ private: } } + ///Returns if a block has the potential to output power inline static bool IsPotentialSource(BLOCKTYPE Block) { switch (Block) @@ -167,6 +191,7 @@ private: } } + ///Returns if a block is any sort of redstone device inline static bool IsRedstone(BLOCKTYPE Block) { switch (Block) -- cgit v1.2.3