feat: 添加游戏数学工具类并重构相关代码
refactor: 将数学工具函数移至GameMath类 feat(音频): 实现地图音频控制器 feat(调试): 添加游戏调试UI组件 feat(地图): 增加移动区域边界获取方法 fix(角色): 修复角色移动区域抑制逻辑 refactor(世界): 重构游戏世界场景初始化 docs(音频): 完善音频数据库注释
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "character/CharacterObject.h"
|
||||
#include "common/math/GameMath.h"
|
||||
#include "map/GameMap.h"
|
||||
#include "world/GameWorld.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <cmath>
|
||||
#include <frostbite2D/core/application.h>
|
||||
#include <frostbite2D/utils/startup_trace.h>
|
||||
#include <sstream>
|
||||
@@ -43,10 +43,6 @@ Vec3 ToWorldVector(const CharacterWorldPosition& position) {
|
||||
static_cast<float>(position.z));
|
||||
}
|
||||
|
||||
int32 RoundWorldCoordinate(float value) {
|
||||
return static_cast<int32>(std::lround(value));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool CharacterObject::Construction(int jobId) {
|
||||
@@ -199,9 +195,9 @@ void CharacterObject::ApplyMapMovementConstraints(
|
||||
static_cast<float>(motor_.position.y - previousPosition.y),
|
||||
static_cast<float>(motor_.position.z - previousPosition.z));
|
||||
Vec3 resolvedWorldPos = map->CheckIsItMovable(previousWorldPos, worldOffset);
|
||||
motor_.position.x = RoundWorldCoordinate(resolvedWorldPos.x);
|
||||
motor_.position.y = RoundWorldCoordinate(resolvedWorldPos.y);
|
||||
motor_.position.z = RoundWorldCoordinate(resolvedWorldPos.z);
|
||||
motor_.position.x = gameMath::RoundWorldCoordinate(resolvedWorldPos.x);
|
||||
motor_.position.y = gameMath::RoundWorldCoordinate(resolvedWorldPos.y);
|
||||
motor_.position.z = gameMath::RoundWorldCoordinate(resolvedWorldPos.z);
|
||||
}
|
||||
|
||||
void CharacterObject::QueueMapTransitionIfNeeded() {
|
||||
@@ -210,16 +206,24 @@ void CharacterObject::QueueMapTransitionIfNeeded() {
|
||||
return;
|
||||
}
|
||||
|
||||
GameMap::MapMoveArea target;
|
||||
if (!map->TryGetMoveAreaTarget(ToWorldVector(motor_.position), target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GameWorld* world = GameWorld::GetWorld();
|
||||
if (!world) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t moveAreaIndex = map->FindMoveAreaIndex(ToWorldVector(motor_.position));
|
||||
world->UpdateMoveAreaSuppression(map, moveAreaIndex);
|
||||
if (moveAreaIndex == GameMap::kInvalidMoveAreaIndex ||
|
||||
world->ShouldSuppressMoveArea(map, moveAreaIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& moveAreaInfo = map->GetMoveAreaInfo();
|
||||
if (moveAreaIndex >= moveAreaInfo.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const GameMap::MapMoveArea& target = moveAreaInfo[moveAreaIndex];
|
||||
world->RequestMoveCharacter(RefPtr<Actor>(this), target.town, target.area);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user