|
Blender
V2.59
|
00001 /* 00002 * $Id: SCA_IActuator.h 35063 2011-02-22 10:33:14Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 #ifndef __KX_IACTUATOR 00035 #define __KX_IACTUATOR 00036 00037 #include "SCA_IController.h" 00038 #include <vector> 00039 00045 class SCA_IActuator : public SCA_ILogicBrick 00046 { 00047 friend class SCA_LogicManager; 00048 protected: 00049 int m_type; 00050 int m_links; // number of active links to controllers 00051 // when 0, the actuator is automatically stopped 00052 //std::vector<CValue*> m_events; 00053 bool m_posevent; 00054 bool m_negevent; 00055 00056 std::vector<class SCA_IController*> m_linkedcontrollers; 00057 00058 void RemoveAllEvents() 00059 { 00060 m_posevent = false; 00061 m_negevent = false; 00062 } 00063 00064 00065 public: 00069 enum KX_ACTUATOR_TYPE { 00070 KX_ACT_OBJECT, 00071 KX_ACT_IPO, 00072 KX_ACT_CAMERA, 00073 KX_ACT_SOUND, 00074 KX_ACT_PROPERTY, 00075 KX_ACT_ADD_OBJECT, 00076 KX_ACT_END_OBJECT, 00077 KX_ACT_DYNAMIC, 00078 KX_ACT_REPLACE_MESH, 00079 KX_ACT_TRACKTO, 00080 KX_ACT_CONSTRAINT, 00081 KX_ACT_SCENE, 00082 KX_ACT_RANDOM, 00083 KX_ACT_MESSAGE, 00084 KX_ACT_ACTION, 00085 KX_ACT_CD, 00086 KX_ACT_GAME, 00087 KX_ACT_VISIBILITY, 00088 KX_ACT_2DFILTER, 00089 KX_ACT_PARENT, 00090 KX_ACT_SHAPEACTION, 00091 KX_ACT_STATE, 00092 KX_ACT_ARMATURE, 00093 }; 00094 00095 SCA_IActuator(SCA_IObject* gameobj, KX_ACTUATOR_TYPE type); 00096 00104 virtual bool UnlinkObject(SCA_IObject* clientobj) { return false; } 00105 00117 virtual bool Update(double curtime, bool frame); 00118 virtual bool Update(); 00119 00123 //void AddEvent(CValue* event) 00124 void AddEvent(bool event) 00125 { 00126 if (event) 00127 m_posevent = true; 00128 else 00129 m_negevent = true; 00130 } 00131 00132 virtual void ProcessReplica(); 00133 00140 bool IsNegativeEvent() const 00141 { 00142 return !m_posevent && m_negevent; 00143 } 00144 00145 virtual ~SCA_IActuator(); 00146 00150 virtual void Deactivate(); 00151 virtual void Activate(SG_DList& head); 00152 00153 void LinkToController(SCA_IController* controller); 00154 void UnlinkController(class SCA_IController* cont); 00155 void UnlinkAllControllers(); 00156 00157 void ClrLink() { m_links=0; } 00158 void IncLink() { m_links++; } 00159 void DecLink(); 00160 bool IsNoLink() const { return !m_links; } 00161 bool IsType(KX_ACTUATOR_TYPE type) { return m_type == type; } 00162 00163 #ifdef WITH_CXX_GUARDEDALLOC 00164 public: 00165 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_IActuator"); } 00166 void operator delete( void *mem ) { MEM_freeN(mem); } 00167 #endif 00168 }; 00169 00170 #endif //__KX_IACTUATOR 00171