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