本文整理汇总了C++中ItemList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemList::insert方法的具体用法?C++ ItemList::insert怎么用?C++ ItemList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
Item_spawn_data::ItemList Item_group::create( const time_point &birthday, RecursionList &rec ) const
{
ItemList result;
if( type == G_COLLECTION ) {
for( const auto &elem : items ) {
if( rng( 0, 99 ) >= ( elem )->probability ) {
continue;
}
ItemList tmp = ( elem )->create( birthday, rec );
result.insert( result.end(), tmp.begin(), tmp.end() );
}
} else if( type == G_DISTRIBUTION ) {
int p = rng( 0, sum_prob - 1 );
for( const auto &elem : items ) {
p -= ( elem )->probability;
if( p >= 0 ) {
continue;
}
ItemList tmp = ( elem )->create( birthday, rec );
result.insert( result.end(), tmp.begin(), tmp.end() );
break;
}
}
return result;
}
示例2: create
Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) const
{
ItemList result;
if (type == G_COLLECTION) {
for(prop_list::const_iterator a = items.begin(); a != items.end(); ++a) {
if(rng(0, 99) >= (*a)->probability) {
continue;
}
ItemList tmp = (*a)->create(birthday, rec);
result.insert(result.end(), tmp.begin(), tmp.end());
}
} else if (type == G_DISTRIBUTION) {
int p = rng(0, sum_prob - 1);
for(prop_list::const_iterator a = items.begin(); a != items.end(); ++a) {
p -= (*a)->probability;
if (p >= 0) {
continue;
}
ItemList tmp = (*a)->create(birthday, rec);
result.insert(result.end(), tmp.begin(), tmp.end());
break;
}
}
if (with_ammo && !result.empty()) {
it_gun *maybe_gun = dynamic_cast<it_gun *>(result.front().type);
if (maybe_gun != NULL) {
item ammo(default_ammo(maybe_gun->ammo), birthday);
// TODO: change the spawn lists to contain proper references to containers
ammo = ammo.in_its_container();
result.push_back(ammo);
}
}
return result;
}
示例3: create
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;
}
示例4: create
Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) const
{
ItemList result;
if (type == G_COLLECTION) {
for( const auto &elem : items ) {
if( rng( 0, 99 ) >= ( elem )->probability ) {
continue;
}
ItemList tmp = ( elem )->create( birthday, rec );
result.insert(result.end(), tmp.begin(), tmp.end());
}
} else if (type == G_DISTRIBUTION) {
int p = rng(0, sum_prob - 1);
for( const auto &elem : items ) {
p -= ( elem )->probability;
if (p >= 0) {
continue;
}
ItemList tmp = ( elem )->create( birthday, rec );
result.insert(result.end(), tmp.begin(), tmp.end());
break;
}
}
for( auto& e : result ) {
bool spawn_ammo = rng( 0, 99 ) < with_ammo;
bool spawn_mags = rng( 0, 99 ) < with_magazine || spawn_ammo;
if( spawn_mags && !e.magazine_integral() && !e.magazine_current() ) {
e.contents.emplace_back( e.magazine_default(), e.bday );
}
if( spawn_ammo && e.ammo_capacity() > 0 && e.ammo_remaining() == 0 ) {
itype_id ammo = default_ammo( e.ammo_type() );
if( e.magazine_current() ) {
e.magazine_current()->contents.emplace_back( ammo, e.bday, e.ammo_capacity() );
} else {
e.set_curammo( ammo );
e.charges = e.ammo_capacity();
}
}
}
return result;
}
示例5: create
Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) const
{
ItemList result;
if (type == G_COLLECTION) {
for( const auto &elem : items ) {
if( rng( 0, 99 ) >= ( elem )->probability ) {
continue;
}
ItemList tmp = ( elem )->create( birthday, rec );
result.insert(result.end(), tmp.begin(), tmp.end());
}
} else if (type == G_DISTRIBUTION) {
int p = rng(0, sum_prob - 1);
for( const auto &elem : items ) {
p -= ( elem )->probability;
if (p >= 0) {
continue;
}
ItemList tmp = ( elem )->create( birthday, rec );
result.insert(result.end(), tmp.begin(), tmp.end());
break;
}
}
if (with_ammo && !result.empty()) {
const auto t = result.front().type;
if( t->gun ) {
const std::string ammoid = default_ammo( t->gun->ammo );
if ( !ammoid.empty() ) {
item ammo( ammoid, birthday );
// TODO: change the spawn lists to contain proper references to containers
ammo = ammo.in_its_container();
result.push_back( ammo );
}
}
}
return result;
}