diff options
| author | Jonas Ask | 2009-10-21 13:41:50 +0000 |
|---|---|---|
| committer | Jonas Ask | 2009-10-21 13:41:50 +0000 |
| commit | 81148ebf643ceec72fc23a7e5c03f4fa00d536f7 (patch) | |
| tree | 0ab588c0f9b2e87ed9224414b9fc7825b70413e4 /BlockCondition.cpp | |
| parent | cc640909fa812d19dcfdb11664f5a3223487a608 (diff) | |
| download | stonesense-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 'BlockCondition.cpp')
| -rw-r--r-- | BlockCondition.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/BlockCondition.cpp b/BlockCondition.cpp new file mode 100644 index 0000000..5cf2cb9 --- /dev/null +++ b/BlockCondition.cpp @@ -0,0 +1,46 @@ +#include "BlockCondition.h"
+#include "GameBuildings.h"
+#include "GUI.h"
+
+BlockCondition::BlockCondition(BlockConditionTypes type)
+{
+ this->type = type;
+ this->value = INVALID_INDEX;
+}
+
+
+
+bool BlockCondition::Matches(Block* b){
+ if(type == Cond_PositionIndex){
+ 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 == this->value;
+ }
+
+ if(type == Cond_MaterialType){
+ return b->building.material.type == this->value;
+ }
+
+ if(type == Cond_NeighbourWall){
+ dirTypes closebyWalls = findWallCloseTo(b->ownerSegment,b);
+
+ bool n = hasWall( b->ownerSegment->getBlock( b->x, b->y - 1, b->z ) );
+ bool s = hasWall( b->ownerSegment->getBlock( b->x, b->y + 1, b->z ) );
+ bool w = hasWall( b->ownerSegment->getBlock( b->x - 1, b->y, b->z ) );
+ bool e = hasWall( b->ownerSegment->getBlock( b->x + 1, b->y, b->z ) );
+
+ if( value == eSimpleN && n) return true;
+ if( value == eSimpleS && s) return true;
+ if( value == eSimpleW && w) return true;
+ if( value == eSimpleE && e) return true;
+
+ if( value == eSimpleSingle && !n && !s && !w && !e) return true;
+
+ return false;
+ }
+
+ return false;
+}
|
