diff options
Diffstat (limited to 'src/mass.rs')
-rw-r--r-- | src/mass.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mass.rs b/src/mass.rs index 4bb44b0..96244c0 100644 --- a/src/mass.rs +++ b/src/mass.rs @@ -8,6 +8,7 @@ use storage::Storage; use modules::mining::Mining; use modules::engines::Engines; use modules::types::ModuleType; +use modules::refinery::Refinery; use modules::dashboard::Dashboard; use modules::navigation::Navigation; @@ -21,11 +22,12 @@ pub struct Mass { #[derive(Serialize, Deserialize, Debug, Clone)] pub enum MassType { Ship { + storage : Storage, mining : Option<Mining>, - navigation : Option<Navigation>, engines : Option<Engines>, + refinery : Option<Refinery>, dashboard : Option<Dashboard>, - storage : Storage, + navigation : Option<Navigation>, }, Astroid{ resources : Storage, @@ -63,6 +65,7 @@ impl Mass { let ship = MassType::Ship { mining : Some(Mining::new()), engines : Some(Engines::new()), + refinery : Some(Refinery::new()), dashboard : Some(Dashboard::new()), navigation : Some(Navigation::new()), storage : Storage::new(Vec::new()), @@ -79,6 +82,7 @@ impl Mass { let mut modules = Vec::new(); modules.push(ModuleType::Mining); modules.push(ModuleType::Engines); + modules.push(ModuleType::Refinery); modules.push(ModuleType::Dashboard); modules.push(ModuleType::Navigation); modules @@ -87,8 +91,9 @@ impl Mass { pub fn process(&mut self) { let mut acceleration = (0.0, 0.0, 0.0); match self.mass_type { - MassType::Ship{ref mut navigation, ref mut engines, ref mut mining, ..} => { + MassType::Ship{ref mut navigation, ref mut engines, ref mut mining, ref mut refinery, ..} => { mining.as_mut().unwrap().process(); + refinery.as_mut().unwrap().process(); navigation.as_mut().unwrap().process(); acceleration = engines.as_mut().unwrap().recv_acceleration(); }, @@ -106,6 +111,13 @@ impl Mass { self.velocity.2 += acceleration.2; } + pub fn has_minerals(&self) -> bool { + match self.mass_type { + MassType::Ship{ref storage, ..} => storage.has_minerals(), + MassType::Astroid{ref resources, ..} => resources.has_minerals(), + } + } + pub fn take(&mut self, name : &str) -> Option<Item> { match self.mass_type { MassType::Ship{ref mut storage, ..} => storage.take(name), |