BGE API cleanup: apply patch from Moguri: Near, Radar, Touch sensor updated.
[blender.git] / source / gameengine / Ketsji / KX_NearSensor.cpp
index 066387abb93e601ca16280d5fa9c2f98c9a0633e..993a6b3d86c55b31830e38b03091714f85412d52 100644 (file)
@@ -42,8 +42,8 @@
 #endif
 KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
                                                         KX_GameObject* gameobj,
-                                                        double margin,
-                                                        double resetmargin,
+                                                        float margin,
+                                                        float resetmargin,
                                                         bool bFindMaterial,
                                                         const STR_String& touchedpropname,
                                                         class KX_Scene* scene,
@@ -276,8 +276,16 @@ bool       KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData
 }
 
 
+/* ------------------------------------------------------------------------- */
+/* Python Functions                                                                                                                     */
+/* ------------------------------------------------------------------------- */
+
+//No methods
+
+/* ------------------------------------------------------------------------- */
+/* Python Integration Hooks                                                  */
+/* ------------------------------------------------------------------------- */
 
-// python embedding
 PyTypeObject KX_NearSensor::Type = {
        PyObject_HEAD_INIT(&PyType_Type)
        0,
@@ -311,20 +319,31 @@ PyParentObject KX_NearSensor::Parents[] = {
 
 
 PyMethodDef KX_NearSensor::Methods[] = {
-       {"setProperty", (PyCFunction) KX_NearSensor::sPySetProperty,      METH_O, (PY_METHODCHAR)SetProperty_doc},
-       {"getProperty", (PyCFunction) KX_NearSensor::sPyGetProperty,      METH_NOARGS, (PY_METHODCHAR)GetProperty_doc},
-       {"getHitObject",(PyCFunction) KX_NearSensor::sPyGetHitObject,     METH_NOARGS, (PY_METHODCHAR)GetHitObject_doc},
-       {"getHitObjectList", (PyCFunction) KX_NearSensor::sPyGetHitObjectList, METH_NOARGS, (PY_METHODCHAR)GetHitObjectList_doc},
+       //No methods
        {NULL,NULL} //Sentinel
 };
 
 PyAttributeDef KX_NearSensor::Attributes[] = {
-       { NULL }        //Sentinel
+       KX_PYATTRIBUTE_FLOAT_RW_CHECK("distance", 0, 100, KX_NearSensor, m_Margin, CheckResetDistance),
+       KX_PYATTRIBUTE_FLOAT_RW_CHECK("resetDistance", 0, 100, KX_NearSensor, m_ResetMargin, CheckResetDistance),
+       {NULL} //Sentinel
 };
 
-PyObject*
-KX_NearSensor::_getattr(const char *attr)
+
+PyObject* KX_NearSensor::_getattr(const char *attr)
 {
-  _getattr_up(KX_TouchSensor);
+       PyObject* object = _getattr_self(Attributes, this, attr);
+       if (object != NULL)
+               return object;
+
+       _getattr_up(KX_TouchSensor);
 }
 
+int KX_NearSensor::_setattr(const char *attr, PyObject* value)
+{
+       int ret = _setattr_self(Attributes, this, attr, value);
+       if (ret >= 0)
+               return ret;
+
+       return KX_TouchSensor::_setattr(attr, value);
+}