|
Blender
V2.59
|
00001 /* 00002 * 'Xor' together all inputs 00003 * 00004 * $Id: SCA_XORController.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_XORController.h" 00038 #include "SCA_ISensor.h" 00039 #include "SCA_LogicManager.h" 00040 #include "BoolValue.h" 00041 00042 /* ------------------------------------------------------------------------- */ 00043 /* Native functions */ 00044 /* ------------------------------------------------------------------------- */ 00045 00046 SCA_XORController::SCA_XORController(SCA_IObject* gameobj) 00047 : 00048 SCA_IController(gameobj) 00049 { 00050 } 00051 00052 00053 00054 SCA_XORController::~SCA_XORController() 00055 { 00056 } 00057 00058 00059 00060 void SCA_XORController::Trigger(SCA_LogicManager* logicmgr) 00061 { 00062 00063 bool sensorresult = false; 00064 00065 for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin(); 00066 !(is==m_linkedsensors.end());is++) 00067 { 00068 SCA_ISensor* sensor = *is; 00069 if (sensor->GetState()) 00070 { 00071 if (sensorresult == true) 00072 { 00073 sensorresult = false; 00074 break; 00075 } 00076 sensorresult = true; 00077 } 00078 } 00079 00080 for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); 00081 !(i==m_linkedactuators.end());i++) 00082 { 00083 SCA_IActuator* actua = *i; 00084 logicmgr->AddActiveActuator(actua,sensorresult); 00085 } 00086 } 00087 00088 00089 00090 CValue* SCA_XORController::GetReplica() 00091 { 00092 CValue* replica = new SCA_XORController(*this); 00093 // this will copy properties and so on... 00094 replica->ProcessReplica(); 00095 00096 return replica; 00097 } 00098 00099 #ifdef WITH_PYTHON 00100 00101 /* ------------------------------------------------------------------------- */ 00102 /* Python functions */ 00103 /* ------------------------------------------------------------------------- */ 00104 00105 /* Integration hooks ------------------------------------------------------- */ 00106 PyTypeObject SCA_XORController::Type = { 00107 PyVarObject_HEAD_INIT(NULL, 0) 00108 "SCA_XORController", 00109 sizeof(PyObjectPlus_Proxy), 00110 0, 00111 py_base_dealloc, 00112 0, 00113 0, 00114 0, 00115 0, 00116 py_base_repr, 00117 0,0,0,0,0,0,0,0,0, 00118 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, 00119 0,0,0,0,0,0,0, 00120 Methods, 00121 0, 00122 0, 00123 &SCA_IController::Type, 00124 0,0,0,0,0,0, 00125 py_base_new 00126 }; 00127 00128 PyMethodDef SCA_XORController::Methods[] = { 00129 {NULL,NULL} //Sentinel 00130 }; 00131 00132 PyAttributeDef SCA_XORController::Attributes[] = { 00133 { NULL } //Sentinel 00134 }; 00135 #endif // WITH_PYTHON 00136 00137 /* eof */