summaryrefslogtreecommitdiff
path: root/src/mass.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2018-06-25 08:36:57 -0500
committertom barrett <spalf0@gmail.com>2018-06-25 08:36:57 -0500
commit39b16e379fb679aa56ded8ab5463569e5633a656 (patch)
tree446c1f2e609836c61109aa27400ac4bf2155c7dc /src/mass.rs
parent7094849bf164ff6f853c8f6812a0e831a66762f3 (diff)
added item mass, allow stopping of ship, if storage is full item goes into space
Diffstat (limited to 'src/mass.rs')
-rw-r--r--src/mass.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/mass.rs b/src/mass.rs
index 96244c0..252de49 100644
--- a/src/mass.rs
+++ b/src/mass.rs
@@ -29,9 +29,12 @@ pub enum MassType {
dashboard : Option<Dashboard>,
navigation : Option<Navigation>,
},
- Astroid{
+ Astroid {
resources : Storage,
},
+ Item {
+ item : Item,
+ }
}
impl Mass {
@@ -78,6 +81,14 @@ impl Mass {
}
}
+ pub fn new_item(item : Item, position : (f64, f64, f64), velocity : (f64, f64, f64)) -> Mass {
+ Mass {
+ mass_type : MassType::Item{item : item},
+ position : position,
+ velocity : velocity,
+ }
+ }
+
pub fn get_modules(&self) -> Vec<ModuleType> {
let mut modules = Vec::new();
modules.push(ModuleType::Mining);
@@ -115,6 +126,7 @@ impl Mass {
match self.mass_type {
MassType::Ship{ref storage, ..} => storage.has_minerals(),
MassType::Astroid{ref resources, ..} => resources.has_minerals(),
+ _ => false,
}
}
@@ -122,13 +134,15 @@ impl Mass {
match self.mass_type {
MassType::Ship{ref mut storage, ..} => storage.take(name),
MassType::Astroid{ref mut resources, ..} => resources.take(name),
+ _ => None,
}
}
- pub fn give(&mut self, item : Item) {
+ pub fn give(&mut self, item : Item) -> bool {
match self.mass_type {
MassType::Ship{ref mut storage, ..} => storage.give(item),
MassType::Astroid{ref mut resources, ..} => resources.give(item),
+ _ => false,
}
}
}