#pragma once #include #include #include #include #include #include #include namespace frostbite2D { class BinaryReader; namespace animation { // --------------------------------------------------------------------------- // 类型定义 // --------------------------------------------------------------------------- using AniFlag = std::variant< int, float, Vec2, std::string, std::vector, std::vector>; // --------------------------------------------------------------------------- // 数据结构 // --------------------------------------------------------------------------- struct AniFrame { std::string imgPath; // 图片路径 int imgIndex = 0; // 图片索引 Vec2 imgPos; // 图片位置 std::vector> attackBox; // 攻击框 [x, y, w, h, type, param] std::vector> damageBox; // 受击框 [x, y, w, h, type, param] std::unordered_map flag; // 帧特效数据 int delay = 0; // 延迟(毫秒) }; struct AniInfo { std::vector imgList; // 图片列表 std::vector frames; // 帧列表 std::unordered_map flag; // 动画特效数据 }; struct AlsAniInfo { std::string path; // 路径 std::vector layer; // 图层 [zOrder, subLayer] }; struct AlsInfo { std::unordered_map aniList; // ALS 动画列表 }; // --------------------------------------------------------------------------- // 工具函数 // --------------------------------------------------------------------------- std::string getAniFlag(int type); std::string getAniEffectType(int type); std::string getAniFlipType(int type); std::string getAniDamageType(int type); // --------------------------------------------------------------------------- // 解析函数 // --------------------------------------------------------------------------- /** * @brief 解析 .ani 二进制数据 * @param data 二进制数据 * @param size 数据大小 * @return 解析后的动画信息 */ AniInfo parseAniInfo(const char* data, size_t size); /** * @brief 从 PVF 路径解析 .ani 文件 * @param path PVF 中的文件路径(如 "character/player/attack.ani") * @return 解析后的动画信息,解析失败返回 std::nullopt */ std::optional parseAniFromPvf(const std::string& path); /** * @brief 解析 .als 文本数据 * @param data 文本数据 * @return 解析后的 ALS 信息 */ AlsInfo parseAlsInfo(const std::string& data); /** * @brief 从 PVF 路径解析 .als 文件 * @param path PVF 中的文件路径 * @return 解析后的 ALS 信息,解析失败返回 std::nullopt */ std::optional parseAlsFromPvf(const std::string& path); } // namespace animation } // namespace frostbite2D