Blender V2.61 - r43446
|
00001 /* 00002 * 'And' together all inputs 00003 * 00004 * 00005 * ***** BEGIN GPL LICENSE BLOCK ***** 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software Foundation, 00019 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 * 00021 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00022 * All rights reserved. 00023 * 00024 * The Original Code is: all of this file. 00025 * 00026 * Contributor(s): none yet. 00027 * 00028 * ***** END GPL LICENSE BLOCK ***** 00029 */ 00030 00036 #include "SCA_ANDController.h" 00037 #include "SCA_ISensor.h" 00038 #include "SCA_LogicManager.h" 00039 #include "BoolValue.h" 00040 00041 /* ------------------------------------------------------------------------- */ 00042 /* Native functions */ 00043 /* ------------------------------------------------------------------------- */ 00044 00045 SCA_ANDController::SCA_ANDController(SCA_IObject* gameobj) 00046 : 00047 SCA_IController(gameobj) 00048 { 00049 } 00050 00051 00052 00053 SCA_ANDController::~SCA_ANDController() 00054 { 00055 } 00056 00057 00058 00059 void SCA_ANDController::Trigger(SCA_LogicManager* logicmgr) 00060 { 00061 00062 bool sensorresult = true; 00063 00064 for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin(); 00065 !(is==m_linkedsensors.end());is++) 00066 { 00067 SCA_ISensor* sensor = *is; 00068 if (!sensor->GetState()) 00069 { 00070 sensorresult = false; 00071 break; 00072 } 00073 } 00074 00075 for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); 00076 !(i==m_linkedactuators.end());i++) 00077 { 00078 SCA_IActuator* actua = *i; 00079 logicmgr->AddActiveActuator(actua,sensorresult); 00080 } 00081 } 00082 00083 00084 00085 CValue* SCA_ANDController::GetReplica() 00086 { 00087 CValue* replica = new SCA_ANDController(*this); 00088 // this will copy properties and so on... 00089 replica->ProcessReplica(); 00090 00091 return replica; 00092 } 00093 00094 #ifdef WITH_PYTHON 00095 00096 /* ------------------------------------------------------------------------- */ 00097 /* Python functions */ 00098 /* ------------------------------------------------------------------------- */ 00099 00100 /* Integration hooks ------------------------------------------------------- */ 00101 PyTypeObject SCA_ANDController::Type = { 00102 PyVarObject_HEAD_INIT(NULL, 0) 00103 "SCA_ANDController", 00104 sizeof(PyObjectPlus_Proxy), 00105 0, 00106 py_base_dealloc, 00107 0, 00108 0, 00109 0, 00110 0, 00111 py_base_repr, 00112 0,0,0,0,0,0,0,0,0, 00113 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, 00114 0,0,0,0,0,0,0, 00115 Methods, 00116 0, 00117 0, 00118 &SCA_IController::Type, 00119 0,0,0,0,0,0, 00120 py_base_new 00121 }; 00122 00123 PyMethodDef SCA_ANDController::Methods[] = { 00124 {NULL,NULL} //Sentinel 00125 }; 00126 00127 PyAttributeDef SCA_ANDController::Attributes[] = { 00128 { NULL } //Sentinel 00129 }; 00130 #endif // WITH_PYTHON 00131 /* eof */