#pragma once #include #include #include #include #include #include namespace easy2d { // ============================================================================ // AnimationFrame - 单帧数据 // 引用 SpriteFrame 而非直接持有纹理(借鉴 Cocos 模式) // 通过 FramePropertySet 支持不固定数据(ANI Flag 系统增强版) // ============================================================================ struct AnimationFrame { // ------ 核心数据(固定部分)------ Ptr spriteFrame; // 精灵帧引用(Cocos 模式) std::string texturePath; // 原始图片路径(用于解析时定位资源) int textureIndex = 0; // 精灵图集索引 Vec2 offset; // 位置偏移 float delay = 100.0f; // 帧延迟(毫秒) // ------ 碰撞盒数据(DNF ANI 格式)------ std::vector> damageBoxes; // 伤害碰撞盒 std::vector> attackBoxes; // 攻击碰撞盒 // ------ 不固定数据(属性集合)------ FramePropertySet properties; // 类型安全的 Flag 系统 // ------ 便捷方法 ------ bool hasTexture() const { return spriteFrame != nullptr && spriteFrame->isValid(); } bool hasInterpolation() const { return properties.getOr(FramePropertyKey::Interpolation, false); } bool hasKeyframeCallback() const { return properties.has(FramePropertyKey::SetFlag); } int getKeyframeIndex() const { return properties.getOr(FramePropertyKey::SetFlag, -1); } Vec2 getEffectiveScale() const { return properties.getOr(FramePropertyKey::ImageRate, Vec2::One()); } float getEffectiveRotation() const { return properties.getOr(FramePropertyKey::ImageRotate, 0.0f); } Color getEffectiveColor() const { return properties.getOr(FramePropertyKey::ColorTint, Colors::White); } }; } // namespace easy2d