Initial engine repository

This commit is contained in:
2026-06-08 19:58:35 +08:00
commit 7a925c3736
137 changed files with 162421 additions and 0 deletions
@@ -0,0 +1,102 @@
#pragma once
#include <frostbite2D/types/type_alias.h>
#include <frostbite2D/types/type_math.h>
#include <variant>
#include <vector>
#include <string>
#include <unordered_map>
#include <optional>
namespace frostbite2D {
class BinaryReader;
namespace animation {
// ---------------------------------------------------------------------------
// 类型定义
// ---------------------------------------------------------------------------
using AniFlag = std::variant<
int,
float,
Vec2,
std::string,
std::vector<int>,
std::vector<float>>;
// ---------------------------------------------------------------------------
// 数据结构
// ---------------------------------------------------------------------------
struct AniFrame {
std::string imgPath; // 图片路径
int imgIndex = 0; // 图片索引
Vec2 imgPos; // 图片位置
std::vector<std::vector<int>> attackBox; // 攻击框 [x, y, w, h, type, param]
std::vector<std::vector<int>> damageBox; // 受击框 [x, y, w, h, type, param]
std::unordered_map<std::string, AniFlag> flag; // 帧特效数据
int delay = 0; // 延迟(毫秒)
};
struct AniInfo {
std::vector<std::string> imgList; // 图片列表
std::vector<AniFrame> frames; // 帧列表
std::unordered_map<std::string, AniFlag> flag; // 动画特效数据
};
struct AlsAniInfo {
std::string path; // 路径
std::vector<int> layer; // 图层 [zOrder, subLayer]
};
struct AlsInfo {
std::unordered_map<std::string, AlsAniInfo> 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<AniInfo> 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<AlsInfo> parseAlsFromPvf(const std::string& path);
} // namespace animation
} // namespace frostbite2D