本文整理汇总了C++中PlayerSAO::getLastGoodPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerSAO::getLastGoodPosition方法的具体用法?C++ PlayerSAO::getLastGoodPosition怎么用?C++ PlayerSAO::getLastGoodPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerSAO
的用法示例。
在下文中一共展示了PlayerSAO::getLastGoodPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessData
//.........这里部分代码省略.........
u16 item = packet[TOSERVER_PLAYERITEM_VALUE].as<u16>();
playersao->setWieldIndex(item);
}
else if(command == TOSERVER_RESPAWN)
{
if(!player->isDead())
return;
RespawnPlayer(peer_id);
actionstream << player->getName() << " respawns at "
<< PP(player->getPosition()/BS) << std::endl;
// ActiveObject is added to environment in AsyncRunStep after
// the previous addition has been successfully removed
}
else if(command == TOSERVER_INTERACT)
{
u8 action;
u16 item_i;
PointedThing pointed;
packet[TOSERVER_INTERACT_ACTION].convert(&action);
packet[TOSERVER_INTERACT_ITEM].convert(&item_i);
packet[TOSERVER_INTERACT_POINTED_THING].convert(&pointed);
if(player->hp == 0)
{
verbosestream<<"TOSERVER_INTERACT: "<<player->getName()
<<" tried to interact, but is dead!"<<std::endl;
return;
}
v3f player_pos = playersao->getLastGoodPosition();
// Update wielded item
playersao->setWieldIndex(item_i);
// Get pointed to node (undefined if not POINTEDTYPE_NODE)
v3s16 p_under = pointed.node_undersurface;
v3s16 p_above = pointed.node_abovesurface;
// Get pointed to object (NULL if not POINTEDTYPE_OBJECT)
ServerActiveObject *pointed_object = NULL;
if(pointed.type == POINTEDTHING_OBJECT)
{
pointed_object = m_env->getActiveObject(pointed.object_id);
if(pointed_object == NULL)
{
verbosestream<<"TOSERVER_INTERACT: "
"pointed object is NULL"<<std::endl;
return;
}
}
v3f pointed_pos_under = player_pos;
v3f pointed_pos_above = player_pos;
if(pointed.type == POINTEDTHING_NODE)
{
pointed_pos_under = intToFloat(p_under, BS);
pointed_pos_above = intToFloat(p_above, BS);
}
else if(pointed.type == POINTEDTHING_OBJECT)
{
pointed_pos_under = pointed_object->getBasePosition();