本文整理汇总了C++中player::cancel_activity方法的典型用法代码示例。如果您正苦于以下问题:C++ player::cancel_activity方法的具体用法?C++ player::cancel_activity怎么用?C++ player::cancel_activity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类player
的用法示例。
在下文中一共展示了player::cancel_activity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
std::list<item> obtain_activity_items( player_activity &act, player &p )
{
std::list<item> res;
auto items = reorder_for_dropping( p, convert_to_indexes( act ) );
debug_drop_list( items );
while( !items.empty() && ( p.is_npc() || p.moves > 0 || items.front().consumed_moves == 0 ) ) {
const auto &ait = items.front();
p.mod_moves( -ait.consumed_moves );
if( p.is_worn( *ait.it ) ) {
p.takeoff( *ait.it, &res );
} else if( ait.it->count_by_charges() ) {
res.push_back( p.reduce_charges( const_cast<item *>( ait.it ), ait.count ) );
} else {
res.push_back( p.i_rem( ait.it ) );
}
items.pop_front();
}
// Avoid tumbling to the ground. Unload cleanly.
const units::volume excessive_volume = p.volume_carried() - p.volume_capacity();
if( excessive_volume > 0_ml ) {
const auto excess = p.inv.remove_randomly_by_volume( excessive_volume );
res.insert( res.begin(), excess.begin(), excess.end() );
}
// Load anything that remains (if any) into the activity
act.values.clear();
if( !items.empty() ) {
for( const auto &drop : convert_to_indexes( p, items ) ) {
act.values.push_back( drop.first );
act.values.push_back( drop.second );
}
}
// And cancel if its empty. If its not, we modified in place and we will continue
// to resolve the drop next turn. This is different from the pickup logic which
// creates a brand new activity every turn and cancels the old activity
if( act.values.empty() ) {
p.cancel_activity();
}
return res;
}
示例2: while
std::list<item> obtain_activity_items( player_activity &act, player &p )
{
std::list<item> res;
auto items = reorder_for_dropping( p, convert_to_indexes( act ) );
debug_drop_list( items );
while( !items.empty() && ( p.is_npc() || p.moves > 0 || items.front().consumed_moves == 0 ) ) {
const auto &ait = items.front();
p.mod_moves( -ait.consumed_moves );
if( p.is_worn( *ait.it ) ) {
p.takeoff( *ait.it, &res );
} else if( ait.it->count_by_charges() ) {
res.push_back( p.reduce_charges( const_cast<item *>( ait.it ), ait.count ) );
} else {
res.push_back( p.i_rem( ait.it ) );
}
items.pop_front();
}
// Avoid tumbling to the ground. Unload cleanly.
const units::volume excessive_volume = p.volume_carried() - p.volume_capacity();
if( excessive_volume > 0 ) {
const auto excess = p.inv.remove_randomly_by_volume( excessive_volume );
res.insert( res.begin(), excess.begin(), excess.end() );
}
// Load anything that remains (if any) into the activity
act.values.clear();
if( !items.empty() ) {
for( const auto &drop : convert_to_indexes( p, items ) ) {
act.values.push_back( drop.first );
act.values.push_back( drop.second );
}
}
// And either cancel if it's empty, or restart if it's not.
if( act.values.empty() ) {
p.cancel_activity();
} else {
p.assign_activity( act );
}
return res;
}