pub struct Entity { /* private fields */ }Expand description
The fundamental entity in the engine, combining a transform with a collection of behavior-defining components.
Implementations§
Source§impl Entity
Implements static factory and ID generation methods for Entity.
impl Entity
Implements static factory and ID generation methods for Entity.
Source§impl Entity
Implements lifecycle and component management methods for Entity.
impl Entity
Implements lifecycle and component management methods for Entity.
Sourcepub fn add_component(&mut self, component: ComponentRc)
pub fn add_component(&mut self, component: ComponentRc)
Adds a component to this entity and calls its on_start lifecycle method.
§Arguments
ComponentRc- The component to add.
Sourcepub fn remove_component_by_name(&mut self, name: &str) -> Option<ComponentRc>
pub fn remove_component_by_name(&mut self, name: &str) -> Option<ComponentRc>
Sourcepub fn get_component_by_name(&self, name: &str) -> Option<ComponentRc>
pub fn get_component_by_name(&self, name: &str) -> Option<ComponentRc>
Sourcepub fn render(&self, context: &CanvasRenderingContext2d)
pub fn render(&self, context: &CanvasRenderingContext2d)
Calls on_render on all active components.
§Arguments
&CanvasRenderingContext2d- The canvas rendering context.
Source§impl Entity
impl Entity
pub fn get_id(&self) -> u64
pub fn get_mut_id(&mut self) -> &mut u64
pub fn set_id(&mut self, val: u64) -> &mut Self
pub fn get_name(&self) -> &String
pub fn get_mut_name(&mut self) -> &mut String
pub fn set_name(&mut self, val: String) -> &mut Self
pub fn get_transform(&self) -> Transform2D
pub fn set_transform(&mut self, val: Transform2D) -> &mut Self
pub fn get_active(&self) -> bool
pub fn get_mut_active(&mut self) -> &mut bool
pub fn set_active(&mut self, val: bool) -> &mut Self
pub fn get_components(&self) -> &Vec<ComponentRc> ⓘ
pub fn set_components(&mut self, val: Vec<ComponentRc>) -> &mut Self
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Entity
impl !Send for Entity
impl !Sync for Entity
impl !UnwindSafe for Entity
impl Freeze for Entity
impl Unpin for Entity
impl UnsafeUnpin for Entity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more