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


C++ ContainerStoreIterator::getCellRef方法代码示例

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


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

示例1:

int MWWorld::ContainerStore::restockCount(const std::string &id)
{
    int total=0;
    for (MWWorld::ContainerStoreIterator iter (begin()); iter!=end(); ++iter)
        if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), id))
            if (iter->getCellRef().getSoul().empty())
                total += iter->getRefData().getCount();
    return total;
}
开发者ID:EmperorArthur,项目名称:openmw,代码行数:9,代码来源:containerstore.cpp

示例2: execute

                virtual void execute (Interpreter::Runtime& runtime)
                {

                    MWWorld::Ptr ptr = R()(runtime);

                    std::string soul = runtime.getStringLiteral (runtime[0].mInteger);
                    runtime.pop();

                    MWWorld::ContainerStore& store = MWWorld::Class::get (ptr).getContainerStore (ptr);


                    for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter)
                    {
                        if (::Misc::StringUtils::ciEqual(iter->getCellRef().mSoul, soul))
                        {

                            if(iter->getRefData().getCount() <= 1)
                            {
                                MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
                                iter->getRefData().setCount(0);
                            }
                            else
                            {
                                int original = iter->getRefData().getCount();
                                iter->getRefData().setCount(1);
                                MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
                                iter->getRefData().setCount(original - 1);
                            }

                            break;
                        }
                    }
                }
开发者ID:UIKit0,项目名称:openmw,代码行数:33,代码来源:miscextensions.cpp

示例3: addOrRemoveGold

    void TradeWindow::addOrRemoveGold(int amount)
    {
        bool goldFound = false;
        MWWorld::Ptr gold;
        MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
        MWWorld::ContainerStore& playerStore = MWWorld::Class::get(player).getContainerStore(player);

        for (MWWorld::ContainerStoreIterator it = playerStore.begin();
                it != playerStore.end(); ++it)
        {
            if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, "gold_001"))
            {
                goldFound = true;
                gold = *it;
            }
        }
        if (goldFound)
        {
            gold.getRefData().setCount(gold.getRefData().getCount() + amount);
        }
        else
        {
            assert(amount > 0);
            MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001");
            ref.getPtr().getRefData().setCount(amount);
            playerStore.add(ref.getPtr());
        }
    }
开发者ID:tdunn19,项目名称:openmw,代码行数:28,代码来源:tradewindow.cpp

示例4: moveProjectiles

    void ProjectileManager::moveProjectiles(float duration)
    {
        for (std::vector<ProjectileState>::iterator it = mProjectiles.begin(); it != mProjectiles.end();)
        {
            // gravity constant - must be way lower than the gravity affecting actors, since we're not
            // simulating aerodynamics at all
            it->mVelocity -= osg::Vec3f(0, 0, 627.2f * 0.1f) * duration;

            osg::Vec3f pos(it->mNode->getPosition());
            osg::Vec3f newPos = pos + it->mVelocity * duration;

            osg::Quat orient;
            orient.makeRotate(osg::Vec3f(0,1,0), it->mVelocity);
            it->mNode->setAttitude(orient);
            it->mNode->setPosition(newPos);

            update(*it, duration);

            MWWorld::Ptr caster = it->getCaster();

            // Check for impact
            // TODO: use a proper btRigidBody / btGhostObject?
            MWPhysics::PhysicsSystem::RayResult result = mPhysics->castRay(pos, newPos, caster, 0xff, MWPhysics::CollisionType_Projectile);

            bool underwater = MWBase::Environment::get().getWorld()->isUnderwater(MWMechanics::getPlayer().getCell(), newPos);
            if (result.mHit || underwater)
            {
                if (result.mHit)
                {
                    MWWorld::ManualRef projectileRef(MWBase::Environment::get().getWorld()->getStore(), it->mId);

                    // Try to get a Ptr to the bow that was used. It might no longer exist.
                    MWWorld::Ptr bow = projectileRef.getPtr();
                    if (!caster.isEmpty())
                    {
                        MWWorld::InventoryStore& inv = caster.getClass().getInventoryStore(caster);
                        MWWorld::ContainerStoreIterator invIt = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
                        if (invIt != inv.end() && Misc::StringUtils::ciEqual(invIt->getCellRef().getRefId(), it->mBowId))
                            bow = *invIt;
                    }

                    if (caster.isEmpty())
                        caster = result.mHitObject;

                    MWMechanics::projectileHit(caster, result.mHitObject, bow, projectileRef.getPtr(), result.mHitPos, it->mAttackStrength);
                }

                if (underwater)
                    mRendering->emitWaterRipple(newPos);

                mParent->removeChild(it->mNode);
                it = mProjectiles.erase(it);
                continue;
            }

            ++it;
        }
    }
