Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

KoduCondition.h

Go to the documentation of this file.
00001 #ifndef KODU_CONDITION_H_
00002 #define KODU_CONDITION_H_
00003 
00004 // C++ Library
00005 #include <string>
00006 
00007 // Kodu Library
00008 #include "Kodu/Primitives/KoduPrimitive.h"
00009 
00010 #include "Kodu/General/KoduState.h"
00011 
00012 namespace Kodu {
00013 
00014     class KoduWorld;
00015 
00016     //! Kodu Condition (derived from Kodu Primitive)
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         //! Constructor
00031         KoduCondition(const std::string& kConditionName, ConditionTypes condType)
00032           : KoduPrimitive(kConditionName), conditionType(condType), state()
00033 
00034         { }
00035         
00036         //! Copy constructor
00037         KoduCondition(const KoduCondition& kCondition)
00038           : KoduPrimitive(kCondition),
00039           conditionType(kCondition.conditionType), state(kCondition.state)
00040         { }
00041 
00042         //! Destructor
00043         virtual ~KoduCondition() {
00044             // no explicit implementation
00045         }
00046 
00047         //! Assignment operator
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         //! Evaluates the event portion of the rule (implementation in derived classes)
00058         virtual bool evaluate(const KoduWorld&) = 0;
00059         
00060         bool canEvaluate() const {
00061             return KoduPrimitive::agentCanUsePrimitive();
00062         }
00063 
00064         //! Used to reinitialize certain variables during, for example, switching to another page
00065         virtual void reinitialize() {
00066             KoduPrimitive::reinitialize();
00067         }
00068 
00069         //! Returns the condition type
00070         ConditionTypes getConditionType() const {
00071             return conditionType;
00072         }
00073         
00074         //! Prints the attributes of a particular instance
00075         virtual void printAttrs() const {
00076             KoduPrimitive::printAttrs();
00077         }
00078         
00079         //Add a state give condition knowlege of state
00080         void setKoduState(const KoduState& curstate) {
00081           state = curstate;
00082         }
00083 
00084         const KoduState& getState() const { return state; }
00085 
00086     protected:
00087         ConditionTypes conditionType;       //!< the condition type
00088         KoduState state;
00089     };
00090 } // end of Kodu namespace
00091 
00092 #endif // KODU_CONDITION_H_

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:43 2016 by Doxygen 1.6.3