[][src]Trait sim::mechanics::parking::ParkingSim

pub trait ParkingSim {
    fn handle_live_edits(
        &mut self,
        map: &Map,
        timer: &mut Timer<'_>
    ) -> (Vec<ParkedCar>, Vec<CarID>);
fn get_free_onstreet_spots(&self, l: LaneID) -> Vec<ParkingSpot>;
fn get_free_offstreet_spots(&self, b: BuildingID) -> Vec<ParkingSpot>;
fn get_free_lot_spots(&self, pl: ParkingLotID) -> Vec<ParkingSpot>;
fn reserve_spot(&mut self, spot: ParkingSpot, car: CarID);
fn remove_parked_car(&mut self, p: ParkedCar);
fn add_parked_car(&mut self, p: ParkedCar);
fn get_draw_cars(&self, id: LaneID, map: &Map) -> Vec<DrawCarInput>;
fn get_draw_cars_in_lots(&self, id: LaneID, map: &Map) -> Vec<DrawCarInput>;
fn get_draw_car(&self, id: CarID, map: &Map) -> Option<DrawCarInput>;
fn canonical_pt(&self, id: CarID, map: &Map) -> Option<Pt2D>;
fn get_all_draw_cars(&self, map: &Map) -> Vec<DrawCarInput>;
fn is_free(&self, spot: ParkingSpot) -> bool;
fn get_car_at_spot(&self, spot: ParkingSpot) -> Option<&ParkedCar>;
fn get_all_free_spots(
        &self,
        driving_pos: Position,
        vehicle: &Vehicle,
        target: BuildingID,
        map: &Map
    ) -> Vec<(ParkingSpot, Position)>;
fn spot_to_driving_pos(
        &self,
        spot: ParkingSpot,
        vehicle: &Vehicle,
        map: &Map
    ) -> Position;
fn spot_to_sidewalk_pos(&self, spot: ParkingSpot, map: &Map) -> Position;
fn get_owner_of_car(&self, id: CarID) -> Option<PersonID>;
fn lookup_parked_car(&self, id: CarID) -> Option<&ParkedCar>;
fn get_all_parking_spots(&self) -> (Vec<ParkingSpot>, Vec<ParkingSpot>);
fn path_to_free_parking_spot(
        &self,
        start: LaneID,
        vehicle: &Vehicle,
        target: BuildingID,
        map: &Map
    ) -> Option<(Vec<PathStep>, ParkingSpot, Position)>;
fn collect_events(&mut self) -> Vec<Event>;
fn all_parked_car_positions(&self, map: &Map) -> Vec<(Position, PersonID)>;
fn bldg_to_parked_cars(&self, b: BuildingID) -> Vec<CarID>; }

Manages the state of parked cars. There are two implementations:

Required methods

fn handle_live_edits(
    &mut self,
    map: &Map,
    timer: &mut Timer<'_>
) -> (Vec<ParkedCar>, Vec<CarID>)

Returns any cars that got very abruptly evicted from existence, and also cars actively moving into a deleted spot.

fn get_free_onstreet_spots(&self, l: LaneID) -> Vec<ParkingSpot>

fn get_free_offstreet_spots(&self, b: BuildingID) -> Vec<ParkingSpot>

fn get_free_lot_spots(&self, pl: ParkingLotID) -> Vec<ParkingSpot>

fn reserve_spot(&mut self, spot: ParkingSpot, car: CarID)

fn remove_parked_car(&mut self, p: ParkedCar)

fn add_parked_car(&mut self, p: ParkedCar)

fn get_draw_cars(&self, id: LaneID, map: &Map) -> Vec<DrawCarInput>

fn get_draw_cars_in_lots(&self, id: LaneID, map: &Map) -> Vec<DrawCarInput>

fn get_draw_car(&self, id: CarID, map: &Map) -> Option<DrawCarInput>

fn canonical_pt(&self, id: CarID, map: &Map) -> Option<Pt2D>

There's no DrawCarInput for cars parked offstreet, so we need this.

fn get_all_draw_cars(&self, map: &Map) -> Vec<DrawCarInput>

fn is_free(&self, spot: ParkingSpot) -> bool

fn get_car_at_spot(&self, spot: ParkingSpot) -> Option<&ParkedCar>

fn get_all_free_spots(
    &self,
    driving_pos: Position,
    vehicle: &Vehicle,
    target: BuildingID,
    map: &Map
) -> Vec<(ParkingSpot, Position)>

The vehicle's front is currently at the given driving_pos. Returns all valid spots and their driving position.

fn spot_to_driving_pos(
    &self,
    spot: ParkingSpot,
    vehicle: &Vehicle,
    map: &Map
) -> Position

fn spot_to_sidewalk_pos(&self, spot: ParkingSpot, map: &Map) -> Position

fn get_owner_of_car(&self, id: CarID) -> Option<PersonID>

fn lookup_parked_car(&self, id: CarID) -> Option<&ParkedCar>

fn get_all_parking_spots(&self) -> (Vec<ParkingSpot>, Vec<ParkingSpot>)

(Filled, available)

fn path_to_free_parking_spot(
    &self,
    start: LaneID,
    vehicle: &Vehicle,
    target: BuildingID,
    map: &Map
) -> Option<(Vec<PathStep>, ParkingSpot, Position)>

Unrealistically assumes the driver has knowledge of currently free parking spots, even if they're far away. Since they don't reserve the spot in advance, somebody else can still beat them there, producing some nice, realistic churn if there's too much contention. The first PathStep is the turn after start, NOT PathStep::Lane(start).

fn collect_events(&mut self) -> Vec<Event>

fn all_parked_car_positions(&self, map: &Map) -> Vec<(Position, PersonID)>

fn bldg_to_parked_cars(&self, b: BuildingID) -> Vec<CarID>

Loading content...

Implementors

impl ParkingSim for ParkingSimState[src]

fn handle_live_edits(
    &mut self,
    map: &Map,
    timer: &mut Timer<'_>
) -> (Vec<ParkedCar>, Vec<CarID>)
[src]

Returns any cars that got very abruptly evicted from existence, and also cars actively moving into a deleted spot.

fn canonical_pt(&self, id: CarID, map: &Map) -> Option<Pt2D>[src]

There's no DrawCarInput for cars parked offstreet, so we need this.

fn get_all_free_spots(
    &self,
    driving_pos: Position,
    vehicle: &Vehicle,
    target: BuildingID,
    map: &Map
) -> Vec<(ParkingSpot, Position)>
[src]

The vehicle's front is currently at the given driving_pos. Returns all valid spots and their driving position.

fn get_all_parking_spots(&self) -> (Vec<ParkingSpot>, Vec<ParkingSpot>)[src]

(Filled, available)

fn path_to_free_parking_spot(
    &self,
    start: LaneID,
    vehicle: &Vehicle,
    target: BuildingID,
    map: &Map
) -> Option<(Vec<PathStep>, ParkingSpot, Position)>
[src]

Unrealistically assumes the driver has knowledge of currently free parking spots, even if they're far away. Since they don't reserve the spot in advance, somebody else can still beat them there, producing some nice, realistic churn if there's too much contention. The first PathStep is the turn after start, NOT PathStep::Lane(start).

impl ParkingSim for InfiniteParkingSimState[src]

impl ParkingSim for NormalParkingSimState[src]

Loading content...