本文整理汇总了C++中player::get_pathfinding_settings方法的典型用法代码示例。如果您正苦于以下问题:C++ player::get_pathfinding_settings方法的具体用法?C++ player::get_pathfinding_settings怎么用?C++ player::get_pathfinding_settings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类player
的用法示例。
在下文中一共展示了player::get_pathfinding_settings方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::vector<tripoint> route_adjacent( const player &p, const tripoint &dest )
{
auto passable_tiles = std::unordered_set<tripoint>();
for( const tripoint &tp : g->m.points_in_radius( dest, 1 ) ) {
if( tp != p.pos() && g->m.passable( tp ) ) {
passable_tiles.emplace( tp );
}
}
const auto &sorted = get_sorted_tiles_by_distance( p.pos(), passable_tiles );
const auto &avoid = p.get_path_avoid();
for( const tripoint &tp : sorted ) {
auto route = g->m.route( p.pos(), tp, p.get_pathfinding_settings(), avoid );
if( !route.empty() ) {
return route;
}
}
return std::vector<tripoint>();
}
示例2: activity_on_turn_move_loot
void activity_on_turn_move_loot( player_activity &, player &p )
{
const activity_id act_move_loot = activity_id( "ACT_MOVE_LOOT" );
auto &mgr = zone_manager::get_manager();
if( g->m.check_vehicle_zones( g->get_levz() ) ) {
mgr.cache_vzones();
}
const auto abspos = g->m.getabs( p.pos() );
const auto &src_set = mgr.get_near( zone_type_id( "LOOT_UNSORTED" ), abspos );
vehicle *src_veh, *dest_veh;
int src_part, dest_part;
// Nuke the current activity, leaving the backlog alone.
p.activity = player_activity();
// sort source tiles by distance
const auto &src_sorted = get_sorted_tiles_by_distance( abspos, src_set );
if( !mgr.is_sorting() ) {
mgr.start_sort( src_sorted );
}
for( auto &src : src_sorted ) {
const auto &src_loc = g->m.getlocal( src );
if( !g->m.inbounds( src_loc ) ) {
if( !g->m.inbounds( p.pos() ) ) {
// p is implicitly an NPC that has been moved off the map, so reset the activity
// and unload them
p.assign_activity( act_move_loot );
p.set_moves( 0 );
g->reload_npcs();
mgr.end_sort();
return;
}
std::vector<tripoint> route;
route = g->m.route( p.pos(), src_loc, p.get_pathfinding_settings(),
p.get_path_avoid() );
if( route.empty() ) {
// can't get there, can't do anything, skip it
continue;
}
p.set_destination( route, player_activity( act_move_loot ) );
mgr.end_sort();
return;
}
bool is_adjacent_or_closer = square_dist( p.pos(), src_loc ) <= 1;
// skip tiles in IGNORE zone and tiles on fire
// (to prevent taking out wood off the lit brazier)
// and inaccessible furniture, like filled charcoal kiln
if( mgr.has( zone_type_id( "LOOT_IGNORE" ), src ) ||
g->m.get_field( src_loc, fd_fire ) != nullptr ||
!g->m.can_put_items_ter_furn( src_loc ) ) {
continue;
}
// the boolean in this pair being true indicates the item is from a vehicle storage space
auto items = std::vector<std::pair<item *, bool>>();
//Check source for cargo part
//map_stack and vehicle_stack are different types but inherit from item_stack
// TODO: use one for loop
if( const cata::optional<vpart_reference> vp = g->m.veh_at( src_loc ).part_with_feature( "CARGO",
false ) ) {
src_veh = &vp->vehicle();
src_part = vp->part_index();
for( auto &it : src_veh->get_items( src_part ) ) {
items.push_back( std::make_pair( &it, true ) );
}
} else {
src_veh = nullptr;
src_part = -1;
}
for( auto &it : g->m.i_at( src_loc ) ) {
items.push_back( std::make_pair( &it, false ) );
}
//Skip items that have already been processed
for( auto it = items.begin() + mgr.get_num_processed( src ); it < items.end(); it++ ) {
mgr.increment_num_processed( src );
const auto thisitem = it->first;
if( thisitem->made_of_from_type( LIQUID ) ) { // skip unpickable liquid
continue;
}
// Only if it's from a vehicle do we use the vehicle source location information.
vehicle *this_veh = it->second ? src_veh : nullptr;
const int this_part = it->second ? src_part : -1;
const auto id = mgr.get_near_zone_type_for_item( *thisitem, abspos );
// checks whether the item is already on correct loot zone or not
// if it is, we can skip such item, if not we move the item to correct pile
// think empty bag on food pile, after you ate the content
if( !mgr.has( id, src ) ) {
const auto &dest_set = mgr.get_near( id, abspos );
//.........这里部分代码省略.........