Initial revision
[blender.git] / source / gameengine / GameLogic / SCA_AlwaysSensor.cpp
1 /**
2  * Always trigger
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 #ifdef WIN32
36 // This warning tells us about truncation of __long__ stl-generated names.
37 // It can occasionally cause DevStudio to have internal compiler warnings.
38 #pragma warning( disable : 4786 )     
39 #endif
40
41 #include "SCA_AlwaysSensor.h"
42 #include "SCA_LogicManager.h"
43 #include "SCA_EventManager.h"
44
45 /* ------------------------------------------------------------------------- */
46 /* Native functions                                                          */
47 /* ------------------------------------------------------------------------- */
48
49 SCA_AlwaysSensor::SCA_AlwaysSensor(class SCA_EventManager* eventmgr,
50                                                                  SCA_IObject* gameobj,
51                                                                  PyTypeObject* T)
52         : SCA_ISensor(gameobj,eventmgr, T)
53 {
54         //SetDrawColor(255,0,0);
55         m_alwaysresult = true;
56 }
57
58
59
60 SCA_AlwaysSensor::~SCA_AlwaysSensor()
61 {
62         /* intentionally empty */
63 }
64
65
66
67 CValue* SCA_AlwaysSensor::GetReplica()
68 {
69         CValue* replica = new SCA_AlwaysSensor(*this);//m_float,GetName());
70         // this will copy properties and so on...
71         CValue::AddDataToReplica(replica);
72
73         return replica;
74 }
75
76
77
78 bool SCA_AlwaysSensor::IsPositiveTrigger()
79
80         return (m_invert ? false : true);
81 }
82
83
84
85 bool SCA_AlwaysSensor::Evaluate(CValue* event)
86 {
87         /* Nice! :) */
88                 //return true;
89         /* even nicer ;) */
90                 //return false;
91         
92         /* nicest ! */
93         bool result = m_alwaysresult;
94         m_alwaysresult = false;
95         return result;
96 }
97
98 /* ------------------------------------------------------------------------- */
99 /* Python functions                                                          */
100 /* ------------------------------------------------------------------------- */
101
102 /* Integration hooks ------------------------------------------------------- */
103 PyTypeObject SCA_AlwaysSensor::Type = {
104         PyObject_HEAD_INIT(&PyType_Type)
105         0,
106         "SCA_AlwaysSensor",
107         sizeof(SCA_AlwaysSensor),
108         0,
109         PyDestructor,
110         0,
111         __getattr,
112         __setattr,
113         0, //&MyPyCompare,
114         __repr,
115         0, //&cvalue_as_number,
116         0,
117         0,
118         0,
119         0
120 };
121
122 PyParentObject SCA_AlwaysSensor::Parents[] = {
123         &SCA_AlwaysSensor::Type,
124         &SCA_ISensor::Type,
125         &SCA_ILogicBrick::Type,
126         &CValue::Type,
127         NULL
128 };
129
130 PyMethodDef SCA_AlwaysSensor::Methods[] = {
131         {NULL,NULL} //Sentinel
132 };
133
134 PyObject* SCA_AlwaysSensor::_getattr(char* attr) {
135         _getattr_up(SCA_ISensor);
136 }
137
138 /* eof */