本文整理汇总了C++中player::get_item_position方法的典型用法代码示例。如果您正苦于以下问题:C++ player::get_item_position方法的具体用法?C++ player::get_item_position怎么用?C++ player::get_item_position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类player
的用法示例。
在下文中一共展示了player::get_item_position方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inv_s
void game_menus::inv::common( player &p )
{
static const std::set<int> allowed_selections = { { ' ', '.', 'q', '=', '\n', KEY_LEFT, KEY_ESCAPE } };
p.inv.restack( &p );
p.inv.sort();
inventory_pick_selector inv_s( p );
inv_s.add_character_items( p );
inv_s.set_title( _( "Inventory" ) );
int res;
do {
inv_s.set_hint( string_format(
_( "Item hotkeys assigned: <color_ltgray>%d</color>/<color_ltgray>%d</color>" ),
p.allocated_invlets().size(), inv_chars.size() - p.allocated_invlets().size() ) );
const item_location &location = inv_s.execute();
if( location == item_location::nowhere ) {
break;
}
g->refresh_all();
res = g->inventory_item_menu( p.get_item_position( location.get_item() ) );
g->refresh_all();
} while( allowed_selections.count( res ) != 0 );
}
示例2: convert_to_indexes
drop_indexes convert_to_indexes( const player &p, const std::list<act_item> &items )
{
drop_indexes res;
for( const auto &ait : items ) {
const int pos = p.get_item_position( ait.it );
if( pos != INT_MIN && ait.count > 0 ) {
if( res.empty() || res.back().first != pos ) {
res.emplace_back( pos, ait.count );
} else {
res.back().second += ait.count;
}
}
}
return res;
}
示例3: remove_dropping_items
void inventory_drop_selector::remove_dropping_items( player &dummy ) const
{
std::map<item *, int> dummy_dropping;
for( const auto &elem : dropping ) {
dummy_dropping[&dummy.i_at( u.get_item_position( elem.first ) )] = elem.second;
}
for( auto &elem : dummy_dropping ) {
if( elem.first->count_by_charges() ) {
elem.first->mod_charges( -elem.second );
} else {
const int pos = dummy.get_item_position( elem.first );
for( int i = 0; i < elem.second; ++i ) {
dummy.i_rem( pos );
}
}
}
}