diff options
Diffstat (limited to 'ecs/src/entity.rs')
-rw-r--r-- | ecs/src/entity.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ecs/src/entity.rs b/ecs/src/entity.rs index 85e7461..a43f9ce 100644 --- a/ecs/src/entity.rs +++ b/ecs/src/entity.rs @@ -1,8 +1,8 @@ use linkme::distributed_slice; -use crate::component::storage::archetype::{Archetype, ArchetypeEntity}; +use crate::component::storage::archetype::{Archetype, Entity as ArchetypeEntity}; use crate::uid::Uid; -use crate::{EntityComponent, World}; +use crate::{EntityComponentRef, World}; /// A handle to a entity. pub struct Handle<'a> @@ -18,16 +18,18 @@ impl<'a> Handle<'a> #[must_use] pub fn uid(&self) -> Uid { - self.entity.uid + self.entity.uid() } #[inline] #[must_use] - pub fn get_component(&self, component_uid: Uid) -> Option<&'a EntityComponent> + pub fn get_component(&self, component_uid: Uid) -> Option<EntityComponentRef<'a>> { let index = self.archetype.get_index_for_component(component_uid)?; - Some(self.entity.components.get(index).unwrap()) + Some(EntityComponentRef::new( + self.entity.components().get(index).unwrap(), + )) } pub(crate) fn new(archetype: &'a Archetype, entity: &'a ArchetypeEntity) -> Self |