本文整理汇总了C++中Space::addEntityAndEnterWorld方法的典型用法代码示例。如果您正苦于以下问题:C++ Space::addEntityAndEnterWorld方法的具体用法?C++ Space::addEntityAndEnterWorld怎么用?C++ Space::addEntityAndEnterWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Space
的用法示例。
在下文中一共展示了Space::addEntityAndEnterWorld方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __py_createEntity
//-------------------------------------------------------------------------------------
PyObject* Cellapp::__py_createEntity(PyObject* self, PyObject* args)
{
PyObject* params = NULL;
char* entityType = NULL;
SPACE_ID spaceID;
PyObject* position, *direction;
if(!PyArg_ParseTuple(args, "s|I|O|O|O", &entityType, &spaceID, &position, &direction, ¶ms))
{
PyErr_Format(PyExc_TypeError,
"KBEngine::createEntity: args is error! args[scriptName, spaceID, position, direction, states].");
PyErr_PrintEx(0);
return 0;
}
if(entityType == NULL || strlen(entityType) == 0)
{
PyErr_Format(PyExc_TypeError, "KBEngine::createEntity: entityType is NULL.");
PyErr_PrintEx(0);
return 0;
}
Space* space = Spaces::findSpace(spaceID);
if(space == NULL)
{
PyErr_Format(PyExc_TypeError, "KBEngine::createEntity: spaceID %ld not found.", spaceID);
PyErr_PrintEx(0);
return 0;
}
// 创建entity
Entity* pEntity = Cellapp::getSingleton().createEntityCommon(entityType, params, false, 0);
if(pEntity != NULL)
{
Py_INCREF(pEntity);
pEntity->setSpaceID(space->getID());
pEntity->initializeEntity(params);
pEntity->pySetPosition(position);
pEntity->pySetDirection(direction);
// 添加到space
space->addEntityAndEnterWorld(pEntity);
// 有可能在addEntityAndEnterWorld中被销毁了
// 是否能在创建过程中被销毁还需要考虑
if(pEntity->isDestroyed())
{
Py_DECREF(pEntity);
return NULL;
}
}
//Py_XDECREF(params);
return pEntity;
}
示例2: process
//-------------------------------------------------------------------------------------
void FMH_Baseapp_onEntityGetCellFrom_onCreateInNewSpaceFromBaseapp::process()
{
KBE_ASSERT(_e != NULL);
Space* space = Spaces::findSpace(_spaceID);
if(space == NULL)
{
ERROR_MSG(boost::format("FMH_Baseapp_onEntityGetCell::process: not found space(%1%), %2% %3%.\n") %
_spaceID % _e->scriptName() % _e->id());
return;
}
_e->spaceID(space->id());
_e->initializeEntity(params_);
Py_XDECREF(params_);
// Ìí¼Óµ½space
space->addEntityAndEnterWorld(_e);
}
示例3: process
//-------------------------------------------------------------------------------------
void FMH_Baseapp_onEntityGetCellFrom_onCreateInNewSpaceFromBaseapp::process()
{
KBE_ASSERT(_e != NULL);
Space* space = Spaces::findSpace(_spaceID);
if(space == NULL || !space->isGood())
{
ERROR_MSG(fmt::format("FMH_Baseapp_onEntityGetCell::process: not found space({}), {} {}.\n",
_spaceID, _e->scriptName(), _e->id()));
return;
}
_e->spaceID(space->id());
_e->initializeEntity(params_);
Py_XDECREF(params_);
params_ = NULL;
// Ìí¼Óµ½space
space->addEntityAndEnterWorld(_e);
}