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


C++ DroidComponent::getSlottedObject方法代码示例

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


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

示例1: findStimPack

StimPack* DroidStimpackModuleDataComponent::findStimPack() {
    StimPack* pack = NULL;
    float biggest = 0;
    DroidComponent* container = cast<DroidComponent*>(getParent());

    if (container == NULL)
        return NULL;

    ManagedReference<SceneObject*> craftingComponents = container->getSlottedObject("crafted_components");

    if (craftingComponents != NULL) {
        SceneObject* satchel = craftingComponents->getContainerObject(0);

        for (int i = 0; i < satchel->getContainerObjectsSize(); ++i) {
            ManagedReference<SceneObject*> sceno = satchel->getContainerObject(i);

            // is a stimpack
            if (sceno->isPharmaceuticalObject()) {
                PharmaceuticalObject* pharma = sceno.castTo<PharmaceuticalObject*>();

                if (pharma->isStimPack() && !pharma->isPetStimPack() && !pharma->isDroidRepairKit()) {
                    StimPack* stim = cast<StimPack*>(pharma);

                    if (stim->getEffectiveness() > biggest) {
                        biggest = stim->getEffectiveness();
                        pack = stim;
                    }
                }
            }
        }
    }

    return pack;
}
开发者ID:JigglyPoofSWG,项目名称:BSS,代码行数:34,代码来源:DroidStimpackModuleDataComponent.cpp

示例2: compatibleStimpack

StimPack* DroidStimpackModuleDataComponent::compatibleStimpack(float power) {
    DroidComponent* droidComponent = cast<DroidComponent*>(getParent());
    if (droidComponent == NULL) {
        info("droidComponent was null");
        return NULL;
    }
    DroidObject* droid = getDroidObject();
    if (droid == NULL) {
        return NULL;
    }
    Locker dlock(droid);
    ManagedReference<SceneObject*> craftingComponents = droidComponent->getSlottedObject("crafted_components");
    if(craftingComponents != NULL) {
        SceneObject* satchel = craftingComponents->getContainerObject(0);
        if(satchel == NULL) {
            return NULL;
        }
        for (int i = 0; i < satchel->getContainerObjectsSize(); ++i) {
            SceneObject* item = satchel->getContainerObject(i);
            if (!item->isTangibleObject())
                continue;

            TangibleObject* tano = cast<TangibleObject*>( item);
            if (tano->isPharmaceuticalObject()) {
                StimPack* stim = cast<StimPack*>(tano);
                if(stim->getEffectiveness() == power) {
                    return stim;
                }
            }
        }
    }
    return NULL;
}
开发者ID:angelsounds777,项目名称:Core3-CU,代码行数:33,代码来源:DroidStimpackModuleDataComponent.cpp

示例3: initialize

void DroidStimpackModuleDataComponent::initialize(CreatureObject* droid) {
    // grab the crafted components in this module and remove then
    // then change capacity to the new capacity so we store the stims directly in the component.
    DroidComponent* droidComponent = cast<DroidComponent*>(getParent());
    if (droidComponent == NULL) {
        info("droidComponent was null");
        return;
    }
    droidComponent->dropSlottedObject("crafted_components");
    ManagedReference<SceneObject*> craftingComponents = droidComponent->getSlottedObject("crafted_components");
    if(craftingComponents == NULL) {
        // create the satchel and container as it would not be present as this object doesnt use components.
        ManagedReference<SceneObject*> craftingComponentsSatchel = NULL;
        String craftingComponentsPath = "object/tangible/crafting/crafting_components_container.iff";
        craftingComponents = droidComponent->getZoneServer()->createObject(craftingComponentsPath.hashCode(), 1);
        craftingComponents->removeAllContainerObjects();
        craftingComponents->setSendToClient(false);
        droidComponent->transferObject(craftingComponents, 4, false);
        Locker locker(craftingComponents);
        craftingComponents->setContainerDefaultDenyPermission(ContainerPermissions::OPEN + ContainerPermissions::MOVEIN + ContainerPermissions::MOVEOUT + ContainerPermissions::MOVECONTAINER);
        craftingComponents->setContainerDefaultAllowPermission(0);
        craftingComponents->setContainerDenyPermission("owner", ContainerPermissions::OPEN + ContainerPermissions::MOVEIN + ContainerPermissions::MOVEOUT + ContainerPermissions::MOVECONTAINER);
        craftingComponents->setContainerDenyPermission("admin", ContainerPermissions::OPEN + ContainerPermissions::MOVEIN + ContainerPermissions::MOVEOUT + ContainerPermissions::MOVECONTAINER);
        craftingComponents->setContainerAllowPermission("owner", 0);
        craftingComponents->setContainerAllowPermission("admin", 0);
        craftingComponents->setContainerInheritPermissionsFromParent(false);
        locker.release();

        String craftingComponentsSatchelPath = "object/tangible/hopper/crafting_station_hopper/crafting_station_ingredient_hopper_large.iff";
        craftingComponentsSatchel = droidComponent->getZoneServer()->createObject(craftingComponentsSatchelPath.hashCode(), 1);
        Locker locker2(craftingComponentsSatchel);
        craftingComponentsSatchel->setContainerVolumeLimit(capacity);
        craftingComponentsSatchel->setContainerInheritPermissionsFromParent(false);
        craftingComponentsSatchel->setContainerDefaultDenyPermission(ContainerPermissions::OPEN + ContainerPermissions::MOVEIN + ContainerPermissions::MOVEOUT + ContainerPermissions::MOVECONTAINER);
        craftingComponentsSatchel->setContainerDefaultAllowPermission(0);
        craftingComponentsSatchel->setContainerAllowPermission("admin", ContainerPermissions::OPEN);
        craftingComponentsSatchel->setContainerDenyPermission("admin", ContainerPermissions::MOVEIN + ContainerPermissions::MOVEOUT + ContainerPermissions::MOVECONTAINER);
        craftingComponentsSatchel->setContainerAllowPermission("owner", 0);
        craftingComponentsSatchel->setContainerDenyPermission("owner", ContainerPermissions::OPEN + ContainerPermissions::MOVEIN + ContainerPermissions::MOVEOUT + ContainerPermissions::MOVECONTAINER);
        craftingComponentsSatchel->sendTo(droid, true);
        craftingComponents->transferObject(craftingComponentsSatchel, -1, false);
    }
}
开发者ID:angelsounds777,项目名称:Core3-CU,代码行数:43,代码来源:DroidStimpackModuleDataComponent.cpp

