1use moonshine_kind::prelude::*;
2use moonshine_tag::Tags;
3
4use crate::{Object, ObjectRef, ObjectWorldRef};
5
6pub trait ObjectTags {
8 fn tags(&self) -> &Tags;
12}
13
14impl<T: Kind> ObjectTags for Object<'_, '_, '_, T> {
15 fn tags(&self) -> &Tags {
16 self.nametags
17 .get(self.entity())
18 .ok()
19 .and_then(|(_name, tags)| tags)
20 .unwrap_or(Tags::static_empty())
21 }
22}
23
24impl<T: Kind> ObjectTags for ObjectRef<'_, '_, '_, T> {
25 fn tags(&self) -> &Tags {
26 self.1.tags()
27 }
28}
29
30impl<T: Kind> ObjectTags for ObjectWorldRef<'_, T> {
31 fn tags(&self) -> &Tags {
32 self.world
33 .get(self.entity())
34 .unwrap_or(Tags::static_empty())
35 }
36}