开发者ID:gr4bb,项目名称:openmw,代码行数:58,代码来源:projectilemanager.cpp

示例5: action

    boost::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr,
        const MWWorld::Ptr& actor) const
    {
        const std::string lockedSound = "LockedChest";
        const std::string trapActivationSound = "Disarm Trap Fail";

        MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer();
        MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);

        bool needKey = ptr.getCellRef().lockLevel>0;
        bool hasKey = false;
        std::string keyName;
        for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
        {
            if (it->getCellRef ().refID == ptr.getCellRef().key)
            {
                hasKey = true;
                keyName = MWWorld::Class::get(*it).getName(*it);
            }
        }

        if (needKey && hasKey)
        {
            MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}", std::vector<std::string>());
            ptr.getCellRef().lockLevel = 0;
            // using a key disarms the trap
            ptr.getCellRef().trap = "";
        }


        if (!needKey || hasKey)
        {
            if(ptr.getCellRef().trap.empty())
            {
                boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
                return action;
            }
            else
            {
                // Trap activation goes here
                std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
                boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
                action->setSound(trapActivationSound);
                ptr.getCellRef().trap = "";
                return action;
            }
        }
        else
        {
            boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
            action->setSound(lockedSound);
            return action;
        }
    }
开发者ID:Manbeardo,项目名称:openmw,代码行数:54,代码来源:container.cpp

示例6: getPlayerGold

    int InventoryWindow::getPlayerGold()
    {
        MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);

        for (MWWorld::ContainerStoreIterator it = invStore.begin();
                it != invStore.end(); ++it)
        {
            if (toLower(it->getCellRef().refID) == "gold_001")
                return it->getRefData().getCount();
        }
        return 0;
    }
开发者ID:angeld29,项目名称:openmw,代码行数:12,代码来源:inventorywindow.cpp

示例7: getPlayerGold

    int InventoryWindow::getPlayerGold()
    {
        MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);

        for (MWWorld::ContainerStoreIterator it = invStore.begin();
                it != invStore.end(); ++it)
        {
            if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, "gold_001"))
                return it->getRefData().getCount();
        }
        return 0;
    }
开发者ID:4DA,项目名称:openmw,代码行数:12,代码来源:inventorywindow.cpp

示例8: execute

                virtual void execute (Interpreter::Runtime& runtime)
                {
                    MWWorld::Ptr ptr = R()(runtime);

                    std::string item = runtime.getStringLiteral (runtime[0].mInteger);
                    runtime.pop();

                    MWWorld::ContainerStore& store = MWWorld::Class::get (ptr).getContainerStore (ptr);

                    Interpreter::Type_Integer sum = 0;

                    for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter)
                        if (Misc::StringUtils::ciEqual(iter->getCellRef().mRefID, item))
                            sum += iter->getRefData().getCount();

                    runtime.push (sum);
                }
开发者ID:4DA,项目名称:openmw,代码行数:17,代码来源:containerextensions.cpp

示例9: payForEnchantment

    void Enchanting::payForEnchantment() const
    {
        MWWorld::Ptr gold;

        MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
        MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);

        for (MWWorld::ContainerStoreIterator it = store.begin();
                it != store.end(); ++it)
        {
            if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, "gold_001"))
            {
                gold = *it;
            }
        }

        gold.getRefData().setCount(gold.getRefData().getCount() - getEnchantPrice());
    }
开发者ID:IanPAOConnor,项目名称:openmw,代码行数:18,代码来源:enchanting.cpp