示例4: countUses

void DroidStimpackModuleDataComponent::countUses() {
    DroidComponent* droidComponent = cast<DroidComponent*>(getParent());
    if (droidComponent == NULL) {
        info("droidComponent was null");
        return;
    }

    DroidObject* droid = getDroidObject();
    if (droid == NULL) {
        return ;
    }

    Locker dlock(droid);

    ManagedReference<SceneObject*> craftingComponents = droidComponent->getSlottedObject("crafted_components");
    if (craftingComponents == NULL) {
        return;
    }

    SceneObject* satchel = craftingComponents->getContainerObject(0);
    if (satchel == NULL) {
        return;
    }

    loaded = 0;

    for (int i = 0; i < satchel->getContainerObjectsSize(); ++i) {
        ManagedReference<SceneObject*> item = satchel->getContainerObject(i);
        if (!item->isPharmaceuticalObject())
            continue;

        PharmaceuticalObject* pharma = item.castTo<PharmaceuticalObject*>();

        if (pharma->isStimPack())
            loaded += pharma->getUseCount();
    }
}
开发者ID:JigglyPoofSWG,项目名称:BSS,代码行数:37,代码来源:DroidStimpackModuleDataComponent.cpp

示例5: handleInsertStimpack

void DroidStimpackModuleDataComponent::handleInsertStimpack(CreatureObject* player, StimPack* pack) {
    // we need to send the invalid stimpack message just where is a good question
    countUses();

    if (player == NULL)
        return;

    if (!player->hasSkill("science_medic_ability_04")) {
        return;
    }

    ManagedReference<DroidObject*> droid = getDroidObject();
    if (droid == NULL) {
        return;
    }

    if (pack == NULL) {
        player->sendSystemMessage("@pet/droid_modules:invalid_stimpack");
        return;
    }

    if (!pack->isClassA()) {
        player->sendSystemMessage("@pet/droid_modules:invalid_stimpack");
        return;
    }

    if (droid->getLinkedCreature().get() != player) {
        return;
    }

    // we have the player and the stim to add to ourselves.
    // code should goes as follow, count total use of all stims, then deduct amount form capacity
    DroidComponent* droidComponent = cast<DroidComponent*>(getParent());

    if (droidComponent == NULL) {
        return;
    }

    ManagedReference<SceneObject*> craftingComponents = droidComponent->getSlottedObject("crafted_components");

    if (craftingComponents == NULL) {
        return;
    }

    SceneObject* satchel = craftingComponents->getContainerObject(0);

    if (satchel == NULL) {
        return;
    }

    int allowedAmount = capacity - loaded;

    if (allowedAmount <= 0) {
        player->sendSystemMessage("@pet/droid_modules:stimpack_capacity_full");
        return;
    }

    Locker plocker(pack);

    int amountOnStim = pack->getUseCount();
    StimPack* targetStim = compatibleStimpack(pack->getEffectiveness());

    if (targetStim != NULL) {
        Locker tlocker(targetStim);

        if (allowedAmount > amountOnStim) {
            targetStim->setUseCount(targetStim->getUseCount() + amountOnStim, true);
            pack->decreaseUseCount(pack->getUseCount());
        } else {
            targetStim->setUseCount(targetStim->getUseCount() + allowedAmount, true);
            pack->decreaseUseCount(allowedAmount);
        }
    } else {
        // can we take it all?
        if (allowedAmount > amountOnStim) {
            pack->destroyObjectFromWorld(true);
            // transfer to the droid and broadcast, then send the satchel to the player
            satchel->transferObject(pack, -1, true);
            satchel->broadcastObject(pack, true);
            pack->sendTo(player, true);
            droid->sendTo(player, true);
            player->sendSystemMessage("@pet/droid_modules:stimpack_loaded");
        } else {
            // we cant load it all so split the diff
            StimPack* newStim = pack->split(allowedAmount);

            if (newStim != NULL) {
                Locker slocker(newStim);
                satchel->transferObject(newStim, -1, true);
                satchel->broadcastObject(newStim, true);
                player->sendSystemMessage("@pet/droid_modules:stimpack_loaded");
            }
        }
    }

    countUses();
}
开发者ID:JigglyPoofSWG,项目名称:BSS,代码行数:97,代码来源:DroidStimpackModuleDataComponent.cpp


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