refactor: 将数学工具函数移至GameMath类 feat(音频): 实现地图音频控制器 feat(调试): 添加游戏调试UI组件 feat(地图): 增加移动区域边界获取方法 fix(角色): 修复角色移动区域抑制逻辑 refactor(世界): 重构游戏世界场景初始化 docs(音频): 完善音频数据库注释
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <frostbite2D/audio/music.h>
|
|
#include <frostbite2D/audio/sound.h>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
namespace frostbite2D {
|
|
|
|
struct MapAudioTrack {
|
|
std::string id;
|
|
std::string path;
|
|
};
|
|
|
|
struct MapAudioState {
|
|
std::optional<MapAudioTrack> bgmTrack;
|
|
std::vector<MapAudioTrack> ambientLoops;
|
|
};
|
|
|
|
class MapAudioController {
|
|
public:
|
|
static MapAudioController& get();
|
|
|
|
void ApplyMapAudio(const MapAudioState& state);
|
|
void ClearMapAudio();
|
|
|
|
private:
|
|
struct ActiveAmbientLoop {
|
|
MapAudioTrack track;
|
|
RefPtr<Sound> sound;
|
|
int channel = -1;
|
|
};
|
|
|
|
MapAudioController() = default;
|
|
|
|
void ApplyBgmTrack(const std::optional<MapAudioTrack>& bgmTrack);
|
|
void ApplyAmbientLoops(const std::vector<MapAudioTrack>& ambientLoops);
|
|
void StopAmbientLoop(ActiveAmbientLoop& loop);
|
|
static std::string NormalizeTrackKey(const MapAudioTrack& track);
|
|
|
|
std::optional<MapAudioTrack> currentBgmTrack_;
|
|
RefPtr<Music> currentBgmMusic_;
|
|
std::unordered_map<std::string, ActiveAmbientLoop> activeAmbientLoops_;
|
|
};
|
|
|
|
} // namespace frostbite2D
|