From b3b4f82f45d23be2fcc2c2e9c1c6e5e015048dc4 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 26 Feb 2019 16:39:17 -0800 Subject: [PATCH] rename CarState enum --- editor/src/plugins/sim/des_model/car.rs | 6 +++--- editor/src/plugins/sim/des_model/mod.rs | 6 +++--- .../src/plugins/sim/new_des_model/mechanics/car.rs | 12 ++++++------ .../plugins/sim/new_des_model/mechanics/parking.rs | 4 ++-- editor/src/render/bike.rs | 12 ++++++------ editor/src/render/car.rs | 12 ++++++------ sim/src/driving.rs | 10 +++++----- sim/src/lib.rs | 2 +- sim/src/parking.rs | 4 ++-- sim/src/render.rs | 4 ++-- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/editor/src/plugins/sim/des_model/car.rs b/editor/src/plugins/sim/des_model/car.rs index d31f37c89e..e71772b702 100644 --- a/editor/src/plugins/sim/des_model/car.rs +++ b/editor/src/plugins/sim/des_model/car.rs @@ -1,7 +1,7 @@ use crate::plugins::sim::des_model::interval::{Delta, Interval}; use geom::{Acceleration, Distance, Duration, Speed, EPSILON_DIST}; use map_model::{Lane, Traversable}; -use sim::{CarID, CarState, DrawCarInput, VehicleType}; +use sim::{CarID, CarStatus, DrawCarInput, VehicleType}; use std::cmp; pub const FOLLOWING_DISTANCE: Distance = Distance::const_meters(1.0); @@ -9,7 +9,7 @@ pub const FOLLOWING_DISTANCE: Distance = Distance::const_meters(1.0); pub struct Car { pub id: CarID, // Hack used for different colors - pub state: CarState, + pub state: CarStatus, pub car_length: Distance, // Note that if we always used these, things would look quite jerky. pub max_accel: Acceleration, @@ -77,7 +77,7 @@ impl Car { id: self.id, waiting_for_turn: None, stopping_trace: None, - state: self.state, + status: self.state, vehicle_type: VehicleType::Car, on: Traversable::Lane(lane.id), body: lane diff --git a/editor/src/plugins/sim/des_model/mod.rs b/editor/src/plugins/sim/des_model/mod.rs index 5f698182dc..168059d799 100644 --- a/editor/src/plugins/sim/des_model/mod.rs +++ b/editor/src/plugins/sim/des_model/mod.rs @@ -6,7 +6,7 @@ use crate::plugins::sim::des_model::car::Car; use ezgui::{GfxCtx, Text}; use geom::{Acceleration, Distance, Duration, Speed, EPSILON_DIST}; use map_model::{LaneID, Map}; -use sim::{CarID, CarState, DrawCarInput, VehicleType}; +use sim::{CarID, CarStatus, DrawCarInput, VehicleType}; pub struct World { pub lane: LaneID, @@ -20,7 +20,7 @@ impl World { let mut leader = Car { id: CarID::tmp_new(0, VehicleType::Car), - state: CarState::Moving, + state: CarStatus::Moving, car_length: Distance::meters(5.0), max_accel: Acceleration::meters_per_second_squared(2.5), max_deaccel: Acceleration::meters_per_second_squared(-3.0), @@ -39,7 +39,7 @@ impl World { for i in 0..num_followers { let mut follower = Car { id: CarID::tmp_new(cars.len(), VehicleType::Car), - state: CarState::Stuck, + state: CarStatus::Stuck, car_length: Distance::meters(5.0), max_accel: Acceleration::meters_per_second_squared(4.5), max_deaccel: Acceleration::meters_per_second_squared(-2.0), diff --git a/editor/src/plugins/sim/new_des_model/mechanics/car.rs b/editor/src/plugins/sim/new_des_model/mechanics/car.rs index 1503ec0399..94f0b3e120 100644 --- a/editor/src/plugins/sim/new_des_model/mechanics/car.rs +++ b/editor/src/plugins/sim/new_des_model/mechanics/car.rs @@ -4,7 +4,7 @@ use crate::plugins::sim::new_des_model::{ use geom::{Distance, Duration, PolyLine}; use map_model::{Map, Traversable, LANE_THICKNESS}; use serde_derive::{Deserialize, Serialize}; -use sim::DrawCarInput; +use sim::{CarStatus, DrawCarInput}; use std::collections::VecDeque; #[derive(Debug, Serialize, Deserialize)] @@ -107,13 +107,13 @@ impl Car { id: self.vehicle.id, waiting_for_turn: None, stopping_trace: None, - state: match self.state { + status: match self.state { // TODO Cars can be Queued behind a slow Crossing. Looks kind of weird. - CarState::Queued => sim::CarState::Stuck, - CarState::Crossing(_, _) => sim::CarState::Moving, + CarState::Queued => CarStatus::Stuck, + CarState::Crossing(_, _) => CarStatus::Moving, // Eh they're technically moving, but this is a bit easier to spot - CarState::Unparking(_, _) => sim::CarState::Parked, - CarState::Parking(_, _, _) => sim::CarState::Parked, + CarState::Unparking(_, _) => CarStatus::Parked, + CarState::Parking(_, _, _) => CarStatus::Parked, }, vehicle_type: self.vehicle.vehicle_type, on: self.router.head(), diff --git a/editor/src/plugins/sim/new_des_model/mechanics/parking.rs b/editor/src/plugins/sim/new_des_model/mechanics/parking.rs index 0bfc9e0b91..bce1675397 100644 --- a/editor/src/plugins/sim/new_des_model/mechanics/parking.rs +++ b/editor/src/plugins/sim/new_des_model/mechanics/parking.rs @@ -7,7 +7,7 @@ use map_model; use map_model::{BuildingID, Lane, LaneID, LaneType, Map, Position, Traversable}; use multimap::MultiMap; use serde_derive::{Deserialize, Serialize}; -use sim::{CarID, CarState, DrawCarInput, VehicleType}; +use sim::{CarID, CarStatus, DrawCarInput, VehicleType}; use std::collections::{BTreeMap, BTreeSet}; use std::iter; @@ -126,7 +126,7 @@ impl ParkingSimState { id: p.vehicle.id, waiting_for_turn: None, stopping_trace: None, - state: CarState::Parked, + status: CarStatus::Parked, vehicle_type: VehicleType::Car, on: Traversable::Lane(lane), diff --git a/editor/src/render/bike.rs b/editor/src/render/bike.rs index 7162f27f9d..e36d025ff7 100644 --- a/editor/src/render/bike.rs +++ b/editor/src/render/bike.rs @@ -4,7 +4,7 @@ use crate::render::{RenderOptions, Renderable}; use ezgui::{Color, Drawable, GfxCtx, Prerender}; use geom::{Bounds, Distance, Polygon, Pt2D}; use map_model::Map; -use sim::{CarID, CarState, DrawCarInput}; +use sim::{CarID, CarStatus, DrawCarInput}; const BIKE_WIDTH: Distance = Distance::const_meters(0.8); @@ -24,14 +24,14 @@ impl DrawBike { let polygon = input.body.make_polygons(BIKE_WIDTH); let draw_default = prerender.upload_borrowed(vec![( - match input.state { - CarState::Debug => cs + match input.status { + CarStatus::Debug => cs .get_def("debug bike", Color::BLUE.alpha(0.8)) .shift(input.id.0), // TODO Hard to see on the greenish bike lanes? :P - CarState::Moving => cs.get_def("moving bike", Color::GREEN).shift(input.id.0), - CarState::Stuck => cs.get_def("stuck bike", Color::RED).shift(input.id.0), - CarState::Parked => panic!("Can't have a parked bike"), + CarStatus::Moving => cs.get_def("moving bike", Color::GREEN).shift(input.id.0), + CarStatus::Stuck => cs.get_def("stuck bike", Color::RED).shift(input.id.0), + CarStatus::Parked => panic!("Can't have a parked bike"), }, &polygon, )]); diff --git a/editor/src/render/car.rs b/editor/src/render/car.rs index f930105849..91e079925a 100644 --- a/editor/src/render/car.rs +++ b/editor/src/render/car.rs @@ -4,7 +4,7 @@ use crate::render::{RenderOptions, Renderable}; use ezgui::{Color, Drawable, GfxCtx, Prerender}; use geom::{Angle, Bounds, Circle, Distance, PolyLine, Polygon, Pt2D}; use map_model::{Map, TurnType}; -use sim::{CarID, CarState, DrawCarInput}; +use sim::{CarID, CarStatus, DrawCarInput}; use std; const CAR_WIDTH: Distance = Distance::const_meters(2.0); @@ -78,11 +78,11 @@ impl DrawCar { let body_polygon = input.body.make_polygons(CAR_WIDTH); // TODO if it's a bus, color it differently -- but how? :\ - let color = match input.state { - CarState::Debug => cs.get_def("debug car", Color::BLUE.alpha(0.8)), - CarState::Moving => cs.get_def("moving car", Color::CYAN), - CarState::Stuck => cs.get_def("stuck car", Color::rgb_f(0.9, 0.0, 0.0)), - CarState::Parked => cs.get_def("parked car", Color::rgb(180, 233, 76)), + let color = match input.status { + CarStatus::Debug => cs.get_def("debug car", Color::BLUE.alpha(0.8)), + CarStatus::Moving => cs.get_def("moving car", Color::CYAN), + CarStatus::Stuck => cs.get_def("stuck car", Color::rgb_f(0.9, 0.0, 0.0)), + CarStatus::Parked => cs.get_def("parked car", Color::rgb(180, 233, 76)), }; let draw_default = prerender.upload_borrowed(vec![ ( diff --git a/sim/src/driving.rs b/sim/src/driving.rs index bd693ee6b1..7ec10b190f 100644 --- a/sim/src/driving.rs +++ b/sim/src/driving.rs @@ -6,7 +6,7 @@ use crate::router::Router; use crate::transit::TransitSimState; use crate::view::{AgentView, WorldView}; use crate::{ - AgentID, CarID, CarState, DrawCarInput, Event, ParkedCar, ParkingSpot, Tick, TripID, + AgentID, CarID, CarStatus, DrawCarInput, Event, ParkedCar, ParkingSpot, Tick, TripID, VehicleType, TIMESTEP, }; use abstutil; @@ -935,12 +935,12 @@ impl DrivingSimState { map, Some(c.vehicle.stopping_distance(c.speed).unwrap()), ), - state: if c.debug { - CarState::Debug + status: if c.debug { + CarStatus::Debug } else if c.speed.is_zero(TIMESTEP) { - CarState::Stuck + CarStatus::Stuck } else { - CarState::Moving + CarStatus::Moving }, vehicle_type: c.vehicle.vehicle_type, on: c.on, diff --git a/sim/src/lib.rs b/sim/src/lib.rs index 96f7b26465..27791576d5 100644 --- a/sim/src/lib.rs +++ b/sim/src/lib.rs @@ -29,7 +29,7 @@ pub use crate::make::{ }; pub use crate::physics::{Tick, TIMESTEP}; pub use crate::query::{Benchmark, ScoreSummary, SimStats, Summary}; -pub use crate::render::{CarState, DrawCarInput, DrawPedestrianInput, GetDrawAgents}; +pub use crate::render::{CarStatus, DrawCarInput, DrawPedestrianInput, GetDrawAgents}; pub use crate::sim::Sim; use abstutil::Cloneable; use map_model::{BuildingID, LaneID}; diff --git a/sim/src/parking.rs b/sim/src/parking.rs index 6f44c12579..3fd434655b 100644 --- a/sim/src/parking.rs +++ b/sim/src/parking.rs @@ -1,5 +1,5 @@ use crate::kinematics::Vehicle; -use crate::{CarID, CarState, DrawCarInput, ParkedCar, ParkingSpot, VehicleType}; +use crate::{CarID, CarStatus, DrawCarInput, ParkedCar, ParkingSpot, VehicleType}; use abstutil::{deserialize_btreemap, serialize_btreemap}; use geom::{Angle, Distance, Pt2D}; use map_model; @@ -95,7 +95,7 @@ impl ParkingSimState { id: p.car, waiting_for_turn: None, stopping_trace: None, - state: CarState::Parked, + status: CarStatus::Parked, vehicle_type: VehicleType::Car, on: Traversable::Lane(lane), diff --git a/sim/src/render.rs b/sim/src/render.rs index 12c6e71230..e4ac4e1145 100644 --- a/sim/src/render.rs +++ b/sim/src/render.rs @@ -17,7 +17,7 @@ pub struct DrawCarInput { pub id: CarID, pub waiting_for_turn: Option, pub stopping_trace: Option, - pub state: CarState, + pub status: CarStatus, // TODO This is definitely redundant pub vehicle_type: VehicleType, pub on: Traversable, @@ -27,7 +27,7 @@ pub struct DrawCarInput { } #[derive(Clone, Copy, PartialEq, Eq)] -pub enum CarState { +pub enum CarStatus { Moving, Stuck, Parked,