本文整理汇总了C++中item::made_of_from_type方法的典型用法代码示例。如果您正苦于以下问题:C++ item::made_of_from_type方法的具体用法?C++ item::made_of_from_type怎么用?C++ item::made_of_from_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item
的用法示例。
在下文中一共展示了item::made_of_from_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move_item
static void move_item( player &p, item &it, int quantity, const tripoint &src,
const tripoint &dest, vehicle *src_veh, int src_part )
{
item leftovers = it;
if( quantity != 0 && it.count_by_charges() ) {
// Reinserting leftovers happens after item removal to avoid stacking issues.
leftovers.charges = it.charges - quantity;
if( leftovers.charges > 0 ) {
it.charges = quantity;
}
} else {
leftovers.charges = 0;
}
// Check that we can pick it up.
if( !it.made_of_from_type( LIQUID ) ) {
p.mod_moves( -move_cost( it, src, dest ) );
put_into_vehicle_or_drop( p, item_drop_reason::deliberate, { it }, dest );
// Remove from map or vehicle.
if( src_veh ) {
src_veh->remove_item( src_part, &it );
} else {
g->m.i_rem( src, &it );
}
}
// If we didn't pick up a whole stack, put the remainder back where it came from.
if( leftovers.charges > 0 ) {
if( src_veh ) {
if( !src_veh->add_item( src_part, leftovers ) ) {
debugmsg( "SortLoot: Source vehicle failed to receive leftover charges." );
}
} else {
g->m.add_item_or_charges( src, leftovers );
}
}
}
示例2: pick_one_up
// Returns false if pickup caused a prompt and the player selected to cancel pickup
bool pick_one_up( const tripoint &pickup_target, item &newit, vehicle *veh,
int cargo_part, int index, int quantity, bool &got_water,
bool &offered_swap, PickupMap &mapPickup, bool autopickup )
{
player &u = g->u;
int moves_taken = 100;
bool picked_up = false;
pickup_answer option = CANCEL;
item leftovers = newit;
const auto wield_check = u.can_wield( newit );
if( newit.invlet != '\0' &&
u.invlet_to_position( newit.invlet ) != INT_MIN ) {
// Existing invlet is not re-usable, remove it and let the code in player.cpp/inventory.cpp
// add a new invlet, otherwise keep the (usable) invlet.
newit.invlet = '\0';
}
if( quantity != 0 && newit.count_by_charges() ) {
// Reinserting leftovers happens after item removal to avoid stacking issues.
leftovers.charges = newit.charges - quantity;
if( leftovers.charges > 0 ) {
newit.charges = quantity;
}
} else {
leftovers.charges = 0;
}
bool did_prompt = false;
newit.charges = u.i_add_to_container( newit, false );
if( newit.is_ammo() && newit.charges == 0 ) {
picked_up = true;
option = NUM_ANSWERS; //Skip the options part
} else if( newit.made_of_from_type( LIQUID ) ) {
got_water = true;
} else if( !u.can_pickWeight( newit, false ) ) {
if( !autopickup ) {
const std::string &explain = string_format( _( "The %s is too heavy!" ),
newit.display_name() );
option = handle_problematic_pickup( newit, offered_swap, explain );
did_prompt = true;
} else {
option = CANCEL;
}
} else if( newit.is_bucket() && !newit.is_container_empty() ) {
if( !autopickup ) {
const std::string &explain = string_format( _( "Can't stash %s while it's not empty" ),
newit.display_name() );
option = handle_problematic_pickup( newit, offered_swap, explain );
did_prompt = true;
} else {
option = CANCEL;
}
} else if( !u.can_pickVolume( newit ) ) {
if( !autopickup ) {
const std::string &explain = string_format( _( "Not enough capacity to stash %s" ),
newit.display_name() );
option = handle_problematic_pickup( newit, offered_swap, explain );
did_prompt = true;
} else {
option = CANCEL;
}
} else {
option = STASH;
}
switch( option ) {
case NUM_ANSWERS:
// Some other option
break;
case CANCEL:
picked_up = false;
break;
case WEAR:
picked_up = !!u.wear_item( newit );
break;
case WIELD:
if( wield_check.success() ) {
picked_up = u.wield( newit );
if( u.weapon.invlet ) {
add_msg( m_info, _( "Wielding %c - %s" ), u.weapon.invlet,
u.weapon.display_name() );
} else {
add_msg( m_info, _( "Wielding - %s" ), u.weapon.display_name() );
}
} else {
add_msg( m_neutral, wield_check.c_str() );
}
break;
case SPILL:
if( newit.is_container_empty() ) {
debugmsg( "Tried to spill contents from an empty container" );
break;
}
picked_up = newit.spill_contents( u );
if( !picked_up ) {
break;
}
//.........这里部分代码省略.........