diff options
author | tom barrett <spalf0@gmail.com> | 2019-02-14 12:05:57 -0600 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2019-02-14 12:05:57 -0600 |
commit | 35b43264c09405c987b48de78b6ca19f29dc7849 (patch) | |
tree | e57fd46c3147d4ab1227d8688ebb23778dd3d21c /src/mass.rs | |
parent | 284cac8f4034f15e7edeba5c8232a770fc082e20 (diff) |
simplified receive pattern even more and moved all controls to the module
Diffstat (limited to 'src/mass.rs')
-rw-r--r-- | src/mass.rs | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/mass.rs b/src/mass.rs index 0c19bad..33144ab 100644 --- a/src/mass.rs +++ b/src/mass.rs @@ -51,13 +51,13 @@ impl Effects { pub enum MassType { Ship { storage: Storage, - mining: Option<Mining>, - engines: Option<Engines>, - refinery: Option<Refinery>, - dashboard: Option<Dashboard>, - navigation: Option<Navigation>, - tractorbeam: Option<Tractorbeam>, - construction: Option<Construction>, + mining: Mining, + engines: Engines, + refinery: Refinery, + dashboard: Dashboard, + navigation: Navigation, + tractorbeam: Tractorbeam, + construction: Construction, }, Astroid { resources: Storage, @@ -110,13 +110,13 @@ impl Mass { pub fn new_ship() -> 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()), - tractorbeam: Some(Tractorbeam::new()), - construction: Some(Construction::new()), + mining: Mining::new(), + engines: Engines::new(), + refinery: Refinery::new(), + dashboard: Dashboard::new(), + navigation: Navigation::new(), + tractorbeam: Tractorbeam::new(), + construction: Construction::new(), storage: Storage::new(Vec::new(), constants::SHIP_STORAGE_CAPACITY), }; @@ -170,12 +170,11 @@ impl Mass { .. } = self.mass_type { - mining.as_mut().unwrap().process(); - refinery.as_mut().unwrap().process(); - navigation.as_mut().unwrap().process(); - construction.as_mut().unwrap().process(); - self.effects - .give_acceleration(engines.as_mut().unwrap().recv_acceleration()) + mining.process(); + refinery.process(); + navigation.process(); + construction.process(); + self.effects.give_acceleration(engines.take_acceleration()) } self.velocity += self.effects.take_acceleration(); |