Changed Python _getattr/_setattr methods to use const STR_String& instead of char...
[blender.git] / source / gameengine / GameLogic / SCA_ORController.cpp
1 /**
2  * 'Or' together all inputs
3  *
4  * $Id$
5  *
6  * ***** BEGIN GPL/BL DUAL 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. The Blender
12  * Foundation also sells licenses for use in proprietary software under
13  * the Blender License.  See http://www.blender.org/BL/ for information
14  * about this.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  *
25  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
26  * All rights reserved.
27  *
28  * The Original Code is: all of this file.
29  *
30  * Contributor(s): none yet.
31  *
32  * ***** END GPL/BL DUAL LICENSE BLOCK *****
33  */
34
35 #include "SCA_ORController.h"
36 #include "SCA_ISensor.h"
37 #include "SCA_LogicManager.h"
38 #include "BoolValue.h"
39
40 #ifdef HAVE_CONFIG_H
41 #include <config.h>
42 #endif
43
44 /* ------------------------------------------------------------------------- */
45 /* Native functions                                                          */
46 /* ------------------------------------------------------------------------- */
47
48 SCA_ORController::SCA_ORController(SCA_IObject* gameobj,
49                                                                    PyTypeObject* T)
50                 :SCA_IController(gameobj, T)
51 {
52 }
53
54
55
56 SCA_ORController::~SCA_ORController()
57 {
58 }
59
60
61
62 CValue* SCA_ORController::GetReplica()
63 {
64         CValue* replica = new SCA_ORController(*this);
65         // this will copy properties and so on...
66         CValue::AddDataToReplica(replica);
67
68         return replica;
69 }
70
71
72 void SCA_ORController::Trigger(SCA_LogicManager* logicmgr)
73 {
74
75         bool sensorresult = false;
76         SCA_ISensor* sensor;
77
78         vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
79         while ( (!sensorresult) && (!(is==m_linkedsensors.end())) )
80         {
81                 sensor = *is;
82                 if (sensor->IsPositiveTrigger()) sensorresult = true;
83                 is++;
84         }
85         
86         CValue* newevent = new CBoolValue(sensorresult);
87
88         for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
89         !(i==m_linkedactuators.end());i++)
90         {
91                 SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
92                 logicmgr->AddActiveActuator(actua,newevent);
93         }
94
95
96         newevent->Release();
97 }
98
99 /* ------------------------------------------------------------------------- */
100 /* Python functions                                                          */
101 /* ------------------------------------------------------------------------- */
102
103 /* Integration hooks ------------------------------------------------------- */
104 PyTypeObject SCA_ORController::Type = {
105         PyObject_HEAD_INIT(&PyType_Type)
106         0,
107         "SCA_ORController",
108         sizeof(SCA_ORController),
109         0,
110         PyDestructor,
111         0,
112         __getattr,
113         __setattr,
114         0, //&MyPyCompare,
115         __repr,
116         0, //&cvalue_as_number,
117         0,
118         0,
119         0,
120         0
121 };
122
123 PyParentObject SCA_ORController::Parents[] = {
124         &SCA_ORController::Type,
125         &SCA_IController::Type,
126         &SCA_ILogicBrick::Type,
127         &CValue::Type,
128         NULL
129 };
130
131 PyMethodDef SCA_ORController::Methods[] = {
132         {NULL,NULL} //Sentinel
133 };
134
135 PyObject* SCA_ORController::_getattr(const STR_String& attr) {
136         _getattr_up(SCA_IController);
137 }
138
139 /* eof */