svn merge -r 21041:21301 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
[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         : SCA_ISensor(gameobj,eventmgr)
53 {
54         //SetDrawColor(255,0,0);
55         Init();
56 }
57
58 void SCA_AlwaysSensor::Init()
59 {
60         m_alwaysresult = true;
61 }
62
63 SCA_AlwaysSensor::~SCA_AlwaysSensor()
64 {
65         /* intentionally empty */
66 }
67
68
69
70 CValue* SCA_AlwaysSensor::GetReplica()
71 {
72         CValue* replica = new SCA_AlwaysSensor(*this);//m_float,GetName());
73         // this will copy properties and so on...
74         replica->ProcessReplica();
75
76         return replica;
77 }
78
79
80
81 bool SCA_AlwaysSensor::IsPositiveTrigger()
82
83         return (m_invert ? false : true);
84 }
85
86
87
88 bool SCA_AlwaysSensor::Evaluate()
89 {
90         /* Nice! :) */
91                 //return true;
92         /* even nicer ;) */
93                 //return false;
94         
95         /* nicest ! */
96         bool result = m_alwaysresult;
97         m_alwaysresult = false;
98         return result;
99 }
100
101 /* ------------------------------------------------------------------------- */
102 /* Python functions                                                          */
103 /* ------------------------------------------------------------------------- */
104
105 /* Integration hooks ------------------------------------------------------- */
106 PyTypeObject SCA_AlwaysSensor::Type = {
107 #if (PY_VERSION_HEX >= 0x02060000)
108         PyVarObject_HEAD_INIT(NULL, 0)
109 #else
110         /* python 2.5 and below */
111         PyObject_HEAD_INIT( NULL )  /* required py macro */
112         0,                          /* ob_size */
113 #endif
114         "SCA_AlwaysSensor",
115         sizeof(PyObjectPlus_Proxy),
116         0,
117         py_base_dealloc,
118         0,
119         0,
120         0,
121         0,
122         py_base_repr,
123         0,0,0,0,0,0,0,0,0,
124         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
125         0,0,0,0,0,0,0,
126         Methods,
127         0,
128         0,
129         &SCA_ISensor::Type,
130         0,0,0,0,0,0,
131         py_base_new
132 };
133
134 PyMethodDef SCA_AlwaysSensor::Methods[] = {
135         {NULL,NULL} //Sentinel
136 };
137
138 PyAttributeDef SCA_AlwaysSensor::Attributes[] = {
139         { NULL }        //Sentinel
140 };
141
142 /* eof */