Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

KoduAction.h

Go to the documentation of this file.
00001 #ifndef KODU_ACTION_H_
00002 #define KODU_ACTION_H_
00003 
00004 // C++ Library
00005 #include <iostream>
00006 #include <string>
00007 
00008 // Kodu Library
00009 #include "Kodu/Primitives/KoduPrimitive.h"
00010 #include "Kodu/General/GeneralMacros.h"
00011 
00012 // KoduState
00013 #include "Kodu/General/KoduState.h"
00014 
00015 namespace Kodu {
00016         
00017   //! Kodu Action (derived from Kodu Behavior)
00018   class KoduAction : public KoduPrimitive {
00019   public:
00020     //! The different action types
00021     enum ActionTypes {
00022       AT_DO_NOTHING = 0,
00023       AT_DROP,
00024       AT_GRAB,
00025       AT_GIVE,
00026       AT_MOTION,
00027       AT_PAGE_SWITCH,
00028       AT_PLAY,
00029       AT_SAY,
00030       AT_SCORING
00031     };
00032 
00033     //! Constructor
00034     KoduAction(const std::string& kActionName, ActionTypes actType, bool actionCanUseOnceMod, bool runOnce) :
00035       KoduPrimitive(kActionName), actionType(actType), onceModEnabled(actionCanUseOnceMod && runOnce), state()
00036       { }
00037         
00038     //! Copy constructor
00039     explicit KoduAction(const KoduAction& kAction) : KoduPrimitive(kAction),
00040       actionType(kAction.actionType), onceModEnabled(kAction.onceModEnabled), state(kAction.state)
00041       { }
00042 
00043     //! Destructor
00044     virtual ~KoduAction () {}
00045    // no explicit implementation
00046         
00047   //! Assignment operator
00048   KoduAction& operator=(const KoduAction& kAction) {
00049     if (this != &kAction) {
00050       KoduPrimitive::operator=(kAction);
00051       actionType = kAction.actionType;
00052       onceModEnabled = kAction.onceModEnabled;
00053       state = kAction.state;
00054     }
00055     return *this;
00056   }
00057 
00058   //! Returns whether or not the action can ran
00059   bool canRun() const {
00060     return KoduPrimitive::agentCanUsePrimitive();
00061   }
00062 
00063   //! Checks if the once modifier is enabled
00064   bool onceModIsEnabled() const {
00065     return onceModEnabled;
00066   }
00067 
00068   //! Used to reinitialize certain variables (e.g. when switching to another page)
00069   virtual void reinitialize() {
00070     KoduPrimitive::reinitialize();
00071   }
00072   /*
00073   //! Sets the action can run variable
00074   void setActionCanRun(bool bVal) {
00075   actionCanRun = bVal;
00076   }
00077   */
00078   //! Returns the action type
00079   ActionTypes getActionType() const { return actionType; }
00080 
00081   //! Prints the attributes for a particular behavior
00082   virtual void printAttrs() const {
00083     KoduPrimitive::printAttrs();
00084     PRINT_ATTRS("Once modifier enabled", onceModEnabled);
00085   }
00086         
00087   void setKoduState(const KoduState& curstate){
00088     state = curstate;
00089   }
00090  
00091  private:
00092   ActionTypes actionType; //!< states the action type
00093   bool onceModEnabled;    //!< states if the once modifier is enabled (depends on action type too)
00094   KoduState state;
00095 };
00096 
00097 } // end of Kodu namespace
00098 
00099 #endif // end of KODU_ACTION_H_

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