Files
hfut-bishe/client/core/persistence/EntityPayloadBinary.h
2026-04-09 23:13:33 +08:00

31 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "domain/Project.h"
#include <QString>
namespace core {
// 实体完整数据(几何 + 贴图路径 + 动画轨道)的二进制格式,与 project.json v2 的 payload 字段对应。
// 贴图 PNG 仍单独存放在 assets/entities/,本文件不嵌入像素。
// 具体读写通过继承 PersistentBinaryObject 的适配器类完成(见 EntityPayloadBinary.cpp
class EntityPayloadBinary {
public:
static constexpr quint32 kMagicPayload = 0x48464550; // 'HFEP'
static constexpr quint32 kPayloadVersion = 9; // v9追加 blackholeResolvedBy
// 旧版独立动画文件(仍用于打开 v1 项目时合并)
static constexpr quint32 kMagicLegacyAnim = 0x48465441; // 'HFTA'
static constexpr quint32 kLegacyAnimVersion = 1;
static bool save(const QString& absolutePath, const Project::Entity& entity);
// 读入后覆盖 entity 中除调用方已校验外的字段;失败时尽量保持 entity 不变。
static bool load(const QString& absolutePath, Project::Entity& entity);
// 仅读取旧 .animHFTA写入 entity 的三条动画轨道。
static bool loadLegacyAnimFile(const QString& absolutePath, Project::Entity& entity);
};
} // namespace core