pub struct Parent { /* private fields */ }Expand description
Component indicating the parent entity of this entity.
When an entity has a Parent component, its transform (if any) is
considered to be in the parent’s local coordinate space. The hierarchy
propagation system will compute the global transform by combining
the parent’s global transform with this entity’s local transform.
§Memory Layout
Parent (8 bytes total):
┌────────────────┬────────────────┐
│ index (u32) │ generation(u32)│ <- Entity
└────────────────┴────────────────┘§Example
use goud_engine::ecs::Entity;
use goud_engine::ecs::components::Parent;
let parent_entity = Entity::new(0, 1);
let parent_component = Parent::new(parent_entity);
assert_eq!(parent_component.get(), parent_entity);Implementations§
Source§impl Parent
impl Parent
Sourcepub const fn get(&self) -> Entity
pub const fn get(&self) -> Entity
Returns the parent entity.
§Example
use goud_engine::ecs::Entity;
use goud_engine::ecs::components::Parent;
let parent_entity = Entity::new(10, 2);
let parent = Parent::new(parent_entity);
assert_eq!(parent.get(), parent_entity);Sourcepub fn set(&mut self, parent: Entity)
pub fn set(&mut self, parent: Entity)
Sets the parent entity.
This allows changing the parent without removing and re-adding the component.
§Arguments
parent- The new parent entity
§Example
use goud_engine::ecs::Entity;
use goud_engine::ecs::components::Parent;
let mut parent = Parent::new(Entity::new(0, 1));
parent.set(Entity::new(5, 1));
assert_eq!(parent.get(), Entity::new(5, 1));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Parent
impl<'de> Deserialize<'de> for Parent
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Parent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Parent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Parent
impl Serialize for Parent
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Component for Parent
impl Copy for Parent
impl Eq for Parent
impl StructuralPartialEq for Parent
Auto Trait Implementations§
impl Freeze for Parent
impl RefUnwindSafe for Parent
impl Send for Parent
impl Sync for Parent
impl Unpin for Parent
impl UnsafeUnpin for Parent
impl UnwindSafe for Parent
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().