#include "KX_PyMath.h"
#include "SCA_IActuator.h"
#include "SCA_ISensor.h"
+#include "SCA_IController.h"
#include "PyObjectPlus.h" /* python stuff */
KX_PYATTRIBUTE_RW_FUNCTION("timeOffset",KX_GameObject, pyattr_get_timeOffset,pyattr_set_timeOffset),
KX_PYATTRIBUTE_RW_FUNCTION("state", KX_GameObject, pyattr_get_state, pyattr_set_state),
KX_PYATTRIBUTE_RO_FUNCTION("meshes", KX_GameObject, pyattr_get_meshes),
+
KX_PYATTRIBUTE_RO_FUNCTION("__dict__", KX_GameObject, pyattr_get_dir_dict),
+
+ /* Experemental, dont rely on these yet */
+ KX_PYATTRIBUTE_RO_FUNCTION("sensors", KX_GameObject, pyattr_get_sensors),
+ KX_PYATTRIBUTE_RO_FUNCTION("controllers", KX_GameObject, pyattr_get_controllers),
+ KX_PYATTRIBUTE_RO_FUNCTION("actuators", KX_GameObject, pyattr_get_actuators),
+
{NULL} //Sentinel
};
}
+/* experemental! */
+PyObject* KX_GameObject::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+ SCA_SensorList& sensors= self->GetSensors();
+ PyObject* resultlist = PyList_New(sensors.size());
+
+ for (unsigned int index=0;index<sensors.size();index++)
+ PyList_SET_ITEM(resultlist, index, sensors[index]->AddRef());
+
+ return resultlist;
+}
+
+PyObject* KX_GameObject::pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+ SCA_ControllerList& controllers= self->GetControllers();
+ PyObject* resultlist = PyList_New(controllers.size());
+
+ for (unsigned int index=0;index<controllers.size();index++)
+ PyList_SET_ITEM(resultlist, index, controllers[index]->AddRef());
+
+ return resultlist;
+}
+
+PyObject* KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+ SCA_ActuatorList& actuators= self->GetActuators();
+ PyObject* resultlist = PyList_New(actuators.size());
+
+ for (unsigned int index=0;index<actuators.size();index++)
+ PyList_SET_ITEM(resultlist, index, actuators[index]->AddRef());
+
+ return resultlist;
+}
+
+
/* __dict__ only for the purpose of giving useful dir() results */
PyObject* KX_GameObject::pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
return dict;
}
+
PyObject* KX_GameObject::py_getattro(PyObject *attr)
{
PyObject* object = py_getattro_self(Attributes, this, attr);
# $Id$
# Documentation for game objects
-class KX_GameObject:
+# from SCA_IObject import *
+from SCA_ISensor import *
+from SCA_IController import *
+from SCA_IActuator import *
+
+
+class KX_GameObject: # (SCA_IObject)
"""
All game objects are derived from this class.
@type timeOffset: float
@ivar state: the game object's state bitmask.
@type state: int
- @ivar meshes: a list of L{KX_MeshProxy} objects.
+ @ivar meshes: a list meshes for this object.
+ B{Note}: Most objects use only 1 mesh.
+ B{Note}: Changes to this list will not update the KX_GameObject.
+ @type meshes: list of L{KX_MeshProxy}
+ @ivar sensors: a list of L{SCA_ISensor} objects.
+ B{Note}: This attribute is experemental and may be removed (but probably wont be).
+ B{Note}: Changes to this list will not update the KX_GameObject
+ @type sensors: list of L{SCA_ISensor}
+ @ivar controllers: a list of L{SCA_ISensor} objects.
+ B{Note}: This attribute is experemental and may be removed (but probably wont be).
+ B{Note}: Changes to this list will not update the KX_GameObject
+ @type controllers: list of L{SCA_IController}
+ @ivar the actuators assigned to this object.
+ B{Note}: This attribute is experemental and may be removed (but probably wont be).
B{Note}: Changes to this list will not update the KX_GameObject
- @type meshes: list
+ @type actuators: a list of L{SCA_IActuator}
"""
def endObject(visible):
"""