doxygen: prevent GPL license block from being parsed as doxygen comment.
[blender.git] / source / gameengine / GameLogic / SCA_XNORController.cpp
1 /*
2  * 'Xnor' 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_XNORController.h"
33 #include "SCA_ISensor.h"
34 #include "SCA_LogicManager.h"
35 #include "BoolValue.h"
36
37 /* ------------------------------------------------------------------------- */
38 /* Native functions                                                          */
39 /* ------------------------------------------------------------------------- */
40
41 SCA_XNORController::SCA_XNORController(SCA_IObject* gameobj)
42         :
43         SCA_IController(gameobj)
44 {
45 }
46
47
48
49 SCA_XNORController::~SCA_XNORController()
50 {
51 }
52
53
54
55 void SCA_XNORController::Trigger(SCA_LogicManager* logicmgr)
56 {
57
58         bool sensorresult = true;
59
60         for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
61         !(is==m_linkedsensors.end());is++)
62         {
63                 SCA_ISensor* sensor = *is;
64                 if (sensor->GetState())
65                 {
66                         if (sensorresult == false)
67                         {
68                                 sensorresult = true;
69                                 break;
70                         }
71                         sensorresult = false;
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_XNORController::GetReplica()
86 {
87         CValue* replica = new SCA_XNORController(*this);
88         // this will copy properties and so on...
89         replica->ProcessReplica();
90
91         return replica;
92 }
93
94 #ifdef WITH_PYTHON
95
96 /* ------------------------------------------------------------------------- */
97 /* Python functions                                                          */
98 /* ------------------------------------------------------------------------- */
99
100 /* Integration hooks ------------------------------------------------------- */
101 PyTypeObject SCA_XNORController::Type = {
102         PyVarObject_HEAD_INIT(NULL, 0)
103         "SCA_XNORController",
104         sizeof(PyObjectPlus_Proxy),
105         0,
106         py_base_dealloc,
107         0,
108         0,
109         0,
110         0,
111         py_base_repr,
112         0,0,0,0,0,0,0,0,0,
113         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
114         0,0,0,0,0,0,0,
115         Methods,
116         0,
117         0,
118         &SCA_IController::Type,
119         0,0,0,0,0,0,
120         py_base_new
121 };
122
123 PyMethodDef SCA_XNORController::Methods[] = {
124         {NULL,NULL} //Sentinel
125 };
126
127 PyAttributeDef SCA_XNORController::Attributes[] = {
128         { NULL }        //Sentinel
129 };
130
131 #endif // WITH_PYTHON
132
133 /* eof */