From ce9adc4cc1b4b30322dc30ee85c42ee1451ffbf9 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Thu, 21 Feb 2019 11:20:16 -0600 Subject: redid engines, finished simple construction tests, setup recv using less parameters --- src/mass.rs | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'src/mass.rs') diff --git a/src/mass.rs b/src/mass.rs index 7cc7d70..3d90573 100644 --- a/src/mass.rs +++ b/src/mass.rs @@ -186,6 +186,12 @@ impl Mass { masses.insert(target_name.to_string(), target); } + let target = match &navigation.target_name { + Some(target_name) => masses.get(target_name), + None => None, + }; + + engines.process(self.position.clone(), self.velocity.clone(), target); refinery.process(storage); navigation.process(self.position.clone(), masses); construction.process( @@ -194,7 +200,6 @@ impl Mass { masses, storage, ); - engines.process(self.velocity.clone()); self.effects.give_acceleration(engines.take_acceleration()); } @@ -236,12 +241,7 @@ impl Mass { } } - pub fn give_received_data( - &mut self, - module_type: ModuleType, - recv: String, - masses: &HashMap, - ) { + pub fn give_received_data(&mut self, module_type: ModuleType, recv: String) { if let MassType::Ship { ref mut navigation, ref mut engines, @@ -252,18 +252,9 @@ impl Mass { .. } = self.mass_type { - let target = match &navigation.target_name { - Some(target_name) => masses.get(target_name), - None => None, - }; match module_type { ModuleType::Navigation => navigation.give_received_data(recv), - ModuleType::Engines => engines.give_received_data( - recv, - self.position.clone(), - self.velocity.clone(), - target, - ), + ModuleType::Engines => engines.give_received_data(recv, self.velocity.clone()), ModuleType::Mining => mining.give_received_data(recv), ModuleType::Construction => construction.give_received_data(recv), ModuleType::Refinery => refinery.give_received_data(recv), @@ -299,12 +290,8 @@ impl Mass { pub fn item_count(&self, item_type: ItemType) -> usize { match &self.mass_type { - MassType::Ship { - storage, .. - } => storage.item_count(item_type), - MassType::Astroid { - resources, .. - } => resources.item_count(item_type), + MassType::Ship { storage, .. } => storage.item_count(item_type), + MassType::Astroid { resources, .. } => resources.item_count(item_type), _ => 0, } } -- cgit v1.2.3