summaryrefslogtreecommitdiff
path: root/src/mass.rs
blob: 22862b6a4c37a139d3f543c3f1016c1aafc211b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use downcast::Any;

pub trait Mass : Any {
    fn name(&self) -> &String;
    fn position(&self) -> (f64, f64, f64);
    fn serialize(&self) -> String;
    fn process(&mut self);
    fn give_acceleration(&mut self, acceleration : (f64, f64, f64));
    fn box_clone(&self) -> Box<Mass>;
}

impl Clone for Box<Mass> {
    fn clone(&self) -> Box<Mass> {
        self.box_clone()
    }
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum Type {
    Ship,
    Astroid,
}

downcast!(Mass);