refactor(game): 移除resolveFormationTargetX依赖并内联阵型锚点计算

简化阵型目标X坐标的计算逻辑,直接根据阵营使用预定义的锚点值,避免导入和调用额外的工具函数。
This commit is contained in:
panw
2026-03-31 15:19:03 +08:00
parent 86cc55b226
commit 251cf715fb

View File

@@ -3,7 +3,7 @@ import { HeroViewComp } from "./HeroViewComp";
import { HeroAttrsComp } from "./HeroAttrsComp";
import { smc } from "../common/SingletonModuleComp";
import { FacSet } from "../common/config/GameSet";
import { HeroDisVal, HType, resolveFormationTargetX } from "../common/config/heroSet";
import { HeroDisVal, HType } from "../common/config/heroSet";
import { BoxCollider2D, Node } from "cc";
@ecs.register('MoveComp')
@@ -49,6 +49,8 @@ interface MoveFacConfig {
export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
/** 近战判定射程(来自 heroSet */
private readonly meleeAttackRange = HeroDisVal[HType.Melee];
private readonly heroFrontAnchorX = -30;
private readonly monFrontAnchorX = 30;
/** 常规同阵营横向最小间距 */
private readonly allySpacingX = 60;
/** 纵向判定为同排的最大 Y 差 */
@@ -239,7 +241,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
return a.eid - b.eid;
});
const slotIndex = Math.max(0, laneAllies.findIndex(entity => entity === self));
const frontAnchorX = resolveFormationTargetX(model.fac, HType.Melee);
const frontAnchorX = model.fac === FacSet.MON ? this.monFrontAnchorX : this.heroFrontAnchorX;
const targetX = frontAnchorX - forwardDir * slotIndex * this.allySpacingX;
return Math.max(moveMinX, Math.min(moveMaxX, targetX));
}