diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/construction.rs | 13 | ||||
-rw-r--r-- | src/modules/mining.rs | 11 | ||||
-rw-r--r-- | src/modules/navigation.rs | 29 | ||||
-rw-r--r-- | src/modules/refinery.rs | 11 |
4 files changed, 22 insertions, 42 deletions
diff --git a/src/modules/construction.rs b/src/modules/construction.rs index 22086a5..46ddbb1 100644 --- a/src/modules/construction.rs +++ b/src/modules/construction.rs @@ -27,14 +27,11 @@ impl Construction { } pub fn process(&mut self) { - match self.start.clone() { - Some(timer) => { - if timer.elapsed().unwrap().as_secs() > self.time { - self.start = Some(SystemTime::now()); - self.status = ConstructionStatus::Constructed; - } + if let Some(timer) = self.start.clone() { + if timer.elapsed().unwrap().as_secs() > self.time { + self.start = Some(SystemTime::now()); + self.status = ConstructionStatus::Constructed; } - _ => (), } } @@ -56,6 +53,6 @@ impl Construction { } pub fn take(&mut self) { - self.status = ConstructionStatus::None; + self.off() } } diff --git a/src/modules/mining.rs b/src/modules/mining.rs index 7a6461a..3c091b9 100644 --- a/src/modules/mining.rs +++ b/src/modules/mining.rs @@ -26,14 +26,11 @@ impl Mining { } pub fn process(&mut self) { - match self.start.clone() { - Some(timer) => { - if timer.elapsed().unwrap().as_secs() > self.time { - self.status = MiningStatus::Mined; - self.start = Some(SystemTime::now()); - } + if let Some(timer) = self.start.clone() { + if timer.elapsed().unwrap().as_secs() > self.time { + self.status = MiningStatus::Mined; + self.start = Some(SystemTime::now()); } - _ => (), } } diff --git a/src/modules/navigation.rs b/src/modules/navigation.rs index c4b3224..84f315c 100644 --- a/src/modules/navigation.rs +++ b/src/modules/navigation.rs @@ -32,19 +32,11 @@ impl Navigation { } pub fn process(&mut self) { - match self.start.clone() { - Some(timer) => { - if timer.elapsed().unwrap().as_secs() > self.time { - self.status = NavigationStatus::Targeted; - self.start = None; - } + if let Some(timer) = self.start.clone() { + if timer.elapsed().unwrap().as_secs() > self.time { + self.status = NavigationStatus::Targeted; + self.start = None; } - _ => (), - } - - match self.target_name { - None => self.status = NavigationStatus::None, - _ => (), } } @@ -55,15 +47,12 @@ impl Navigation { } pub fn verify_target(&mut self, ship_position : (f64, f64, f64), masses : &HashMap<String, Mass>) { - match self.target_name.clone() { - Some(name) => { - let target = masses.get(&name).unwrap(); - if distance(target.position, ship_position) > self.range { - self.target_name = None; - self.status = NavigationStatus::None; - } + if let Some(name) = self.target_name.clone() { + let target = masses.get(&name).unwrap(); + if distance(target.position, ship_position) > self.range { + self.target_name = None; + self.status = NavigationStatus::None; } - _ => (), } } } diff --git a/src/modules/refinery.rs b/src/modules/refinery.rs index cdb5de0..5100f3d 100644 --- a/src/modules/refinery.rs +++ b/src/modules/refinery.rs @@ -24,14 +24,11 @@ impl Refinery { } pub fn process(&mut self) { - match self.start.clone() { - Some(timer) => { - if timer.elapsed().unwrap().as_secs() > self.time { - self.status = RefineryStatus::Refined; - self.start = Some(SystemTime::now()); - } + if let Some(timer) = self.start.clone() { + if timer.elapsed().unwrap().as_secs() > self.time { + self.status = RefineryStatus::Refined; + self.start = Some(SystemTime::now()); } - _ => (), } } |