summaryrefslogtreecommitdiff
path: root/ecs/src/entity/obtainer.rs
blob: 6c2ea96e68001e372a3b074ece51203033353c17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)
    }
}