summaryrefslogtreecommitdiff
path: root/src/modules/construction.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/construction.rs')
-rw-r--r--src/modules/construction.rs28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/modules/construction.rs b/src/modules/construction.rs
index 46ddbb1..f55a2fb 100644
--- a/src/modules/construction.rs
+++ b/src/modules/construction.rs
@@ -1,5 +1,5 @@
+use crate::modules::types::ModuleType;
use std::time::SystemTime;
-use modules::types::ModuleType;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum ConstructionStatus {
@@ -8,26 +8,32 @@ pub enum ConstructionStatus {
Constructed,
}
-#[derive(Serialize, Deserialize, Debug, Clone)]
+impl Default for ConstructionStatus {
+ fn default() -> Self {
+ ConstructionStatus::None
+ }
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct Construction {
- pub status : ConstructionStatus,
- construction : Option<ModuleType>,
- time : u64,
- start : Option<SystemTime>,
+ pub status: ConstructionStatus,
+ construction: Option<ModuleType>,
+ time: u64,
+ start: Option<SystemTime>,
}
impl Construction {
pub fn new() -> Construction {
Construction {
- status : ConstructionStatus::None,
- construction : None,
- time : 5,
- start : None,
+ status: ConstructionStatus::None,
+ construction: None,
+ time: 5,
+ start: None,
}
}
pub fn process(&mut self) {
- if let Some(timer) = self.start.clone() {
+ if let Some(timer) = self.start {
if timer.elapsed().unwrap().as_secs() > self.time {
self.start = Some(SystemTime::now());
self.status = ConstructionStatus::Constructed;