JK2eA
 All Classes Functions Variables
Controller.h
00001 #pragma once
00002 
00003 #include <string>
00004 #include "Observable.h"
00005 
00006 #define CNTRL_CLASS_NAME(name) \
00007         virtual const char *GetCntrlType() { return #name; }
00008 #define CNTRL_SKIP_UPDATE() \
00009         if(m_eState == CLS_FINISHED || m_eState == CLS_WAITING) return; \
00010         if(m_eState == CLS_SLEEPING) {m_fLocalTime += dt; return;}
00011 
00012 
00017 //TODO muze byt zleva i zprava, zatim se neresi
00018 enum CONTRL_ORT {
00019         ORT_CONSTANT = 1,       
00020         ORT_LOOP         = 5,   
00021         ORT_RANDOM       = 10,  
00022         ORT_FINISH       = 15   
00023 };
00024 
00028 enum CONTRL_STATE {
00029         CLS_SLEEPING = 1,  
00030         CLS_ACTIVE       = 5,  
00031         CLS_WAITING      = 10, 
00032         CLS_FINISHED = 15  
00033 };
00034 
00035 
00045 class CController {
00046         friend class CControllerManager;
00047 protected:
00048         float            m_fLocalTime;  
00049         float            m_fTimeScale;  
00050         CONTRL_ORT       m_eORT;                
00051         CONTRL_STATE m_eState;          
00052         std::string      m_sName;               
00053         bool             m_bPassive;    
00054 
00055 public:
00056         CObservable      m_observable;  
00057 
00062         CController(const std::string& name);
00066         virtual ~CController();
00071         virtual void Update(float dt) = 0;
00072 
00077         virtual inline void  SetTimeScale(const float fTimeScale) { m_fTimeScale = fTimeScale; }
00082         virtual inline void  SetORT(CONTRL_ORT ort) { m_eORT = ort; }
00087         virtual void             Reset(const bool activate = false) { m_fLocalTime = 0.0f; if(activate) m_eState = CLS_ACTIVE; }
00092         inline CONTRL_STATE  GetState() { return m_eState; }
00097         inline void                      SetState(CONTRL_STATE state) { m_eState = state; } 
00098         
00103         inline void                     SetPassive(bool state) { m_bPassive = state; }
00104 
00109         CNTRL_CLASS_NAME(CController)
00110 };
00111