actually spawning walking trips...

This commit is contained in:
Dustin Carlino 2019-01-21 11:52:23 -08:00
parent 0d297b9dac
commit 4b42f70da4
3 changed files with 22 additions and 3 deletions

View File

@ -48,10 +48,10 @@ impl Plugin for SpawnAgent {
SpawnAgent::Walking(ref raw_from, ref maybe_to) => {
let from = raw_from.clone();
if let Some(ID::Building(id)) = ctx.primary.current_selection {
let map = &ctx.primary.map;
if maybe_to.as_ref().map(|(b, _)| *b != id).unwrap_or(true) {
*self = SpawnAgent::Walking(from, Some((id, None)));
let map = &ctx.primary.map;
let start = map.get_b(from).front_path.sidewalk;
if let Some(path) = Pathfinder::shortest_distance(
map,
@ -70,7 +70,10 @@ impl Plugin for SpawnAgent {
}
if ctx.input.contextual_action(Key::F3, "end the agent here") {
// TODO spawn em
info!(
"Spawning {}",
ctx.primary.sim.seed_trip_just_walking(from, id, map)
);
return false;
}
} else {

View File

@ -213,6 +213,21 @@ impl Sim {
)
}
// TODO This is for tests and interactive UI; rename or move it?
pub fn seed_trip_just_walking(
&mut self,
from_bldg: BuildingID,
to_bldg: BuildingID,
map: &Map,
) -> PedestrianID {
self.spawner.start_trip_just_walking(
self.time.next(),
SidewalkSpot::building(from_bldg, map),
SidewalkSpot::building(to_bldg, map),
&mut self.trips_state,
)
}
pub fn seed_bus_route(&mut self, route: &BusRoute, map: &Map) -> Vec<CarID> {
// TODO throw away the events? :(
let mut events: Vec<Event> = Vec::new();

View File

@ -611,7 +611,7 @@ impl Spawner {
start: SidewalkSpot,
goal: SidewalkSpot,
trips: &mut TripManager,
) {
) -> PedestrianID {
let ped_id = PedestrianID(self.ped_id_counter);
self.ped_id_counter += 1;
@ -622,6 +622,7 @@ impl Spawner {
start,
goal,
));
ped_id
}
// Trip transitions