Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00032 #ifndef __KX_ICONTROLLER 00033 #define __KX_ICONTROLLER 00034 00035 #include "SCA_ILogicBrick.h" 00036 #include "PyObjectPlus.h" 00037 00043 class SCA_IController : public SCA_ILogicBrick 00044 { 00045 Py_Header 00046 protected: 00047 std::vector<class SCA_ISensor*> m_linkedsensors; 00048 std::vector<class SCA_IActuator*> m_linkedactuators; 00049 unsigned int m_statemask; 00050 bool m_justActivated; 00051 bool m_bookmark; 00052 public: 00053 SCA_IController(SCA_IObject* gameobj); 00054 virtual ~SCA_IController(); 00055 virtual void Trigger(class SCA_LogicManager* logicmgr)=0; 00056 void LinkToSensor(SCA_ISensor* sensor); 00057 void LinkToActuator(SCA_IActuator*); 00058 std::vector<class SCA_ISensor*>& GetLinkedSensors(); 00059 std::vector<class SCA_IActuator*>& GetLinkedActuators(); 00060 void ReserveActuator(int num) 00061 { 00062 m_linkedactuators.reserve(num); 00063 } 00064 void UnlinkAllSensors(); 00065 void UnlinkAllActuators(); 00066 void UnlinkActuator(class SCA_IActuator* actua); 00067 void UnlinkSensor(class SCA_ISensor* sensor); 00068 void SetState(unsigned int state) { m_statemask = state; } 00069 void ApplyState(unsigned int state); 00070 void Deactivate() 00071 { 00072 // the controller can only be part of a sensor m_newControllers list 00073 Delink(); 00074 } 00075 bool IsJustActivated() 00076 { 00077 return m_justActivated; 00078 } 00079 void ClrJustActivated() 00080 { 00081 m_justActivated = false; 00082 } 00083 void SetBookmark(bool bookmark) 00084 { 00085 m_bookmark = bookmark; 00086 } 00087 void Activate(SG_DList& head) 00088 { 00089 if (QEmpty()) 00090 { 00091 if (m_bookmark) 00092 { 00093 m_gameobj->m_activeBookmarkedControllers.QAddBack(this); 00094 head.AddFront(&m_gameobj->m_activeBookmarkedControllers); 00095 } 00096 else 00097 { 00098 InsertActiveQList(m_gameobj->m_activeControllers); 00099 head.AddBack(&m_gameobj->m_activeControllers); 00100 } 00101 } 00102 } 00103 00104 00105 #ifdef WITH_PYTHON 00106 static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00107 static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00108 static PyObject* pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00109 #endif // WITH_PYTHON 00110 }; 00111 00112 #endif 00113