Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
| Context not available. | |||||
| #include <stddef.h> | #include <stddef.h> | ||||
| #include "NG_NetworkScene.h" | #include "KX_NetworkMessageScene.h" | ||||
| #include "KX_NetworkMessageActuator.h" | #include "KX_NetworkMessageActuator.h" | ||||
| KX_NetworkMessageActuator::KX_NetworkMessageActuator( | KX_NetworkMessageActuator::KX_NetworkMessageActuator( | ||||
| SCA_IObject* gameobj, // the actuator controlling object | SCA_IObject *gameobj, // the actuator controlling object | ||||
| NG_NetworkScene* networkscene, // needed for replication | KX_NetworkMessageScene *networkscene, // needed for replication | ||||
| const STR_String &toPropName, | const std::string &toPropName, | ||||
| const STR_String &subject, | const std::string &subject, | ||||
| int bodyType, | int bodyType, | ||||
| const STR_String &body) : | const std::string &body) | ||||
| SCA_IActuator(gameobj, KX_ACT_MESSAGE), | :SCA_IActuator(gameobj, KX_ACT_MESSAGE), | ||||
| m_networkscene(networkscene), | m_networkscene(networkscene), | ||||
| m_toPropName(toPropName), | m_toPropName(toPropName), | ||||
| m_subject(subject), | m_subject(subject), | ||||
| Context not available. | |||||
| { | { | ||||
| } | } | ||||
| // returns true if the actuators needs to be running over several frames | /// returns true if the actuators needs to be running over several frames | ||||
| bool KX_NetworkMessageActuator::Update() | bool KX_NetworkMessageActuator::Update() | ||||
| { | { | ||||
| //printf("update messageactuator\n"); | |||||
| bool bNegativeEvent = IsNegativeEvent(); | bool bNegativeEvent = IsNegativeEvent(); | ||||
| RemoveAllEvents(); | RemoveAllEvents(); | ||||
| if (bNegativeEvent) { | if (bNegativeEvent) { | ||||
| return false; // do nothing on negative events | return false; // do nothing on negative events | ||||
| //printf("messageactuator false event\n"); | |||||
| } | } | ||||
| //printf("messageactuator true event\n"); | |||||
| if (m_bPropBody) // ACT_MESG_PROP in DNA_actuator_types.h | // ACT_MESG_PROP in DNA_actuator_types.h | ||||
| { | if (m_bPropBody) { | ||||
| m_networkscene->SendMessage( | m_networkscene->SendMessage( | ||||
| m_toPropName, | m_toPropName, | ||||
| GetParent()->GetName(), | GetParent(), | ||||
| m_subject, | m_subject, | ||||
| GetParent()->GetPropertyText(m_body)); | GetParent()->GetPropertyText(m_body)); | ||||
| } else | } | ||||
| { | else { | ||||
| m_networkscene->SendMessage( | m_networkscene->SendMessage( | ||||
| m_toPropName, | m_toPropName, | ||||
| GetParent()->GetName(), | GetParent(), | ||||
| m_subject, | m_subject, | ||||
| m_body); | m_body); | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| CValue* KX_NetworkMessageActuator::GetReplica() | CValue *KX_NetworkMessageActuator::GetReplica() | ||||
| { | { | ||||
| KX_NetworkMessageActuator* replica = new KX_NetworkMessageActuator(*this); | KX_NetworkMessageActuator *replica = new KX_NetworkMessageActuator(*this); | ||||
| replica->ProcessReplica(); | replica->ProcessReplica(); | ||||
| return replica; | return replica; | ||||
| Context not available. | |||||
| 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_NetworkMessageActuator::Methods[] = { | PyMethodDef KX_NetworkMessageActuator::Methods[] = { | ||||
| {NULL,NULL} // Sentinel | {NULL, NULL} // Sentinel | ||||
| }; | }; | ||||
| PyAttributeDef KX_NetworkMessageActuator::Attributes[] = { | PyAttributeDef KX_NetworkMessageActuator::Attributes[] = { | ||||
| Context not available. | |||||
| KX_PYATTRIBUTE_STRING_RW("subject", 0, 100, false, KX_NetworkMessageActuator, m_subject), | KX_PYATTRIBUTE_STRING_RW("subject", 0, 100, false, KX_NetworkMessageActuator, m_subject), | ||||
| KX_PYATTRIBUTE_BOOL_RW("usePropBody", KX_NetworkMessageActuator, m_bPropBody), | KX_PYATTRIBUTE_BOOL_RW("usePropBody", KX_NetworkMessageActuator, m_bPropBody), | ||||
| KX_PYATTRIBUTE_STRING_RW("body", 0, 16384, false, KX_NetworkMessageActuator, m_body), | KX_PYATTRIBUTE_STRING_RW("body", 0, 16384, false, KX_NetworkMessageActuator, m_body), | ||||
| { NULL } //Sentinel | KX_PYATTRIBUTE_NULL //Sentinel | ||||
| }; | }; | ||||
| #endif // WITH_PYTHON | #endif // WITH_PYTHON | ||||
| Context not available. | |||||