summaryrefslogtreecommitdiff
path: root/ConditionalSprite.cpp
diff options
context:
space:
mode:
authorJonas Ask2009-10-21 13:41:50 +0000
committerJonas Ask2009-10-21 13:41:50 +0000
commit81148ebf643ceec72fc23a7e5c03f4fa00d536f7 (patch)
tree0ab588c0f9b2e87ed9224414b9fc7825b70413e4 /ConditionalSprite.cpp
parentcc640909fa812d19dcfdb11664f5a3223487a608 (diff)
downloadstonesense-81148ebf643ceec72fc23a7e5c03f4fa00d536f7.tar.gz
stonesense-81148ebf643ceec72fc23a7e5c03f4fa00d536f7.tar.bz2
stonesense-81148ebf643ceec72fc23a7e5c03f4fa00d536f7.tar.xz
Building sprite conditions are now stackable. This means any sprite can have any number of conditions assigned
Diffstat (limited to 'ConditionalSprite.cpp')
-rw-r--r--ConditionalSprite.cpp35
1 files changed, 4 insertions, 31 deletions
diff --git a/ConditionalSprite.cpp b/ConditionalSprite.cpp
index 7fe6eae..64e033e 100644
--- a/ConditionalSprite.cpp
+++ b/ConditionalSprite.cpp
@@ -7,42 +7,15 @@
ConditionalSprite::ConditionalSprite(void)
{
memset(this, 0, sizeof(ConditionalSprite));
- //
- cMaterialType = INVALID_INDEX;
- cMaterialIndex = 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::matchMaterialType(Block *b){
- return b->building.material.type == cMaterialType;
-}
-
-
-bool ConditionalSprite::matchNeighbourHasWall(Block *b){
- dirTypes closebyWalls = findWallCloseTo(b->ownerSegment,b);
-
- return closebyWalls == cNeighbourHasWall;
-}
bool ConditionalSprite::BlockMatches(Block* b){
bool okSoFar = true;
- if(cMaterialType != INVALID_INDEX){
- if( !this->matchMaterialType(b) ) okSoFar = false;
- }
- if(cPositionIndex != INVALID_INDEX){
- if( !this->matchPosition(b) ) okSoFar = false;
- }
- if(cNeighbourHasWall != INVALID_INDEX){
- if( !this->matchNeighbourHasWall(b) ) okSoFar = false;
+
+ for(uint32_t i=0; i<conditions.size(); i++){
+ okSoFar &= conditions[i].Matches( b );
}
+
return okSoFar;
} \ No newline at end of file