use crate::{
custom_index::NameMap,
data::runtime::{skeleton::BoneIdx, skin::AttachmentNameIdx},
new_index,
};
new_index!(SlotIdx);
#[cfg_attr(feature = "bevy_reflect", derive(bevy_reflect::Reflect))]
#[derive(Debug, Clone, PartialEq)]
pub struct SlotData {
pub name: String,
pub bone: BoneIdx,
pub default_attachment: Option<String>,
pub default_attachment_idx: Option<AttachmentNameIdx>,
pub color: [f32; 4],
}
#[derive(Debug, Clone)]
pub struct SlotSet {
pub data: NameMap<SlotIdx, SlotData>,
}
impl Default for SlotSet {
fn default() -> Self {
Self::new()
}
}
impl SlotSet {
pub fn new() -> Self {
Self {
data: NameMap::new(),
}
}
pub fn insert(&mut self, name: impl Into<String>, data: SlotData) -> SlotIdx {
self.data.insert(name.into(), data)
}
pub fn get_index(&self, name: &str) -> Option<SlotIdx> {
self.data.get_index(name)
}
pub fn get_bone(&self, idx: SlotIdx) -> BoneIdx {
self.data[idx].bone
}
}