Blender V2.61 - r43446

SCA_PropertySensor.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #ifndef __KX_PROPERTYSENSOR
00034 #define __KX_PROPERTYSENSOR
00035 
00036 #include "SCA_ISensor.h"
00037 
00038 class SCA_PropertySensor : public SCA_ISensor
00039 {
00040     Py_Header
00041     //class CExpression*    m_rightexpr;
00042     int             m_checktype;
00043     STR_String      m_checkpropval;
00044     STR_String      m_checkpropmaxval;
00045     STR_String      m_checkpropname;
00046     STR_String      m_previoustext;
00047     bool            m_lastresult;
00048     bool            m_recentresult;
00049     CExpression*    m_range_expr;
00050 
00051  protected:
00052 
00053 public:
00054     enum KX_PROPSENSOR_TYPE {
00055         KX_PROPSENSOR_NODEF = 0,
00056         KX_PROPSENSOR_EQUAL,
00057         KX_PROPSENSOR_NOTEQUAL,
00058         KX_PROPSENSOR_INTERVAL,
00059         KX_PROPSENSOR_CHANGED,
00060         KX_PROPSENSOR_EXPRESSION,
00061         KX_PROPSENSOR_MAX
00062     };
00063 
00064     const STR_String S_KX_PROPSENSOR_EQ_STRING;
00065     
00066     SCA_PropertySensor(class SCA_EventManager* eventmgr,
00067                       SCA_IObject* gameobj,
00068                       const STR_String& propname,
00069                       const STR_String& propval,
00070                       const STR_String& propmaxval,
00071                       KX_PROPSENSOR_TYPE checktype);
00072     
00077     virtual void Delete();
00078     virtual ~SCA_PropertySensor();
00079     virtual CValue* GetReplica();
00080     virtual void Init();
00081     void    PrecalculateRangeExpression();
00082     bool    CheckPropertyCondition();
00083 
00084     virtual bool Evaluate();
00085     virtual bool    IsPositiveTrigger();
00086     virtual CValue*     FindIdentifier(const STR_String& identifiername);
00087 
00088 #ifdef WITH_PYTHON
00089 
00090     /* --------------------------------------------------------------------- */
00091     /* Python interface ---------------------------------------------------- */
00092     /* --------------------------------------------------------------------- */
00093 
00097     static int validValueForProperty(void* self, const PyAttributeDef*);
00098 
00102     static int validValueForIntervalProperty(void* self, const PyAttributeDef*);
00103 
00107     static int modeChange(void* self, const PyAttributeDef* attrdef);
00108 
00109 #endif
00110 };
00111 
00112 #endif
00113