Track how long cars have been parked in one spot

This commit is contained in:
Dustin Carlino 2020-09-16 09:42:02 -07:00
parent 4beff2b7bf
commit 1331b629aa
5 changed files with 21 additions and 3 deletions

View File

@ -481,7 +481,7 @@ pub fn parked_car(
.align_right(),
]));
// TODO how long idle, prev trips, next trips, etc
// TODO prev trips, next trips, etc
let p = app.primary.sim.get_owner_of_car(id).unwrap();
rows.push(Btn::text_bg2(format!("Owned by {}", p)).build_def(ctx, None));
@ -508,6 +508,14 @@ pub fn parked_car(
);
}
}
rows.push(
format!(
"Parked here for {}",
app.primary.sim.time() - p.parked_since
)
.draw_text(ctx),
);
} else {
rows.push("No longer parked".draw_text(ctx));
}

View File

@ -323,6 +323,7 @@ pub enum ParkingSpot {
pub struct ParkedCar {
pub vehicle: Vehicle,
pub spot: ParkingSpot,
pub parked_since: Time,
}
// It'd be nice to inline the goal_pos like SidewalkSpot does, but DrivingGoal is persisted in

View File

@ -554,6 +554,7 @@ impl DrivingSimState {
ctx.parking.add_parked_car(ParkedCar {
vehicle: car.vehicle.clone(),
spot,
parked_since: now,
});
trips.car_reached_parking_spot(
now,

View File

@ -244,7 +244,11 @@ impl Sim {
}
pub(crate) fn seed_parked_car(&mut self, vehicle: Vehicle, spot: ParkingSpot) {
self.parking.reserve_spot(spot);
self.parking.add_parked_car(ParkedCar { vehicle, spot });
self.parking.add_parked_car(ParkedCar {
vehicle,
spot,
parked_since: self.time,
});
}
pub(crate) fn seed_bus_route(&mut self, route: &BusRoute) {

View File

@ -784,7 +784,11 @@ impl TripManager {
),
));
ctx.parking.reserve_spot(spot);
ctx.parking.add_parked_car(ParkedCar { vehicle, spot });
ctx.parking.add_parked_car(ParkedCar {
vehicle,
spot,
parked_since: now,
});
} else {
self.events.push(Event::Alert(
AlertLocation::Person(person),