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_IACTUATOR 00033 #define __KX_IACTUATOR 00034 00035 #include "SCA_IController.h" 00036 #include <vector> 00037 00043 class SCA_IActuator : public SCA_ILogicBrick 00044 { 00045 friend class SCA_LogicManager; 00046 protected: 00047 int m_type; 00048 int m_links; // number of active links to controllers 00049 // when 0, the actuator is automatically stopped 00050 //std::vector<CValue*> m_events; 00051 bool m_posevent; 00052 bool m_negevent; 00053 00054 std::vector<class SCA_IController*> m_linkedcontrollers; 00055 00056 void RemoveAllEvents() 00057 { 00058 m_posevent = false; 00059 m_negevent = false; 00060 } 00061 00062 00063 public: 00067 enum KX_ACTUATOR_TYPE { 00068 KX_ACT_OBJECT, 00069 KX_ACT_IPO, 00070 KX_ACT_CAMERA, 00071 KX_ACT_SOUND, 00072 KX_ACT_PROPERTY, 00073 KX_ACT_ADD_OBJECT, 00074 KX_ACT_END_OBJECT, 00075 KX_ACT_DYNAMIC, 00076 KX_ACT_REPLACE_MESH, 00077 KX_ACT_TRACKTO, 00078 KX_ACT_CONSTRAINT, 00079 KX_ACT_SCENE, 00080 KX_ACT_RANDOM, 00081 KX_ACT_MESSAGE, 00082 KX_ACT_ACTION, 00083 KX_ACT_CD, 00084 KX_ACT_GAME, 00085 KX_ACT_VISIBILITY, 00086 KX_ACT_2DFILTER, 00087 KX_ACT_PARENT, 00088 KX_ACT_SHAPEACTION, 00089 KX_ACT_STATE, 00090 KX_ACT_ARMATURE, 00091 KX_ACT_STEERING, 00092 }; 00093 00094 SCA_IActuator(SCA_IObject* gameobj, KX_ACTUATOR_TYPE type); 00095 00103 virtual bool UnlinkObject(SCA_IObject* clientobj) { return false; } 00104 00116 virtual bool Update(double curtime, bool frame); 00117 virtual bool Update(); 00118 00122 //void AddEvent(CValue* event) 00123 void AddEvent(bool event) 00124 { 00125 if (event) 00126 m_posevent = true; 00127 else 00128 m_negevent = true; 00129 } 00130 00131 virtual void ProcessReplica(); 00132 00139 bool IsNegativeEvent() const 00140 { 00141 return !m_posevent && m_negevent; 00142 } 00143 00144 virtual ~SCA_IActuator(); 00145 00149 virtual void Deactivate(); 00150 virtual void Activate(SG_DList& head); 00151 00152 void LinkToController(SCA_IController* controller); 00153 void UnlinkController(class SCA_IController* cont); 00154 void UnlinkAllControllers(); 00155 00156 void ClrLink() { m_links=0; } 00157 void IncLink() { m_links++; } 00158 void DecLink(); 00159 bool IsNoLink() const { return !m_links; } 00160 bool IsType(KX_ACTUATOR_TYPE type) { return m_type == type; } 00161 00162 #ifdef WITH_CXX_GUARDEDALLOC 00163 public: 00164 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_IActuator"); } 00165 void operator delete( void *mem ) { MEM_freeN(mem); } 00166 #endif 00167 }; 00168 00169 #endif //__KX_IACTUATOR 00170