本文整理汇总了C++中Space::addEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ Space::addEntity方法的具体用法?C++ Space::addEntity怎么用?C++ Space::addEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Space
的用法示例。
在下文中一共展示了Space::addEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: teleport
//-------------------------------------------------------------------------------------
void Entity::teleport(PyObject_ptr nearbyMBRef, Position3D& pos, Direction3D& dir)
{
SPACE_ID lastSpaceID = this->getSpaceID();
// 如果为None则是entity自己想在本space上跳转到某位置
if(nearbyMBRef == Py_None)
{
this->setPositionAndDirection(pos, dir);
}
else
{
//EntityMailbox* mb = NULL;
SPACE_ID spaceID = 0;
// 如果是entity则一定是在本cellapp上, 可以直接进行操作
if(PyObject_TypeCheck(nearbyMBRef, Entity::getScriptType()))
{
Entity* entity = static_cast<Entity*>(nearbyMBRef);
spaceID = entity->getSpaceID();
if(spaceID == this->getSpaceID())
{
this->setPositionAndDirection(pos, dir);
onTeleportSuccess(nearbyMBRef, lastSpaceID);
}
else
{
this->setPositionAndDirection(pos, dir);
Space* currspace = Spaces::findSpace(this->getSpaceID());
Space* space = Spaces::findSpace(spaceID);
currspace->removeEntity(this);
space->addEntity(this);
onTeleportSuccess(nearbyMBRef, lastSpaceID);
}
}
else
{
if(PyObject_TypeCheck(nearbyMBRef, EntityMailbox::getScriptType()))
{
}
}
}
}
示例2: teleportFromBaseapp
//-------------------------------------------------------------------------------------
void Entity::teleportFromBaseapp(Mercury::Channel* pChannel, COMPONENT_ID cellAppID, ENTITY_ID targetEntityID, COMPONENT_ID sourceBaseAppID)
{
DEBUG_MSG(boost::format("%1%::teleportFromBaseapp: %2%, targetEntityID=%3%, cell=%4%, sourceBaseAppID=%5%.\n") %
this->getScriptName() % this->getID() % targetEntityID % cellAppID % sourceBaseAppID);
SPACE_ID lastSpaceID = this->getSpaceID();
// 如果不在一个cell上
if(cellAppID != g_componentID)
{
Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(cellAppID);
if(cinfos == NULL || cinfos->pChannel == NULL)
{
ERROR_MSG(boost::format("%1%::teleportFromBaseapp: %2%, teleport is error, not found cellapp, targetEntityID, cellAppID=%3%.\n") %
this->getScriptName() % this->getID() % targetEntityID % cellAppID);
_sendBaseTeleportResult(this->getID(), sourceBaseAppID, 0, lastSpaceID);
return;
}
}
else
{
Entity* entity = Cellapp::getSingleton().findEntity(targetEntityID);
if(entity == NULL || entity->isDestroyed())
{
ERROR_MSG(boost::format("%1%::teleportFromBaseapp: %2%, can't found targetEntity(%3%).\n") %
this->getScriptName() % this->getID() % targetEntityID);
_sendBaseTeleportResult(this->getID(), sourceBaseAppID, 0, lastSpaceID);
return;
}
// 找到space
SPACE_ID spaceID = entity->getSpaceID();
// 如果是不同space跳转
if(spaceID != this->getSpaceID())
{
Space* space = Spaces::findSpace(spaceID);
if(space == NULL)
{
ERROR_MSG(boost::format("%1%::teleportFromBaseapp: %2%, can't found space(%3%).\n") %
this->getScriptName() % this->getID() % spaceID);
_sendBaseTeleportResult(this->getID(), sourceBaseAppID, 0, lastSpaceID);
return;
}
Space* currspace = Spaces::findSpace(this->getSpaceID());
currspace->removeEntity(this);
space->addEntity(this);
_sendBaseTeleportResult(this->getID(), sourceBaseAppID, spaceID, lastSpaceID);
}
else
{
WARNING_MSG(boost::format("%1%::teleportFromBaseapp: %2% targetSpace(%3%) == currSpaceID(%4%).\n") %
this->getScriptName() % this->getID() % spaceID % this->getSpaceID());
_sendBaseTeleportResult(this->getID(), sourceBaseAppID, spaceID, lastSpaceID);
}
}
}