示例10: execute

                virtual void execute(Interpreter::Runtime &runtime)
                {
                    MWWorld::Ptr ptr = R()(runtime);

                    std::string item = runtime.getStringLiteral (runtime[0].mInteger);
                    runtime.pop();

                    MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
                    MWWorld::ContainerStoreIterator it = invStore.begin();
                    for (; it != invStore.end(); ++it)
                    {
                        if (::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), item))
                            break;
                    }
                    if (it == invStore.end())
                        throw std::runtime_error("Item to equip not found");

                    MWWorld::ActionEquip action (*it);
                    action.execute(ptr);

                    if (ptr.getRefData().getHandle() == "player" && !ptr.getClass().getScript(ptr).empty())
                        ptr.getRefData().getLocals().setVarByInt(ptr.getClass().getScript(ptr), "onpcequip", 1);
                }
开发者ID:0xmono,项目名称:openmw,代码行数:23,代码来源:containerextensions.cpp

示例11: action

boost::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr,
        const MWWorld::Ptr& actor) const
{
    if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
        return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());

    const std::string lockedSound = "LockedChest";
    const std::string trapActivationSound = "Disarm Trap Fail";

    MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer();
    MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);

    bool needKey = ptr.getCellRef().mLockLevel>0;
    bool hasKey = false;
    std::string keyName;

    // make key id lowercase
    std::string keyId = ptr.getCellRef().mKey;
    Misc::StringUtils::toLower(keyId);
    for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
    {
        std::string refId = it->getCellRef().mRefID;
        Misc::StringUtils::toLower(refId);
        if (refId == keyId)
        {
            hasKey = true;
            keyName = MWWorld::Class::get(*it).getName(*it);
        }
    }

    if (needKey && hasKey)
    {
        MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}");
        ptr.getCellRef().mLockLevel = 0;
        // using a key disarms the trap
        ptr.getCellRef().mTrap = "";
    }


    if (!needKey || hasKey)
    {
        if(ptr.getCellRef().mTrap.empty())
        {
            boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
            return action;
        }
        else
        {
            // Trap activation goes here
            std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl;
            boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction);
            action->setSound(trapActivationSound);
            ptr.getCellRef().mTrap = "";
            return action;
        }
    }
    else
    {
        boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction);
        action->setSound(lockedSound);
        return action;
    }
}
开发者ID:jhooks1,项目名称:openmw,代码行数:63,代码来源:container.cpp

示例12: action

    boost::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr,
        const MWWorld::Ptr& actor) const
    {
        MWWorld::LiveCellRef<ESM::Door> *ref =
            ptr.get<ESM::Door>();

        const std::string &openSound = ref->mBase->mOpenSound;
        //const std::string &closeSound = ref->mBase->closeSound;
        const std::string lockedSound = "LockedDoor";
        const std::string trapActivationSound = "Disarm Trap Fail";

        MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer();
        MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);

        bool needKey = ptr.getCellRef().mLockLevel>0;
        bool hasKey = false;
        std::string keyName;

        // make key id lowercase
        std::string keyId = ptr.getCellRef().mKey;
        std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower);
        for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
        {
            std::string refId = it->getCellRef().mRefID;
            std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower);
            if (refId == keyId)
            {
                hasKey = true;
                keyName = MWWorld::Class::get(*it).getName(*it);
            }
        }

        if (needKey && hasKey)
        {
            MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}", std::vector<std::string>());
            ptr.getCellRef().mLockLevel = 0;
            // using a key disarms the trap
            ptr.getCellRef().mTrap = "";
        }

        if (!needKey || hasKey)
        {
            if(!ptr.getCellRef().mTrap.empty())
            {
                // Trap activation
                std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl;

                boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);

                action->setSound(trapActivationSound);
                ptr.getCellRef().mTrap = "";

                return action;
            }

            if (ref->mRef.mTeleport)
            {
                // teleport door
                /// \todo remove this if clause once ActionTeleport can also support other actors
                if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor)
                {
                    boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ref->mRef.mDestCell, ref->mRef.mDoorDest));

                    action->setSound(openSound);

                    return action;
                }
                else
                {
                    // another NPC or a creature is using the door
                    return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
                }
            }
            else
            {
                // animated door
                // TODO return action for rotating the door

                // This is a little pointless, but helps with testing
                boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);

                action->setSound(openSound);

                return action;
            }
        }
        else
        {
            // locked, and we can't open.
            boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
            action->setSound(lockedSound);
            return action;
        }
    }
