Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

KX_PythonController.cpp

Go to the documentation of this file.
00001 #include "SCA_PythonController.h"
00002 #include "SCA_LogicManager.h"
00003 #include "SCA_ISensor.h"
00004 #include "SCA_IActuator.h"
00005 
00006 // initialize static member variables
00007 SCA_PythonController* SCA_PythonController::m_sCurrentController = NULL;
00008 char* SCA_PythonController::sPyGetCurrentController__doc__ = "GetCurrentController";
00009 char* SCA_PythonController::sPyGetActuator__doc__ = "GetActuator";
00010 char* SCA_PythonController::sPyGetSensor__doc__   = "GetSensor";
00011 
00012 PyTypeObject SCA_PythonController::Type = {
00013         PyObject_HEAD_INIT(&PyType_Type)
00014         0,
00015         "SCA_PythonController",
00016         sizeof(SCA_PythonController),
00017         0,
00018         PyDestructor,
00019         0,
00020         __getattr,
00021         __setattr,
00022         0, //&MyPyCompare,
00023         __repr,
00024         0, //&cvalue_as_number,
00025         0,
00026         0,
00027         0,
00028         0
00029 };
00030 
00031 PyParentObject SCA_PythonController::Parents[] = {
00032         &SCA_PythonController::Type,
00033         &CValue::Type,
00034         NULL
00035 };
00036 PyMethodDef SCA_PythonController::Methods[] = {
00037   {"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator, 
00038    METH_VARARGS, SCA_PythonController::sPyGetActuator__doc__},
00039   {"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor, 
00040    METH_VARARGS, SCA_PythonController::sPyGetSensor__doc__},
00041   {NULL,NULL} //Sentinel
00042 };
00043 
00044 SCA_PythonController::SCA_PythonController(KX_GameObject* gameobj,PyTypeObject* T) 
00045   : SCA_IController(gameobj, T)

00046 {
00047 }
00048 
00049 SCA_PythonController::~SCA_PythonController()

00050 {
00051 }
00052 
00053 void 
00054 SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)

00055 {
00056 //  printf("Run the script ...\n");
00057   m_sCurrentController = this;
00058   // run the script
00059   m_sCurrentController = NULL;
00060   
00061 }
00062 
00063 PyObject*
00064 SCA_PythonController::_getattr(char* attr)

00065 {
00066   _getattr_up(SCA_IController);
00067 }
00068 
00069 PyObject*
00070 SCA_PythonController::PyGetActuator(PyObject* self, 
00071                                    PyObject* args, 
00072                                    PyObject* kwds)

00073 {
00074   int index;
00075 
00076   if (!PyArg_ParseTuple(args, "i", &index))
00077     {
00078       return NULL;
00079     }
00080 
00081   m_linkedactuators[index]->AddRef();
00082   return m_linkedactuators[index];
00083 }
00084 
00085 PyObject*
00086 SCA_PythonController::PyGetSensor(PyObject* self, 
00087                                  PyObject* args, 
00088                                  PyObject* kwds)

00089 {
00090   int index;
00091 
00092   if (!PyArg_ParseTuple(args, "i", &index))
00093     {
00094       return NULL;
00095     }
00096 
00097   m_linkedsensors[index]->AddRef();
00098   return m_linkedsensors[index];
00099 }

Generated at Thu Feb 1 13:03:06 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000