Blender V2.61 - r43446

SCA_ORController.cpp

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