add set_id() method in Component trait

embed
Manos Pitsidianakis 2019-02-21 15:29:26 +02:00
parent 62168e9183
commit abf8878b39
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 10 additions and 5 deletions

View File

@ -83,9 +83,11 @@ pub struct Entity {
}
impl From<Box<Component>> for Entity {
fn from(kind: Box<Component>) -> Entity {
fn from(mut kind: Box<Component>) -> Entity {
let id = Uuid::new_v4();
kind.set_id(id);
Entity {
id: Uuid::new_v4(),
id: id,
component: kind,
}
}
@ -95,9 +97,11 @@ impl<C: 'static> From<Box<C>> for Entity
where
C: Component,
{
fn from(kind: Box<C>) -> Entity {
fn from(mut kind: Box<C>) -> Entity {
let id = Uuid::new_v4();
kind.set_id(id);
Entity {
id: Uuid::new_v4(),
id: id,
component: kind,
}
}
@ -143,7 +147,8 @@ pub trait Component: Display + Debug {
true
}
fn set_dirty(&mut self);
fn kill(&mut self, _uuid: Uuid) {}
fn kill(&mut self, uuid: Uuid) {}
fn set_id(&mut self, uuid: Uuid) {}
}
/*