当前位置: 首页>>代码示例>>C++>>正文


C++ MapComposite::getAroundActorIterator方法代码示例

本文整理汇总了C++中MapComposite::getAroundActorIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ MapComposite::getAroundActorIterator方法的具体用法?C++ MapComposite::getAroundActorIterator怎么用?C++ MapComposite::getAroundActorIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MapComposite的用法示例。


在下文中一共展示了MapComposite::getAroundActorIterator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: remove

void GameState::remove(Entity *ptr)
{
    assert(!dbgLockObjects);
    MapComposite *map = ptr->getMap();
    int visualRange = Configuration::getValue("game_visualRange", 448);

    ptr->signal_removed.emit(ptr);

    // DEBUG INFO
    switch (ptr->getType())
    {
        case OBJECT_ITEM:
            LOG_DEBUG("Item removed: "
                   << ptr->getComponent<ItemComponent>()->getItemClass()->getDatabaseID());
            break;

        case OBJECT_NPC:
            LOG_DEBUG("NPC removed: " << ptr->getComponent<NpcComponent>()->getNpcId());
            break;

        case OBJECT_CHARACTER:
            LOG_DEBUG("Player removed: "
                      << static_cast<Being*>(ptr)->getName());
            break;

        case OBJECT_EFFECT:
            LOG_DEBUG("Effect removed: "
                      << ptr->getComponent<EffectComponent>()->getEffectId());
            break;

        case OBJECT_MONSTER:
            LOG_DEBUG("Monster removed: "
                      << static_cast<Monster*>(ptr)->getSpecy()->getId());
            break;

        case OBJECT_ACTOR:
        case OBJECT_OTHER:
        default:
            LOG_DEBUG("Entity removed: " << ptr->getType());
            break;
    }

    if (ptr->canMove())
    {
        if (ptr->getType() == OBJECT_CHARACTER)
        {
            static_cast< Character * >(ptr)->cancelTransaction();

            // remove characters online status
            accountHandler->updateOnlineStatus(
                static_cast< Character * >(ptr)->getDatabaseID(), false);
        }

        Actor *obj = static_cast< Actor * >(ptr);
        MessageOut msg(GPMSG_BEING_LEAVE);
        msg.writeInt16(obj->getPublicID());
        Point objectPos = obj->getPosition();

        for (CharacterIterator p(map->getAroundActorIterator(obj, visualRange));
             p; ++p)
        {
            if (*p != obj && objectPos.inRangeOf((*p)->getPosition(),
                visualRange))
            {
                gameHandler->sendTo(*p, msg);
            }
        }
    }
    else if (ptr->getType() == OBJECT_ITEM)
    {
        Actor *actor = static_cast<Actor*>(ptr);
        Point pos = actor->getPosition();
        MessageOut msg(GPMSG_ITEMS);
        msg.writeInt16(0);
        msg.writeInt16(pos.x);
        msg.writeInt16(pos.y);

        for (CharacterIterator p(map->getAroundActorIterator(actor, visualRange)); p; ++p)
        {
            if (pos.inRangeOf((*p)->getPosition(), visualRange))
            {
                gameHandler->sendTo(*p, msg);
            }
        }
    }

    map->remove(ptr);
}
开发者ID:hanwujunlc,项目名称:manaserv,代码行数:88,代码来源:state.cpp


注:本文中的MapComposite::getAroundActorIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。