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);