BGE: bookmark option on controller to make them run before all other controllers.
[blender.git] / source / gameengine / GameLogic / SCA_AlwaysSensor.cpp
1 /**
2  * Always trigger
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 #ifdef HAVE_CONFIG_H
33 #include <config.h>
34 #endif
35
36 #ifdef WIN32
37 // This warning tells us about truncation of __long__ stl-generated names.
38 // It can occasionally cause DevStudio to have internal compiler warnings.
39 #pragma warning( disable : 4786 )     
40 #endif
41
42 #include "SCA_AlwaysSensor.h"
43 #include "SCA_LogicManager.h"
44 #include "SCA_EventManager.h"
45
46 /* ------------------------------------------------------------------------- */
47 /* Native functions                                                          */
48 /* ------------------------------------------------------------------------- */
49
50 SCA_AlwaysSensor::SCA_AlwaysSensor(class SCA_EventManager* eventmgr,
51                                                                  SCA_IObject* gameobj,
52                                                                  PyTypeObject* T)
53         : SCA_ISensor(gameobj,eventmgr, T)
54 {
55         //SetDrawColor(255,0,0);
56         Init();
57 }
58
59 void SCA_AlwaysSensor::Init()
60 {
61         m_alwaysresult = true;
62 }
63
64 SCA_AlwaysSensor::~SCA_AlwaysSensor()
65 {
66         /* intentionally empty */
67 }
68
69
70
71 CValue* SCA_AlwaysSensor::GetReplica()
72 {
73         CValue* replica = new SCA_AlwaysSensor(*this);//m_float,GetName());
74         // this will copy properties and so on...
75         replica->ProcessReplica();
76
77         return replica;
78 }
79
80
81
82 bool SCA_AlwaysSensor::IsPositiveTrigger()
83
84         return (m_invert ? false : true);
85 }
86
87
88
89 bool SCA_AlwaysSensor::Evaluate()
90 {
91         /* Nice! :) */
92                 //return true;
93         /* even nicer ;) */
94                 //return false;
95         
96         /* nicest ! */
97         bool result = m_alwaysresult;
98         m_alwaysresult = false;
99         return result;
100 }
101
102 /* ------------------------------------------------------------------------- */
103 /* Python functions                                                          */
104 /* ------------------------------------------------------------------------- */
105
106 /* Integration hooks ------------------------------------------------------- */
107 PyTypeObject SCA_AlwaysSensor::Type = {
108 #if (PY_VERSION_HEX >= 0x02060000)
109         PyVarObject_HEAD_INIT(NULL, 0)
110 #else
111         /* python 2.5 and below */
112         PyObject_HEAD_INIT( NULL )  /* required py macro */
113         0,                          /* ob_size */
114 #endif
115         "SCA_AlwaysSensor",
116         sizeof(PyObjectPlus_Proxy),
117         0,
118         py_base_dealloc,
119         0,
120         0,
121         0,
122         0,
123         py_base_repr,
124         0,0,0,0,0,0,
125         py_base_getattro,
126         py_base_setattro,
127         0,0,0,0,0,0,0,0,0,
128         Methods
129 };
130
131 PyParentObject SCA_AlwaysSensor::Parents[] = {
132         &SCA_AlwaysSensor::Type,
133         &SCA_ISensor::Type,
134         &SCA_ILogicBrick::Type,
135         &CValue::Type,
136         NULL
137 };
138
139 PyMethodDef SCA_AlwaysSensor::Methods[] = {
140         {NULL,NULL} //Sentinel
141 };
142
143 PyAttributeDef SCA_AlwaysSensor::Attributes[] = {
144         { NULL }        //Sentinel
145 };
146
147 PyObject* SCA_AlwaysSensor::py_getattro(PyObject *attr) {
148         py_getattro_up(SCA_ISensor);
149 }
150
151 PyObject* SCA_AlwaysSensor::py_getattro_dict() {
152         py_getattro_dict_up(SCA_ISensor);
153 }
154
155 /* eof */