00001 00006 00007 #ifndef __KX_RANDOMSENSOR 00008 #define __KX_RANDOMSENSOR 00009 00010 #include "SCA_ISensor.h" 00011 #include "BoolValue.h" 00012 #include "SCA_RandomNumberGenerator.h" 00013 00014 class SCA_RandomSensor : public SCA_ISensor 00015 { 00016 Py_Header; 00017 00018 unsigned int m_currentDraw; 00019 int m_iteration; 00020 SCA_RandomNumberGenerator *m_basegenerator; 00021 bool m_lastdraw; 00022 public: 00023 SCA_RandomSensor(class SCA_EventManager* rndmgr, 00024 SCA_IObject* gameobj, 00025 int startseed, 00026 PyTypeObject* T=&Type); 00027 virtual ~SCA_RandomSensor(); 00028 virtual CValue* GetReplica() { 00029 CValue* replica = new SCA_RandomSensor(*this); 00030 // this will copy properties and so on... 00031 CValue::AddDataToReplica(replica); 00032 return replica; 00033 }; 00034 virtual bool Evaluate(CValue* event); 00035 virtual bool IsPositiveTrigger() { 00036 return (m_invert !=m_lastdraw); 00037 00038 } 00039 00040 /* --------------------------------------------------------------------- */ 00041 /* Python interface ---------------------------------------------------- */ 00042 /* --------------------------------------------------------------------- */ 00043 00044 virtual PyObject* _getattr(char *attr); 00045 00046 /* 1. setSeed */ 00047 KX_PYMETHOD_DOC(SCA_RandomSensor,SetSeed); 00048 /* 2. getSeed */ 00049 KX_PYMETHOD_DOC(SCA_RandomSensor,GetSeed); 00050 /* 3. getSeed */ 00051 KX_PYMETHOD_DOC(SCA_RandomSensor,GetLastDraw); 00052 00053 }; 00054 00055 #endif //__KX_RANDOMSENSOR