diff options
Diffstat (limited to 'ecs/src')
-rw-r--r-- | ecs/src/entity.rs | 2 | ||||
-rw-r--r-- | ecs/src/entity/obtainer.rs | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/ecs/src/entity.rs b/ecs/src/entity.rs index 16f881d..bec50cd 100644 --- a/ecs/src/entity.rs +++ b/ecs/src/entity.rs @@ -15,6 +15,8 @@ use crate::component::{ use crate::uid::{Kind as UidKind, Uid}; use crate::{EntityComponentRef, World}; +pub mod obtainer; + /// A handle to a entity. #[derive(Debug)] pub struct Handle<'a> diff --git a/ecs/src/entity/obtainer.rs b/ecs/src/entity/obtainer.rs new file mode 100644 index 0000000..6c2ea96 --- /dev/null +++ b/ecs/src/entity/obtainer.rs @@ -0,0 +1,29 @@ +use crate::entity::Handle as EntityHandle; +use crate::system::{Metadata as SystemMetadata, Param as SystemParam}; +use crate::uid::Uid; +use crate::World; + +#[derive(Debug)] +pub struct Obtainer<'world> +{ + world: &'world World, +} + +impl<'world> SystemParam<'world> for Obtainer<'world> +{ + type Input = (); + + fn new(world: &'world World, _system_metadata: &SystemMetadata) -> Self + { + Self { world } + } +} + +impl Obtainer<'_> +{ + #[must_use] + pub fn get_entity(&self, entity_id: Uid) -> Option<EntityHandle<'_>> + { + self.world.get_entity(entity_id) + } +} |