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


C++ item::is_container方法代码示例

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


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

示例1: ingest

void stomach_contents::ingest( player &p, item &food, int charges = 1 )
{
    item comest;
    if( food.is_container() ) {
        comest = food.get_contained();
    } else {
        comest = food;
    }
    if( charges == 0 ) {
        // if charges is 0, it means the item is not count_by_charges
        charges = 1;
    }
    // maybe move tapeworm to digestion
    for( const auto &v : p.vitamins_from( comest ) ) {
        vitamins[v.first] += p.has_effect( efftype_id( "tapeworm" ) ) ? v.second / 2 : v.second;
    }
    auto &comest_t = comest.type->comestible;
    const units::volume add_water = std::max( 0_ml, comest_t->quench * 5_ml );
    // if this number is negative, we decrease the quench/increase the thirst of the player
    if( comest_t->quench < 0 ) {
        p.mod_thirst( -comest_t->quench );
    } else {
        mod_quench( comest_t->quench );
    }
    // @TODO: Move quench values to mL and remove the magic number here
    mod_contents( ( comest.base_volume() * charges ) - add_water );

    last_ate = calendar::turn;

    mod_calories( comest_t->get_calories() );
}
开发者ID:Robik81,项目名称:Cataclysm-DDA,代码行数:31,代码来源:stomach.cpp

示例2: switch

/*static*/ bool inventory::has_category(const item& it, item_cat cat, const player& u) {
    switch (cat)
    {
    case IC_COMESTIBLE: // food
        if (it.is_food(&u) || it.is_food_container(&u))
        {
             return true;
        }
        break;
    case IC_AMMO: // ammo
        if (it.is_ammo() || it.is_ammo_container())
        {
             return true;
        }
        break;
    case IC_ARMOR: // armour
        if (it.is_armor())
        {
             return true;
        }
        break;
    case IC_BOOK: // books
        if (it.is_book())
        {
             return true;
        }
        break;
    case IC_TOOL: // tools
        if (it.is_tool())
        {
             return true;
        }
        break;
    case IC_CONTAINER: // containers for liquid handling
        if (it.is_tool() || it.is_gun())
        {
            if (it.ammo_type() == "gasoline")
            {
                return true;
            }
        }
        else
        {
            if (it.is_container())
            {
                return true;
            }
        }
        break;
    }
    return false;
}
开发者ID:tyrael93,项目名称:Cataclysm-DDA,代码行数:52,代码来源:inventory.cpp


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