summaryrefslogtreecommitdiff
path: root/ConditionalSprite.cpp
diff options
context:
space:
mode:
authorJonas Ask2009-10-20 19:20:35 +0000
committerJonas Ask2009-10-20 19:20:35 +0000
commite4614f535d4be2d015144a6bb2fe57bfdedd7b16 (patch)
treec7bcd6f78bc1e11a490d4e7d38bda895aac80037 /ConditionalSprite.cpp
parent2489644b5df063a2471f6b7a76a5212f4af60f71 (diff)
downloadstonesense-e4614f535d4be2d015144a6bb2fe57bfdedd7b16.tar.gz
stonesense-e4614f535d4be2d015144a6bb2fe57bfdedd7b16.tar.bz2
stonesense-e4614f535d4be2d015144a6bb2fe57bfdedd7b16.tar.xz
Started work on XML building configurations.
Diffstat (limited to 'ConditionalSprite.cpp')
-rw-r--r--ConditionalSprite.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/ConditionalSprite.cpp b/ConditionalSprite.cpp
new file mode 100644
index 0000000..346d13d
--- /dev/null
+++ b/ConditionalSprite.cpp
@@ -0,0 +1,49 @@
+#include "common.h"
+#include "ConditionalSprite.h"
+#include "Block.h"
+#include "GameBuildings.h"
+
+
+ConditionalSprite::ConditionalSprite(void)
+{
+ memset(this, 0, sizeof(ConditionalSprite));
+ //
+ cMaterial = INVALID_INDEX;
+ cPositionIndex = INVALID_INDEX;
+ cNeighbourHasWall = eSimpleInvalid;
+}
+
+bool ConditionalSprite::matchPosition(Block *b){
+ int x = b->x - b->building.x1;
+ int y = b->y - b->building.y1;
+ int w = b->building.x2 - b->building.x1 + 1 ;
+ int pos = y * w + x;
+
+ return pos == cPositionIndex;
+}
+
+bool ConditionalSprite::matchMaterial(Block *b){
+ bool material = false;
+ material = b->building.material.index == cMaterial;
+ return true;
+}
+
+
+bool ConditionalSprite::matchNeighbourHasWall(Block *b){
+ dirTypes closebyWalls = findWallCloseTo(b->ownerSegment,b);
+
+ return closebyWalls == cNeighbourHasWall;
+}
+bool ConditionalSprite::BlockMatches(Block* b){
+ bool okSoFar = true;
+ if(cMaterial != INVALID_INDEX){
+ if( !this->matchMaterial(b) ) okSoFar = false;
+ }
+ if(cPositionIndex != INVALID_INDEX){
+ if( !this->matchPosition(b) ) okSoFar = false;
+ }
+ if(cNeighbourHasWall != INVALID_INDEX){
+ if( !this->matchNeighbourHasWall(b) ) okSoFar = false;
+ }
+ return okSoFar;
+} \ No newline at end of file