From 11b51897dda7609b5a22a490bfb8cd2c269b5969 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Thu, 7 Jun 2018 08:30:35 -0500 Subject: -added crude refinery methods --- src/mass.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/mass.rs') 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, - navigation : Option, engines : Option, + refinery : Option, dashboard : Option, - storage : Storage, + navigation : Option, }, 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 { match self.mass_type { MassType::Ship{ref mut storage, ..} => storage.take(name), -- cgit v1.2.3