开发者ID:Gohan1989,项目名称:openmw,代码行数:94,代码来源:door.cpp

示例13: moveProjectiles

    void ProjectileManager::moveProjectiles(float duration)
    {
        for (std::vector<ProjectileState>::iterator it = mProjectiles.begin(); it != mProjectiles.end();)
        {
            // gravity constant - must be way lower than the gravity affecting actors, since we're not
            // simulating aerodynamics at all
            it->mVelocity -= Ogre::Vector3(0, 0, 627.2f * 0.1f) * duration;

            Ogre::Vector3 pos(it->mNode->getPosition());
            Ogre::Vector3 newPos = pos + it->mVelocity * duration;

            Ogre::Quaternion orient = Ogre::Vector3::UNIT_Y.getRotationTo(it->mVelocity);
            it->mNode->setOrientation(orient);
            it->mNode->setPosition(newPos);

            update(it->mObject, duration);

            // Check for impact
            // TODO: use a proper btRigidBody / btGhostObject?
            btVector3 from(pos.x, pos.y, pos.z);
            btVector3 to(newPos.x, newPos.y, newPos.z);
            std::vector<std::pair<float, std::string> > collisions = mPhysEngine.rayTest2(from, to, OEngine::Physic::CollisionType_Projectile);
            bool hit=false;

            for (std::vector<std::pair<float, std::string> >::iterator cIt = collisions.begin(); cIt != collisions.end() && !hit; ++cIt)
            {
                MWWorld::Ptr obstacle = MWBase::Environment::get().getWorld()->searchPtrViaHandle(cIt->second);

                MWWorld::Ptr caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(it->mActorId);

                // Arrow intersects with player immediately after shooting :/
                if (obstacle == caster)
                    continue;

                MWWorld::ManualRef projectileRef(MWBase::Environment::get().getWorld()->getStore(), it->mId);

                // Try to get a Ptr to the bow that was used. It might no longer exist.
                MWWorld::Ptr bow = projectileRef.getPtr();
                if (!caster.isEmpty())
                {
                    MWWorld::InventoryStore& inv = caster.getClass().getInventoryStore(caster);
                    MWWorld::ContainerStoreIterator invIt = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
                    if (invIt != inv.end() && Misc::StringUtils::ciEqual(invIt->getCellRef().getRefId(), it->mBowId))
                        bow = *invIt;
                }

                if (caster.isEmpty())
                    caster = obstacle;

                MWMechanics::projectileHit(caster, obstacle, bow, projectileRef.getPtr(), pos + (newPos - pos) * cIt->first);

                hit = true;
            }
            if (hit)
            {
                mSceneMgr->destroySceneNode(it->mNode);

                it = mProjectiles.erase(it);
                continue;
            }
            else
                ++it;
        }
    }
开发者ID:mellotanica,项目名称:openmw,代码行数:64,代码来源:projectilemanager.cpp

示例14: runtime_error

