feat: 添加游戏数学工具类并重构相关代码
refactor: 将数学工具函数移至GameMath类 feat(音频): 实现地图音频控制器 feat(调试): 添加游戏调试UI组件 feat(地图): 增加移动区域边界获取方法 fix(角色): 修复角色移动区域抑制逻辑 refactor(世界): 重构游戏世界场景初始化 docs(音频): 完善音频数据库注释
This commit is contained in:
@@ -15,7 +15,9 @@ Vec2 RoundWorldPoint(const Vec2& pos) {
|
||||
|
||||
} // namespace
|
||||
|
||||
GameTown::GameTown() = default;
|
||||
GameTown::GameTown() {
|
||||
EnableEventReceive();
|
||||
}
|
||||
|
||||
bool GameTown::Init(int index, const std::string& townPath) {
|
||||
game::TownConfig config;
|
||||
@@ -68,10 +70,25 @@ RefPtr<GameMap> GameTown::GetArea(int index) const {
|
||||
return it->map;
|
||||
}
|
||||
|
||||
RefPtr<GameMap> GameTown::GetCurrentArea() const {
|
||||
if (curMapIndex_ == -1) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GetArea(curMapIndex_);
|
||||
}
|
||||
|
||||
void GameTown::AddCharacter(RefPtr<Actor> actor, int areaIndex) {
|
||||
int targetMapIndex = areaIndex;
|
||||
if (areaIndex == -2) {
|
||||
targetMapIndex = sariaRoomId_ != -1 ? sariaRoomId_ : (mapList_.empty() ? -1 : mapList_.front().areaId);
|
||||
if (sariaRoomId_ != -1) {
|
||||
targetMapIndex = sariaRoomId_;
|
||||
} else {
|
||||
targetMapIndex = mapList_.empty() ? -1 : mapList_.front().areaId;
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"GameTown: no gate area configured, fallback to first area %d",
|
||||
targetMapIndex);
|
||||
}
|
||||
}
|
||||
|
||||
auto mapIt = std::find_if(mapList_.begin(), mapList_.end(),
|
||||
|
||||
Reference in New Issue
Block a user