00001
00006
00007 #ifndef __KX_PROPERTYSENSOR
00008 #define __KX_PROPERTYSENSOR
00009
00010 #include "SCA_ISensor.h"
00011
00012 class SCA_PropertySensor : public SCA_ISensor
00013 {
00014 Py_Header;
00015
00016 int m_checktype;
00017 CCString m_checkpropval;
00018 CCString m_checkpropmaxval;
00019 CCString m_checkpropname;
00020 CCString m_previoustext;
00021 bool m_lastresult;
00022 bool m_recentresult;
00023 CExpression* m_range_expr;
00024
00028 bool validValueForProperty(char *val, CCString &prop);
00029 protected:
00030
00031 public:
00032 enum KX_PROPSENSOR_TYPE {
00033 KX_PROPSENSOR_NODEF = 0,
00034 KX_PROPSENSOR_EQUAL,
00035 KX_PROPSENSOR_NOTEQUAL,
00036 KX_PROPSENSOR_INTERVAL,
00037 KX_PROPSENSOR_CHANGED,
00038 KX_PROPSENSOR_EXPRESSION,
00039 KX_PROPSENSOR_MAX
00040 };
00041
00042 const CCString S_KX_PROPSENSOR_EQ_STRING;
00043
00044 SCA_PropertySensor(class SCA_EventManager* eventmgr,
00045 SCA_IObject* gameobj,
00046 const CCString& propname,
00047 const CCString& propval,
00048 const CCString& propmaxval,
00049 KX_PROPSENSOR_TYPE checktype,
00050 PyTypeObject* T=&Type );
00051
00052 virtual ~SCA_PropertySensor();
00053 virtual CValue* GetReplica() {
00054 CValue* replica = new SCA_PropertySensor(*this);
00055
00056 CValue::AddDataToReplica(replica);
00057 return replica;
00058 };
00059
00060 bool CheckPropertyCondition();
00061
00062 virtual bool Evaluate(CValue* event);
00063 virtual bool IsPositiveTrigger()
00064 {
00065 bool result = m_recentresult;
00066 if (m_invert) result = !result;
00067 return result;
00068 }
00069 virtual CValue* FindIdentifier(const CCString& identifiername);
00070
00071
00072
00073
00074
00075 virtual PyObject* _getattr(char *attr);
00076
00077
00078 KX_PYMETHOD_DOC(SCA_PropertySensor,GetType);
00079
00080 KX_PYMETHOD_DOC(SCA_PropertySensor,SetType);
00081
00082 KX_PYMETHOD_DOC(SCA_PropertySensor,SetProperty);
00083
00084 KX_PYMETHOD_DOC(SCA_PropertySensor,GetProperty);
00085
00086 KX_PYMETHOD_DOC(SCA_PropertySensor,GetValue);
00087
00088 KX_PYMETHOD_DOC(SCA_PropertySensor,SetValue);
00089
00090 };
00091 #endif