int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) const
{
    MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();

    switch (select.getFunction())
    {
        case SelectWrapper::Function_Journal:

            return MWBase::Environment::get().getJournal()->getJournalIndex (select.getName());

        case SelectWrapper::Function_Item:
        {
            MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player);

            int sum = 0;

            std::string name = select.getName();

            for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter)
                if (Misc::StringUtils::lowerCase(iter->getCellRef().mRefID) == name)
                    sum += iter->getRefData().getCount();

            return sum;
        }

        case SelectWrapper::Function_Dead:

            return MWBase::Environment::get().getMechanicsManager()->countDeaths (select.getName());

        case SelectWrapper::Function_Choice:

            return mChoice;

        case SelectWrapper::Function_AiSetting:

            return MWWorld::Class::get (mActor).getCreatureStats (mActor).getAiSetting (select.getArgument());

        case SelectWrapper::Function_PcAttribute:

            return MWWorld::Class::get (player).getCreatureStats (player).
                getAttribute (select.getArgument()).getModified();

        case SelectWrapper::Function_PcSkill:

            return static_cast<int> (MWWorld::Class::get (player).
                getNpcStats (player).getSkill (select.getArgument()).getModified());

        case SelectWrapper::Function_FriendlyHit:
        {
            int hits = MWWorld::Class::get (mActor).getCreatureStats (mActor).getFriendlyHits();

            return hits>4 ? 4 : hits;
        }

        case SelectWrapper::Function_PcLevel:

            return MWWorld::Class::get (player).getCreatureStats (player).getLevel();

        case SelectWrapper::Function_PcGender:

            return player.get<ESM::NPC>()->mBase->isMale() ? 0 : 1;

        case SelectWrapper::Function_PcClothingModifier:
        {
            MWWorld::InventoryStore& store = MWWorld::Class::get (player).getInventoryStore (player);

            int value = 0;

            for (int i=0; i<=15; ++i) // everything except thigns held in hands and amunition
            {
                MWWorld::ContainerStoreIterator slot = store.getSlot (i);

                if (slot!=store.end())
                    value += MWWorld::Class::get (*slot).getValue (*slot);
            }

            return value;
        }

        case SelectWrapper::Function_PcCrimeLevel:

            return MWWorld::Class::get (player).getNpcStats (player).getBounty();

        case SelectWrapper::Function_RankRequirement:
        {
            if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
                return 0;

            std::string faction =
                MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;

            int rank = getFactionRank (player, faction);

            if (rank>=9)
                return 0; // max rank

            int result = 0;

            if (hasFactionRankSkillRequirements (player, faction, rank+1))
                result += 1;
//.........这里部分代码省略.........
开发者ID:Adrian-Revk,项目名称:openmw,代码行数:101,代码来源:filter.cpp

示例15: unlock

    boost::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr,
        const MWWorld::Ptr& actor) const
    {
        MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();

        const std::string &openSound = ref->mBase->mOpenSound;
        const std::string &closeSound = ref->mBase->mCloseSound;
        const std::string lockedSound = "LockedDoor";
        const std::string trapActivationSound = "Disarm Trap Fail";

        MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);

        bool needKey = ptr.getCellRef().getLockLevel() > 0;
        bool hasKey = false;
        std::string keyName;

        // make key id lowercase
        std::string keyId = ptr.getCellRef().getKey();
        Misc::StringUtils::lowerCaseInPlace(keyId);
        for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
        {
            std::string refId = it->getCellRef().getRefId();
            Misc::StringUtils::lowerCaseInPlace(refId);
            if (refId == keyId)
            {
                hasKey = true;
                keyName = it->getClass().getName(*it);
            }
        }

        if (needKey && hasKey)
        {
            if(actor == MWMechanics::getPlayer())
                MWBase::Environment::get().getWindowManager()->messageBox(keyName + " #{sKeyUsed}");
            unlock(ptr); //Call the function here. because that makes sense.
            // using a key disarms the trap
            ptr.getCellRef().setTrap("");
        }

        if (!needKey || hasKey)
        {
            if(!ptr.getCellRef().getTrap().empty())
            {
                // Trap activation
                boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(actor, ptr.getCellRef().getTrap(), ptr));
                action->setSound(trapActivationSound);
                return action;
            }

            if (ptr.getCellRef().getTeleport())
            {
                boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true));

                action->setSound(openSound);

                return action;
            }
            else
            {
                // animated door
                boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionDoor(ptr));
                int doorstate = getDoorState(ptr);
                bool opening = true;
                float doorRot = ptr.getRefData().getPosition().rot[2] - ptr.getCellRef().getPosition().rot[2];
                if (doorstate == 1)
                    opening = false;
                if (doorstate == 0 && doorRot != 0)
                    opening = false;

                if (opening)
                {
                    MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr,
                            closeSound, 0.5f);
                    // Doors rotate at 90 degrees per second, so start the sound at
                    // where it would be at the current rotation.
                    float offset = doorRot/(3.14159265f * 0.5f);
                    action->setSoundOffset(offset);
                    action->setSound(openSound);
                }
                else
                {
                    MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr,
                                                openSound, 0.5f);
                    float offset = 1.0f - doorRot/(3.14159265f * 0.5f);
                    action->setSoundOffset(std::max(offset, 0.0f));
                    action->setSound(closeSound);
                }

                return action;
            }
        }
        else
        {
            // locked, and we can't open.
            boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction);
            action->setSound(lockedSound);
            return action;
        }
    }
开发者ID:ChairGraveyard,项目名称:TES3MP,代码行数:99,代码来源:door.cpp


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