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