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


C++ Item_spawn_data类代码示例

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


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

示例1: item

item Single_item_creator::create_single(int birthday, RecursionList &rec) const
{
    item tmp;
    if (type == S_ITEM) {
        if (id == "corpse") {
            tmp = item::make_corpse( NULL_ID, birthday );
        } else {
            tmp = item(id, birthday);
        }
    } else if (type == S_ITEM_GROUP) {
        if (std::find(rec.begin(), rec.end(), id) != rec.end()) {
            debugmsg("recursion in item spawn list %s", id.c_str());
            return item(null_item_id, birthday);
        }
        rec.push_back(id);
        Item_spawn_data *isd = item_controller->get_group(id);
        if (isd == NULL) {
            debugmsg("unknown item spawn list %s", id.c_str());
            return item(null_item_id, birthday);
        }
        tmp = isd->create_single(birthday, rec);
        rec.erase( rec.end() - 1 );
    } else if (type == S_NONE) {
        return item(null_item_id, birthday);
    }
    if( one_in( 3 ) && tmp.has_flag( "VARSIZE" ) ) {
        tmp.item_tags.insert( "FIT" );
    }
    if (modifier.get() != NULL) {
        modifier->modify(tmp);
    }
    // TODO: change the spawn lists to contain proper references to containers
    tmp = tmp.in_its_container();
    return tmp;
}
开发者ID:Bubbadoo,项目名称:Cataclysm-DDA,代码行数:35,代码来源:item_group.cpp

示例2: rng

Item_spawn_data::ItemList Single_item_creator::create(int birthday, RecursionList &rec) const
{
    ItemList result;
    int cnt = 1;
    if (modifier.get() != NULL) {
        cnt = (modifier->count.first == modifier->count.second) ? modifier->count.first : rng(
                  modifier->count.first, modifier->count.second);
    }
    for( ; cnt > 0; cnt--) {
        if (type == S_ITEM) {
            result.push_back(create_single(birthday, rec));
        } else {
            if (std::find(rec.begin(), rec.end(), id) != rec.end()) {
                debugmsg("recursion in item spawn list %s", id.c_str());
                return result;
            }
            rec.push_back(id);
            Item_spawn_data *isd = item_controller->get_group(id);
            if (isd == NULL) {
                debugmsg("unknown item spawn list %s", id.c_str());
                return result;
            }
            ItemList tmplist = isd->create(birthday, rec);
            if (modifier.get() != NULL) {
                for(ItemList::iterator a = tmplist.begin(); a != tmplist.end(); ++a) {
                    modifier->modify(*a);
                }
            }
            result.insert(result.end(), tmplist.begin(), tmplist.end());
        }
    }
    return result;
}
开发者ID:3721assistant,项目名称:Cataclysm-DDA,代码行数:33,代码来源:item_group.cpp

示例3: if

bool Single_item_creator::remove_item(const Item_tag &itemid)
{
    if (modifier.get() != NULL) {
        if (modifier->remove_item(itemid)) {
            type = S_NONE;
            return true;
        }
    }
    if (type == S_ITEM) {
        if (itemid == id) {
            type = S_NONE;
            return true;
        }
    } else if (type == S_ITEM_GROUP) {
        Item_spawn_data *isd = item_controller->get_group(id);
        if (isd != NULL) {
            isd->remove_item(itemid);
        }
    }
    return type == S_NONE;
}
开发者ID:Bubbadoo,项目名称:Cataclysm-DDA,代码行数:21,代码来源:item_group.cpp

示例4: rng

Item_spawn_data::ItemList Single_item_creator::create( const time_point &birthday,
        RecursionList &rec ) const
{
    ItemList result;
    int cnt = 1;
    if( modifier ) {
        auto modifier_count = modifier->count;
        cnt = ( modifier_count.first == modifier_count.second ) ? modifier_count.first : rng(
                  modifier_count.first, modifier_count.second );
    }
    for( ; cnt > 0; cnt-- ) {
        if( type == S_ITEM ) {
            const auto itm = create_single( birthday, rec );
            if( !itm.is_null() ) {
                result.push_back( itm );
            }
        } else {
            if( std::find( rec.begin(), rec.end(), id ) != rec.end() ) {
                debugmsg( "recursion in item spawn list %s", id.c_str() );
                return result;
            }
            rec.push_back( id );
            Item_spawn_data *isd = item_controller->get_group( id );
            if( isd == nullptr ) {
                debugmsg( "unknown item spawn list %s", id.c_str() );
                return result;
            }
            ItemList tmplist = isd->create( birthday, rec );
            rec.erase( rec.end() - 1 );
            if( modifier ) {
                for( auto &elem : tmplist ) {
                    modifier->modify( elem );
                }
            }
            result.insert( result.end(), tmplist.begin(), tmplist.end() );
        }
    }
    return result;
}
开发者ID:Barhandar,项目名称:Cataclysm-DDA,代码行数:39,代码来源:item_group.cpp


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