summaryrefslogtreecommitdiff
path: root/BlockCondition.h
diff options
context:
space:
mode:
authorJapa2010-04-09 14:24:27 +0000
committerJapa2010-04-09 14:24:27 +0000
commit114df922d3073bd296b38cf522997f520fb17850 (patch)
treec4cf372825118c3663cd77e18c69a6c3b59d070f /BlockCondition.h
parent81aefc8e03ff3f647494012e18bcdc8f33f4de42 (diff)
downloadstonesense-114df922d3073bd296b38cf522997f520fb17850.tar.gz
stonesense-114df922d3073bd296b38cf522997f520fb17850.tar.bz2
stonesense-114df922d3073bd296b38cf522997f520fb17850.tar.xz
updated trunk to the new graphics engine, and the latest DFhack
Diffstat (limited to 'BlockCondition.h')
-rw-r--r--BlockCondition.h208
1 files changed, 208 insertions, 0 deletions
diff --git a/BlockCondition.h b/BlockCondition.h
new file mode 100644
index 0000000..8c7568d
--- /dev/null
+++ b/BlockCondition.h
@@ -0,0 +1,208 @@
+#pragma once
+#include "common.h"
+#include "Block.h"
+
+enum BlockConditionTypes{
+ Cond_MaterialType,
+ Cond_MaterialIndex,
+ Cond_NeighbourWall,
+ Cond_NeighbourSameBuilding,
+ Cond_PositionIndex,
+ Cond_NeighbourIdentical,
+ Cond_BuildingOcc,
+ Cond_NeighbourSameIndex,
+
+};
+
+// abstract base class
+class BlockCondition
+{
+public:
+ BlockCondition(){};
+ virtual ~BlockCondition(void){};
+
+ virtual bool Matches(Block* b) = 0;
+};
+
+class ConditionalNode
+{
+ public:
+ ConditionalNode(){};
+ virtual ~ConditionalNode(void){};
+
+ //false on failure
+ virtual bool addCondition(BlockCondition* cond) = 0;
+};
+
+//TODO: sort these (alpha order?)
+
+class NeighbourWallCondition : public BlockCondition
+{
+ public:
+ NeighbourWallCondition(const char* strValue);
+ ~NeighbourWallCondition(void){};
+
+ int value;
+ bool Matches(Block* b);
+};
+
+
+class PositionIndexCondition : public BlockCondition
+{
+ public:
+ PositionIndexCondition(const char* strValue);
+ ~PositionIndexCondition(void){};
+
+ int value;
+ bool Matches(Block* b);
+};
+
+
+class MaterialTypeCondition : public BlockCondition
+{
+ public:
+ MaterialTypeCondition(const char* strValue, const char* strSubtype);
+ ~MaterialTypeCondition(void){};
+
+ int value;
+ int subtype;
+ bool Matches(Block* b);
+};
+
+class AnimationFrameCondition : public BlockCondition
+{
+ public:
+ AnimationFrameCondition(const char* strValue);
+ ~AnimationFrameCondition(void){};
+
+ int value;
+ bool Matches(Block* b);
+};
+
+
+class BuildingOccupancyCondition : public BlockCondition
+{
+ public:
+ BuildingOccupancyCondition(const char* strValue);
+ ~BuildingOccupancyCondition(void){};
+
+ int value;
+ bool Matches(Block* b);
+};
+
+
+class NeighbourSameBuildingCondition : public BlockCondition
+{
+ public:
+ NeighbourSameBuildingCondition(const char* strValue);
+ ~NeighbourSameBuildingCondition(void){};
+
+ int value;
+ bool Matches(Block* b);
+};
+
+
+class NeighbourIdenticalCondition : public BlockCondition
+{
+ public:
+ NeighbourIdenticalCondition(const char* strValue);
+ ~NeighbourIdenticalCondition(void){};
+
+ int value;
+ bool Matches(Block* b);
+};
+
+
+class NeighbourOfTypeCondition : public BlockCondition
+{
+ public:
+ NeighbourOfTypeCondition(const char* strDir, const char* strValue);
+ ~NeighbourOfTypeCondition(void){};
+
+ int value;
+ int direction;
+ bool Matches(Block* b);
+};
+
+class NeighbourSameTypeCondition : public BlockCondition
+{
+ public:
+ NeighbourSameTypeCondition(const char* strDir);
+ ~NeighbourSameTypeCondition(void){};
+
+ int direction;
+ bool Matches(Block* b);
+};
+
+class AndConditionalNode : public BlockCondition, public ConditionalNode
+{
+ public:
+ AndConditionalNode(){};
+ ~AndConditionalNode(void);
+
+ vector<BlockCondition*> children;
+
+ bool Matches(Block* b);
+ bool addCondition(BlockCondition* cond);
+};
+
+class OrConditionalNode : public BlockCondition, public ConditionalNode
+{
+ public:
+ OrConditionalNode(){};
+ ~OrConditionalNode(void);
+
+ vector<BlockCondition*> children;
+
+ bool Matches(Block* b);
+ bool addCondition(BlockCondition* cond);
+};
+
+class AlwaysCondition : public BlockCondition
+{
+ public:
+ AlwaysCondition(){};
+ ~AlwaysCondition(void){};
+
+ bool Matches(Block* b);
+};
+
+class NeverCondition : public BlockCondition
+{
+ public:
+ NeverCondition(){};
+ ~NeverCondition(void){};
+
+ bool Matches(Block* b);
+};
+
+class NotConditionalNode : public BlockCondition, public ConditionalNode
+{
+ public:
+ NotConditionalNode();
+ ~NotConditionalNode(void);
+ BlockCondition* childcond;
+
+ bool Matches(Block* b);
+ bool addCondition(BlockCondition* cond);
+};
+
+class HaveFloorCondition : public BlockCondition
+{
+ public:
+ HaveFloorCondition(){};
+ ~HaveFloorCondition(void){};
+
+ bool Matches(Block* b);
+};
+
+class FluidBelowCondition : public BlockCondition
+{
+ public:
+ FluidBelowCondition(const char* strValue);
+ ~FluidBelowCondition(void){};
+
+ int value;
+ bool Matches(Block* b);
+};
+