aada 0.1.1

纯 Rust 的 2D 骨骼动画引擎,兼容 Spine 4.x 导出格式(JSON + atlas)。求解到分层 Mesh 与各 Mesh 渲染设置为止,之后交给渲染器。
Documentation
//! 运行时 slot 数据与集合。

use crate::{
    custom_index::NameMap,
    data::runtime::{skeleton::BoneIdx, skin::AttachmentNameIdx},
    new_index,
};

new_index!(SlotIdx);

/// 运行时的 slot 基础信息(静态不变)
#[cfg_attr(feature = "bevy_reflect", derive(bevy_reflect::Reflect))]
#[derive(Debug, Clone, PartialEq)]
pub struct SlotData {
    pub name: String,
    /// slot 绑定的主骨骼
    pub bone: BoneIdx,
    /// 默认 attachment 的逻辑名称,用于在皮肤中查找
    pub default_attachment: Option<String>,
    /// 默认 attachment 的逻辑名索引(解析期映射,运行时零字符串查找)
    pub default_attachment_idx: Option<AttachmentNameIdx>,
    /// slot 默认颜色(RGBA 0-1):与 attachment 颜色相乘构成默认 tint,动画 color 时间轴覆盖它
    pub color: [f32; 4],
}

/// 运行时 slot 集合(静态不变),通过名称一次性查索引
#[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
    }
}