logo
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
30
31
32
33
use super::*;

/// Entity info component. Use to get information about the entity such as name assigned.

pub struct EntityInfo {
    id: Entity,
}

impl std::fmt::Debug for EntityInfo {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("EntityInfo")
            .field("name", &self.name())
            .finish()
    }
}

impl EntityInfo {
    impl_world_accessor!(
        /// Returns a `ValueAccessor` for the name data of the entity info component.
        EntityInfo,
        Name,
        WorldData,
        name_data,
        ValueAccessorDataReadWrite
    );

    /// Retrieves the name of the entity this component belongs to
    pub fn name(&self) -> String {
        self.name_data().get().get_data_handle().read_str()
    }
}

impl_world_component!(EntityInfo);