2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2012-03-01 12:20:18 +00:00
|
|
|
* Ketsji Logic Extension: Network Message Actuator generic implementation
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-25 13:35:59 +00:00
|
|
|
/** \file gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
|
|
|
|
* \ingroup ketsjinet
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-01-27 00:02:25 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "NG_NetworkScene.h"
|
|
|
|
#include "KX_NetworkMessageActuator.h"
|
|
|
|
|
|
|
|
KX_NetworkMessageActuator::KX_NetworkMessageActuator(
|
|
|
|
SCA_IObject* gameobj, // the actuator controlling object
|
|
|
|
NG_NetworkScene* networkscene, // needed for replication
|
|
|
|
const STR_String &toPropName,
|
|
|
|
const STR_String &subject,
|
|
|
|
int bodyType,
|
2009-06-28 11:22:26 +00:00
|
|
|
const STR_String &body) :
|
2009-09-24 21:22:24 +00:00
|
|
|
SCA_IActuator(gameobj, KX_ACT_MESSAGE),
|
2002-10-12 11:37:38 +00:00
|
|
|
m_networkscene(networkscene),
|
|
|
|
m_toPropName(toPropName),
|
|
|
|
m_subject(subject),
|
2009-04-20 15:06:46 +00:00
|
|
|
m_bPropBody(bodyType),
|
2002-10-12 11:37:38 +00:00
|
|
|
m_body(body)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
KX_NetworkMessageActuator::~KX_NetworkMessageActuator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns true if the actuators needs to be running over several frames
|
2004-10-16 11:41:50 +00:00
|
|
|
bool KX_NetworkMessageActuator::Update()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
//printf("update messageactuator\n");
|
|
|
|
bool bNegativeEvent = IsNegativeEvent();
|
|
|
|
RemoveAllEvents();
|
|
|
|
|
|
|
|
if (bNegativeEvent) {
|
|
|
|
return false; // do nothing on negative events
|
|
|
|
//printf("messageactuator false event\n");
|
|
|
|
}
|
|
|
|
//printf("messageactuator true event\n");
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (m_bPropBody) // ACT_MESG_PROP in DNA_actuator_types.h
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
m_networkscene->SendMessage(
|
|
|
|
m_toPropName,
|
|
|
|
GetParent()->GetName(),
|
|
|
|
m_subject,
|
2009-06-08 20:08:19 +00:00
|
|
|
GetParent()->GetPropertyText(m_body));
|
2002-10-12 11:37:38 +00:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
m_networkscene->SendMessage(
|
|
|
|
m_toPropName,
|
|
|
|
GetParent()->GetName(),
|
|
|
|
m_subject,
|
|
|
|
m_body);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CValue* KX_NetworkMessageActuator::GetReplica()
|
|
|
|
{
|
2011-09-01 02:12:53 +00:00
|
|
|
KX_NetworkMessageActuator* replica = new KX_NetworkMessageActuator(*this);
|
2002-10-12 11:37:38 +00:00
|
|
|
replica->ProcessReplica();
|
|
|
|
|
|
|
|
return replica;
|
|
|
|
}
|
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* Python interface --------------------------------------------------- */
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Integration hooks -------------------------------------------------- */
|
|
|
|
PyTypeObject KX_NetworkMessageActuator::Type = {
|
2009-06-08 20:08:19 +00:00
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
2002-10-12 11:37:38 +00:00
|
|
|
"KX_NetworkMessageActuator",
|
2009-04-20 15:06:46 +00:00
|
|
|
sizeof(PyObjectPlus_Proxy),
|
2002-10-12 11:37:38 +00:00
|
|
|
0,
|
2009-04-20 15:06:46 +00:00
|
|
|
py_base_dealloc,
|
2002-10-12 11:37:38 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
2009-04-20 15:06:46 +00:00
|
|
|
py_base_repr,
|
2009-06-29 12:06:46 +00:00
|
|
|
0,0,0,0,0,0,0,0,0,
|
2009-06-28 11:22:26 +00:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
|
|
|
0,0,0,0,0,0,0,
|
|
|
|
Methods,
|
|
|
|
0,
|
|
|
|
0,
|
2009-06-29 12:06:46 +00:00
|
|
|
&SCA_IActuator::Type,
|
|
|
|
0,0,0,0,0,0,
|
|
|
|
py_base_new
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PyMethodDef KX_NetworkMessageActuator::Methods[] = {
|
|
|
|
{NULL,NULL} // Sentinel
|
|
|
|
};
|
|
|
|
|
2009-02-26 09:04:06 +00:00
|
|
|
PyAttributeDef KX_NetworkMessageActuator::Attributes[] = {
|
2012-01-16 05:27:11 +00:00
|
|
|
KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, KX_NetworkMessageActuator, m_toPropName),
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_PYATTRIBUTE_STRING_RW("subject", 0, 100, false, KX_NetworkMessageActuator, m_subject),
|
|
|
|
KX_PYATTRIBUTE_BOOL_RW("usePropBody", KX_NetworkMessageActuator, m_bPropBody),
|
2009-06-17 12:32:28 +00:00
|
|
|
KX_PYATTRIBUTE_STRING_RW("body", 0, 16384, false, KX_NetworkMessageActuator, m_body),
|
2009-02-26 09:04:06 +00:00
|
|
|
{ NULL } //Sentinel
|
|
|
|
};
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#endif // WITH_PYTHON
|