summaryrefslogtreecommitdiff
path: root/src/mass.rs
blob: 5742f8394dfe4127631dbdfffc3efe6fad648fe2 (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
25
26
27
extern crate serde;

use downcast::Any;

pub trait Mass : Any {
    fn recv_mass_type(&self) -> MassType;
    fn position(&self) -> (f64, f64, f64);
    fn serialize(&self) -> String;
    fn process(&mut self);
    fn give_acceleration(&mut self, acceleration : (f64, f64, f64));
    fn recv_velocity(&self) -> (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 MassType {
    Ship,
    Astroid,
}

downcast!(Mass);