fix(hero): 防止移动组件在特定情况下反向移动

在计算新位置后添加方向检查,确保英雄不会朝与输入方向相反的方向移动,避免可能的卡顿或位置异常。
This commit is contained in:
panw
2026-03-16 16:08:04 +08:00
parent 95edd6fd6d
commit fb7b10b7e1

View File

@@ -221,6 +221,11 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
newX = direction > 0 ? Math.min(newX, stopAtX) : Math.max(newX, stopAtX);
}
newX = this.clampXByAllies(view.ent, model.fac, move.baseY, currentX, newX, direction);
if (direction > 0) {
newX = Math.max(currentX, newX);
} else {
newX = Math.min(currentX, newX);
}
if (Math.abs(newX - currentX) < 0.01) {
view.status_change("idle");
return;