KoduCondition.h
Go to the documentation of this file.00001 #ifndef KODU_CONDITION_H_
00002 #define KODU_CONDITION_H_
00003
00004
00005 #include <string>
00006
00007
00008 #include "Kodu/Primitives/KoduPrimitive.h"
00009
00010 #include "Kodu/General/KoduState.h"
00011
00012 namespace Kodu {
00013
00014 class KoduWorld;
00015
00016
00017 class KoduCondition : public KoduPrimitive {
00018 public:
00019 enum ConditionTypes {
00020 CT_ALWAYS = 0,
00021 CT_BUMP,
00022 CT_GOT,
00023 CT_SCORED,
00024 CT_SEE,
00025 CT_TIMER,
00026 CT_GAMEPAD,
00027 CT_HEAR
00028 };
00029
00030
00031 KoduCondition(const std::string& kConditionName, ConditionTypes condType)
00032 : KoduPrimitive(kConditionName), conditionType(condType), state()
00033
00034 { }
00035
00036
00037 KoduCondition(const KoduCondition& kCondition)
00038 : KoduPrimitive(kCondition),
00039 conditionType(kCondition.conditionType), state(kCondition.state)
00040 { }
00041
00042
00043 virtual ~KoduCondition() {
00044
00045 }
00046
00047
00048 KoduCondition& operator=(const KoduCondition& kCondition) {
00049 if (this != &kCondition) {
00050 KoduPrimitive::operator=(kCondition);
00051 conditionType = kCondition.conditionType;
00052 state = kCondition.state;
00053 }
00054 return *this;
00055 }
00056
00057
00058 virtual bool evaluate(const KoduWorld&) = 0;
00059
00060 bool canEvaluate() const {
00061 return KoduPrimitive::agentCanUsePrimitive();
00062 }
00063
00064
00065 virtual void reinitialize() {
00066 KoduPrimitive::reinitialize();
00067 }
00068
00069
00070 ConditionTypes getConditionType() const {
00071 return conditionType;
00072 }
00073
00074
00075 virtual void printAttrs() const {
00076 KoduPrimitive::printAttrs();
00077 }
00078
00079
00080 void setKoduState(const KoduState& curstate) {
00081 state = curstate;
00082 }
00083
00084 const KoduState& getState() const { return state; }
00085
00086 protected:
00087 ConditionTypes conditionType;
00088 KoduState state;
00089 };
00090 }
00091
00092 #endif // KODU_CONDITION_H_