forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvehicle_selector.cpp
33 lines (30 loc) · 1.16 KB
/
vehicle_selector.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "vehicle_selector.h"
#include "map.h"
#include "optional.h"
#include "point.h"
#include "vpart_position.h"
vehicle_selector::vehicle_selector( const tripoint &pos, int radius, bool accessible,
bool visibility_only )
{
map &here = get_map();
for( const tripoint &e : closest_points_first( pos, radius ) ) {
if( !accessible ||
( visibility_only ? here.sees( pos, e, radius ) : here.clear_path( pos, e, radius, 1, 100 ) ) ) {
if( const optional_vpart_position vp = here.veh_at( e ) ) {
data.emplace_back( vp->vehicle(), vp->part_index() );
}
}
}
}
vehicle_selector::vehicle_selector( const tripoint &pos, int radius, bool accessible,
const vehicle &ignore )
{
map &here = get_map();
for( const tripoint &e : closest_points_first( pos, radius ) ) {
if( !accessible || here.clear_path( pos, e, radius, 1, 100 ) ) {
if( const optional_vpart_position vp = here.veh_at( e ) ) {
data.emplace_back( vp->vehicle(), vp->part_index(), &vp->vehicle() == &ignore );
}
}
}
}