Struct let_engine::Object
source · pub struct Object {
pub transform: Transform,
pub appearance: Appearance,
/* private fields */
}
Expand description
Object to be rendered on the screen and get the physics processed of.
Fields§
§transform: Transform
§appearance: Appearance
Implementations§
source§impl Object
impl Object
New
sourcepub fn init_with_parent(
&mut self,
layer: &Layer,
parent: &Object
) -> Result<(), ObjectError>
pub fn init_with_parent( &mut self, layer: &Layer, parent: &Object ) -> Result<(), ObjectError>
Initializes the object into a layer with a parent object.
sourcepub fn init_with_optional_parent(
&mut self,
layer: &Layer,
parent: Option<&Object>
) -> Result<(), ObjectError>
pub fn init_with_optional_parent( &mut self, layer: &Layer, parent: Option<&Object> ) -> Result<(), ObjectError>
Initializes the object into a layer with an optional parent object.
sourcepub fn remove(&mut self) -> Result<(), ObjectError>
pub fn remove(&mut self) -> Result<(), ObjectError>
Removes the object from it’s layer.
source§impl Object
impl Object
Setters
sourcepub fn set_isometry(&mut self, position: Vec2, rotation: f32)
pub fn set_isometry(&mut self, position: Vec2, rotation: f32)
Sets the position and rotation of an object.
sourcepub fn public_transform(&self) -> Transform
pub fn public_transform(&self) -> Transform
Returns the public position where the object is going to be rendered.
sourcepub fn appearance(&self) -> &Appearance
pub fn appearance(&self) -> &Appearance
Returns a reference to the appearance of the object.
sourcepub fn id(&self) -> usize
pub fn id(&self) -> usize
Returns the identification number of the object specific the layer it is inside right now.
Returns 0 in case it is not initialized to a layer yet.
sourcepub fn update(&mut self) -> Result<(), ObjectError>
pub fn update(&mut self) -> Result<(), ObjectError>
Updates the object to match the object information located inside the system of the layer. Useful when having physics.
sourcepub fn sync(&mut self) -> Result<(), ObjectError>
pub fn sync(&mut self) -> Result<(), ObjectError>
Updates the object inside the layer system to match with this one. Useful when doing anything to the object and submitting it with this function.
sourcepub fn collider(&self) -> Option<&Collider>
pub fn collider(&self) -> Option<&Collider>
Returns the collider of the object in case it has one.
sourcepub fn set_collider(&mut self, collider: Option<Collider>)
pub fn set_collider(&mut self, collider: Option<Collider>)
Sets the collider of the object.
sourcepub fn collider_mut(&mut self) -> Option<&mut Collider>
pub fn collider_mut(&mut self) -> Option<&mut Collider>
Returns a mutable reference to the collider.
sourcepub fn rigid_body(&self) -> Option<&RigidBody>
pub fn rigid_body(&self) -> Option<&RigidBody>
Returns the rigid bodyh of the object in case it has one.
sourcepub fn set_rigid_body(&mut self, rigid_body: Option<RigidBody>)
pub fn set_rigid_body(&mut self, rigid_body: Option<RigidBody>)
Sets the rigid body of the object.
sourcepub fn rigid_body_mut(&mut self) -> Option<&mut RigidBody>
pub fn rigid_body_mut(&mut self) -> Option<&mut RigidBody>
Returns a mutable reference to the rigid body.
sourcepub fn local_collider_position(&self) -> Vec2
pub fn local_collider_position(&self) -> Vec2
Returns the local position of the collider.
sourcepub fn set_local_collider_position(&mut self, pos: Vec2)
pub fn set_local_collider_position(&mut self, pos: Vec2)
Sets the local position of the collider of this object in case it has one.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl !UnwindSafe for Object
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for Pwhere R: Read + ReadEndian<P>, P: Default,
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.