mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 23:15:24 +03:00
Track how long cars have been parked in one spot
This commit is contained in:
parent
4beff2b7bf
commit
1331b629aa
@ -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));
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user