summaryrefslogtreecommitdiff
path: root/ecs/src/entity.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/entity.rs')
-rw-r--r--ecs/src/entity.rs35
1 files changed, 17 insertions, 18 deletions
diff --git a/ecs/src/entity.rs b/ecs/src/entity.rs
index 562f7ea..bab3d61 100644
--- a/ecs/src/entity.rs
+++ b/ecs/src/entity.rs
@@ -10,7 +10,6 @@ use crate::component::storage::archetype::{
use crate::component::{
Component,
Handle as ComponentHandle,
- HandleFromEntityComponentRef,
HandleMut as ComponentHandleMut,
};
use crate::uid::{Kind as UidKind, Uid};
@@ -20,7 +19,6 @@ use crate::{EntityComponentRef, World};
#[derive(Debug)]
pub struct Handle<'a>
{
- world: &'a World,
archetype: &'a Archetype,
entity: &'a ArchetypeEntity,
}
@@ -50,13 +48,12 @@ impl<'a> Handle<'a>
let component = self.get_matching_components(ComponentT::id()).next()?;
Some(
- ComponentHandle::from_entity_component_ref(Some(component), self.world)
- .unwrap_or_else(|err| {
- panic!(
- "Taking component {} lock failed: {err}",
- type_name::<ComponentT>()
- );
- }),
+ ComponentHandle::from_entity_component_ref(component).unwrap_or_else(|err| {
+ panic!(
+ "Taking component {} lock failed: {err}",
+ type_name::<ComponentT>()
+ );
+ }),
)
}
@@ -77,13 +74,14 @@ impl<'a> Handle<'a>
let component = self.get_matching_components(ComponentT::id()).next()?;
Some(
- ComponentHandleMut::from_entity_component_ref(Some(component), self.world)
- .unwrap_or_else(|err| {
+ ComponentHandleMut::from_entity_component_ref(component).unwrap_or_else(
+ |err| {
panic!(
"Taking component {} lock failed: {err}",
type_name::<ComponentT>()
);
- }),
+ },
+ ),
)
}
@@ -98,13 +96,14 @@ impl<'a> Handle<'a>
}
}
- pub(crate) fn new(
- world: &'a World,
- archetype: &'a Archetype,
- entity: &'a ArchetypeEntity,
- ) -> Self
+ pub fn component_ids(&self) -> impl Iterator<Item = Uid> + '_
+ {
+ self.archetype.component_ids_sorted()
+ }
+
+ pub(crate) fn new(archetype: &'a Archetype, entity: &'a ArchetypeEntity) -> Self
{
- Self { world, archetype, entity }
+ Self { archetype, entity }
}
}