本文整理汇总了C++中item::is_bucket_nonempty方法的典型用法代码示例。如果您正苦于以下问题:C++ item::is_bucket_nonempty方法的具体用法?C++ item::is_bucket_nonempty怎么用?C++ item::is_bucket_nonempty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item
的用法示例。
在下文中一共展示了item::is_bucket_nonempty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_spillable_contents
bool Pickup::handle_spillable_contents( Character &c, item &it, map &m )
{
if( it.is_bucket_nonempty() ) {
const item &it_cont = it.contents.front();
int num_charges = it_cont.charges;
while( !it.spill_contents( c ) ) {
if( num_charges > it_cont.charges ) {
num_charges = it_cont.charges;
} else {
break;
}
}
// If bucket is still not empty then player opted not to handle the
// rest of the contents
if( it.is_bucket_nonempty() ) {
c.add_msg_player_or_npc(
_( "To avoid spilling its contents, you set your %1$s on the %2$s." ),
_( "To avoid spilling its contents, <npcname> sets their %1$s on the %2$s." ),
it.display_name(), m.name( c.pos() )
);
m.add_item_or_charges( c.pos(), it );
return true;
}
}
return false;
}
示例2: handle_problematic_pickup
pickup_answer handle_problematic_pickup( const item &it, bool &offered_swap,
const std::string &explain )
{
if( offered_swap ) {
return CANCEL;
}
player &u = g->u;
uimenu amenu;
amenu.return_invalid = true;
amenu.selected = 0;
amenu.text = explain;
offered_swap = true;
// @todo Gray out if not enough hands
if( u.is_armed() ) {
amenu.addentry( WIELD, !u.weapon.has_flag( "NO_UNWIELD" ), 'w',
_( "Dispose of %s and wield %s" ), u.weapon.display_name().c_str(),
it.display_name().c_str() );
} else {
amenu.addentry( WIELD, true, 'w', _( "Wield %s" ), it.display_name().c_str() );
}
if( it.is_armor() ) {
amenu.addentry( WEAR, u.can_wear( it ), 'W', _( "Wear %s" ), it.display_name().c_str() );
}
if( it.is_bucket_nonempty() ) {
amenu.addentry( SPILL, u.can_pickVolume( it ), 's', _( "Spill %s, then pick up %s" ),
it.contents.front().tname().c_str(), it.display_name().c_str() );
}
amenu.query();
int choice = amenu.ret;
if( choice <= CANCEL || choice >= NUM_ANSWERS ) {
return CANCEL;
}
return static_cast<pickup_answer>( choice );
}