Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/GameLogic/SCA_StateActuator.cpp
- This file was moved from source/gameengine/Ketsji/KX_StateActuator.cpp.
| Show All 20 Lines | |||||
| * The Original Code is: all of this file. | * The Original Code is: all of this file. | ||||
| * | * | ||||
| * Contributor(s): none yet. | * Contributor(s): none yet. | ||||
| * | * | ||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| * Actuator to toggle visibility/invisibility of objects | * Actuator to toggle visibility/invisibility of objects | ||||
| */ | */ | ||||
| /** \file gameengine/Ketsji/KX_StateActuator.cpp | /** \file gameengine/GameLogic/SCA_StateActuator.cpp | ||||
| * \ingroup ketsji | * \ingroup gamelogic | ||||
| */ | */ | ||||
| #include "KX_StateActuator.h" | #include "SCA_StateActuator.h" | ||||
| #include "KX_GameObject.h" | #include "KX_GameObject.h" | ||||
| KX_StateActuator::KX_StateActuator( | SCA_StateActuator::SCA_StateActuator(SCA_IObject* gameobj, | ||||
| SCA_IObject* gameobj, | |||||
| int operation, | int operation, | ||||
| unsigned int mask | unsigned int mask | ||||
| ) | ) | ||||
| : SCA_IActuator(gameobj, KX_ACT_STATE), | : SCA_IActuator(gameobj, SCA_ACT_STATE), | ||||
| m_operation(operation), | m_operation(operation), | ||||
| m_mask(mask) | m_mask(mask) | ||||
| { | { | ||||
| // intentionally empty | // intentionally empty | ||||
| } | } | ||||
| KX_StateActuator::~KX_StateActuator( | SCA_StateActuator::~SCA_StateActuator(void) | ||||
| void | |||||
| ) | |||||
| { | { | ||||
| // intentionally empty | // intentionally empty | ||||
| } | } | ||||
| // used to put state actuator to be executed before any other actuators | // used to put state actuator to be executed before any other actuators | ||||
| SG_QList KX_StateActuator::m_stateActuatorHead; | SG_QList SCA_StateActuator::m_stateActuatorHead; | ||||
| CValue* | CValue* SCA_StateActuator::GetReplica(void) | ||||
| KX_StateActuator::GetReplica( | |||||
| void | |||||
| ) | |||||
| { | { | ||||
| KX_StateActuator* replica = new KX_StateActuator(*this); | SCA_StateActuator* replica = new SCA_StateActuator(*this); | ||||
| replica->ProcessReplica(); | replica->ProcessReplica(); | ||||
| return replica; | return replica; | ||||
| } | } | ||||
| bool | bool SCA_StateActuator::Update() | ||||
| KX_StateActuator::Update() | |||||
| { | { | ||||
| bool bNegativeEvent = IsNegativeEvent(); | bool bNegativeEvent = IsNegativeEvent(); | ||||
| unsigned int objMask; | unsigned int objMask; | ||||
| // execution of state actuator means that we are in the execution phase, reset this pointer | // execution of state actuator means that we are in the execution phase, reset this pointer | ||||
| // because all the active actuator of this object will be removed for sure. | // because all the active actuator of this object will be removed for sure. | ||||
| m_gameobj->m_firstState = NULL; | m_gameobj->m_firstState = NULL; | ||||
| RemoveAllEvents(); | RemoveAllEvents(); | ||||
| Show All 21 Lines | default: | ||||
| return false; | return false; | ||||
| } | } | ||||
| obj->SetState(objMask); | obj->SetState(objMask); | ||||
| return false; | return false; | ||||
| } | } | ||||
| // this function is only used to deactivate actuators outside the logic loop | // this function is only used to deactivate actuators outside the logic loop | ||||
| // e.g. when an object is deleted. | // e.g. when an object is deleted. | ||||
| void KX_StateActuator::Deactivate() | void SCA_StateActuator::Deactivate() | ||||
| { | { | ||||
| if (QDelink()) | if (QDelink()) | ||||
| { | { | ||||
| // the actuator was in the active list | // the actuator was in the active list | ||||
| if (m_stateActuatorHead.QEmpty()) | if (m_stateActuatorHead.QEmpty()) | ||||
| // no more state object active | // no more state object active | ||||
| m_stateActuatorHead.Delink(); | m_stateActuatorHead.Delink(); | ||||
| } | } | ||||
| } | } | ||||
| void KX_StateActuator::Activate(SG_DList& head) | void SCA_StateActuator::Activate(SG_DList& head) | ||||
| { | { | ||||
| // sort the state actuators per object on the global list | // sort the state actuators per object on the global list | ||||
| if (QEmpty()) | if (QEmpty()) | ||||
| { | { | ||||
| InsertSelfActiveQList(m_stateActuatorHead, &m_gameobj->m_firstState); | InsertSelfActiveQList(m_stateActuatorHead, &m_gameobj->m_firstState); | ||||
| // add front to make sure it runs before other actuators | // add front to make sure it runs before other actuators | ||||
| head.AddFront(&m_stateActuatorHead); | head.AddFront(&m_stateActuatorHead); | ||||
| } | } | ||||
| } | } | ||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| /* Python functions */ | /* Python functions */ | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| /* Integration hooks ------------------------------------------------------- */ | /* Integration hooks ------------------------------------------------------- */ | ||||
| PyTypeObject KX_StateActuator::Type = { | PyTypeObject SCA_StateActuator::Type = { | ||||
| PyVarObject_HEAD_INIT(NULL, 0) | PyVarObject_HEAD_INIT(NULL, 0) | ||||
| "KX_StateActuator", | "SCA_StateActuator", | ||||
| sizeof(PyObjectPlus_Proxy), | sizeof(PyObjectPlus_Proxy), | ||||
| 0, | 0, | ||||
| py_base_dealloc, | py_base_dealloc, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| py_base_repr, | py_base_repr, | ||||
| 0,0,0,0,0,0,0,0,0, | 0,0,0,0,0,0,0,0,0, | ||||
| Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, | ||||
| 0,0,0,0,0,0,0, | 0,0,0,0,0,0,0, | ||||
| Methods, | Methods, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| &SCA_IActuator::Type, | &SCA_IActuator::Type, | ||||
| 0,0,0,0,0,0, | 0,0,0,0,0,0, | ||||
| py_base_new | py_base_new | ||||
| }; | }; | ||||
| PyMethodDef KX_StateActuator::Methods[] = { | PyMethodDef SCA_StateActuator::Methods[] = { | ||||
| {NULL,NULL} //Sentinel | {NULL,NULL} //Sentinel | ||||
| }; | }; | ||||
| PyAttributeDef KX_StateActuator::Attributes[] = { | PyAttributeDef SCA_StateActuator::Attributes[] = { | ||||
| KX_PYATTRIBUTE_INT_RW("operation",KX_StateActuator::OP_NOP+1,KX_StateActuator::OP_COUNT-1,false,KX_StateActuator,m_operation), | KX_PYATTRIBUTE_INT_RW("operation",SCA_StateActuator::OP_NOP+1,SCA_StateActuator::OP_COUNT-1,false,SCA_StateActuator,m_operation), | ||||
| KX_PYATTRIBUTE_INT_RW("mask",0,0x3FFFFFFF,false,KX_StateActuator,m_mask), | KX_PYATTRIBUTE_INT_RW("mask",0,0x3FFFFFFF,false,SCA_StateActuator,m_mask), | ||||
| { NULL } //Sentinel | { NULL } //Sentinel | ||||
| }; | }; | ||||
| #endif // WITH_PYTHON | #endif // WITH_PYTHON | ||||