Merged 15170:15635 from trunk (no conflicts or even merges)
[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         CValue::AddDataToReplica(replica);
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(CValue* event)
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         PyObject_HEAD_INIT(&PyType_Type)
109         0,
110         "SCA_AlwaysSensor",
111         sizeof(SCA_AlwaysSensor),
112         0,
113         PyDestructor,
114         0,
115         __getattr,
116         __setattr,
117         0, //&MyPyCompare,
118         __repr,
119         0, //&cvalue_as_number,
120         0,
121         0,
122         0,
123         0
124 };
125
126 PyParentObject SCA_AlwaysSensor::Parents[] = {
127         &SCA_AlwaysSensor::Type,
128         &SCA_ISensor::Type,
129         &SCA_ILogicBrick::Type,
130         &CValue::Type,
131         NULL
132 };
133
134 PyMethodDef SCA_AlwaysSensor::Methods[] = {
135         {NULL,NULL} //Sentinel
136 };
137
138 PyObject* SCA_AlwaysSensor::_getattr(const STR_String& attr) {
139         _getattr_up(SCA_ISensor);
140 }
141
142 /* eof */