本文整理汇总了C++中inventory::get_binned_items方法的典型用法代码示例。如果您正苦于以下问题:C++ inventory::get_binned_items方法的具体用法?C++ inventory::get_binned_items怎么用?C++ inventory::get_binned_items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inventory
的用法示例。
在下文中一共展示了inventory::get_binned_items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: has
bool tool_comp::has( const inventory &crafting_inv, int batch,
std::function<void( int )> visitor ) const
{
if( g->u.has_trait( trait_DEBUG_HS ) ) {
return true;
}
if( !by_charges() ) {
return crafting_inv.has_tools( type, std::abs( count ) );
} else {
int charges_found = crafting_inv.charges_of( type, count * batch );
if( charges_found == count * batch ) {
return true;
}
const auto &binned = crafting_inv.get_binned_items();
const auto iter = binned.find( type );
if( iter == binned.end() ) {
return false;
}
bool has_UPS = false;
for( const item *it : iter->second ) {
it->visit_items( [&has_UPS]( const item * e ) {
if( e->has_flag( "USE_UPS" ) ) {
has_UPS = true;
return VisitResponse::ABORT;
}
return VisitResponse::NEXT;
} );
}
if( has_UPS ) {
int UPS_charges_used =
crafting_inv.charges_of( "UPS", ( count * batch ) - charges_found );
if( visitor && UPS_charges_used + charges_found >= ( count * batch ) ) {
visitor( UPS_charges_used );
}
charges_found += UPS_charges_used;
}
return charges_found == count * batch;
}
}