svn merge -r 21041:21243 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
[blender.git] / source / gameengine / GameLogic / SCA_NORController.cpp
1 /**
2  * 'Nor' together all inputs
3  *
4  * $Id$
5  *
6  * ***** BEGIN GPL LICENSE BLOCK *****
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  *
22  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23  * All rights reserved.
24  *
25  * The Original Code is: all of this file.
26  *
27  * Contributor(s): none yet.
28  *
29  * ***** END GPL LICENSE BLOCK *****
30  */
31
32 #include "SCA_NORController.h"
33 #include "SCA_ISensor.h"
34 #include "SCA_LogicManager.h"
35 #include "BoolValue.h"
36
37 #ifdef HAVE_CONFIG_H
38 #include <config.h>
39 #endif
40
41 /* ------------------------------------------------------------------------- */
42 /* Native functions                                                          */
43 /* ------------------------------------------------------------------------- */
44
45 SCA_NORController::SCA_NORController(SCA_IObject* gameobj)
46         :
47         SCA_IController(gameobj)
48 {
49 }
50
51
52
53 SCA_NORController::~SCA_NORController()
54 {
55 }
56
57
58
59 void SCA_NORController::Trigger(SCA_LogicManager* logicmgr)
60 {
61
62         bool sensorresult = true;
63
64         for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
65         !(is==m_linkedsensors.end());is++)
66         {
67                 SCA_ISensor* sensor = *is;
68                 if (sensor->GetState())
69                 {
70                         sensorresult = false;
71                         break;
72                 }
73         }
74         
75         for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
76         !(i==m_linkedactuators.end());i++)
77         {
78                 SCA_IActuator* actua = *i;
79                 logicmgr->AddActiveActuator(actua,sensorresult);
80         }
81 }
82
83
84
85 CValue* SCA_NORController::GetReplica()
86 {
87         CValue* replica = new SCA_NORController(*this);
88         // this will copy properties and so on...
89         replica->ProcessReplica();
90
91         return replica;
92 }
93
94
95
96 /* ------------------------------------------------------------------------- */
97 /* Python functions                                                          */
98 /* ------------------------------------------------------------------------- */
99
100 /* Integration hooks ------------------------------------------------------- */
101 PyTypeObject SCA_NORController::Type = {
102 #if (PY_VERSION_HEX >= 0x02060000)
103         PyVarObject_HEAD_INIT(NULL, 0)
104 #else
105         /* python 2.5 and below */
106         PyObject_HEAD_INIT( NULL )  /* required py macro */
107         0,                          /* ob_size */
108 #endif
109         "SCA_NORController",
110         sizeof(PyObjectPlus_Proxy),
111         0,
112         py_base_dealloc,
113         0,
114         0,
115         0,
116         0,
117         py_base_repr,
118         0,0,0,0,0,0,0,0,0,
119         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
120         0,0,0,0,0,0,0,
121         Methods,
122         0,
123         0,
124         &SCA_IController::Type,
125         0,0,0,0,0,0,
126         py_base_new
127 };
128
129 PyMethodDef SCA_NORController::Methods[] = {
130         {NULL,NULL} //Sentinel
131 };
132
133 PyAttributeDef SCA_NORController::Attributes[] = {
134         { NULL }        //Sentinel
135 };
136
137 /* eof */