refactor(map/hero): 重构英雄位置管理逻辑,移除lane相关字段

重构了英雄分路排位的旧实现,改用硬编码的点位数组管理英雄站位,移除了HeroAttrsComp中的lane和lane_index字段,简化了英雄位置分配、UI面板绑定的逻辑,提升代码可维护性。
This commit is contained in:
walkpan
2026-05-13 23:48:58 +08:00
parent e3a9d447ba
commit 3f47df2682
5 changed files with 105 additions and 265 deletions

View File

@@ -64,8 +64,6 @@ export class HeroAttrsComp extends ecs.Comp {
minSkillDistance: number = 0; // 最近技能攻击距离缓存不受MP影响用于停止位置判断
// ==================== 阵型位置 ====================
lane: number = -1; // 所在分路0上路, 1中路, 2下路
lane_index: number = -1; // 所在路中的排位0前排, 1后排
// ==================== 标记状态 ====================
is_dead: boolean = false;
@@ -312,8 +310,6 @@ export class HeroAttrsComp extends ecs.Comp {
this.maxSkillDistance = 0;
this.minSkillDistance = 0;
this.lane = -1;
this.lane_index = -1;
this.is_dead = false;
this.is_count_dead = false;

View File

@@ -46,6 +46,8 @@ interface MoveFacConfig {
retreatBackX: number;
}
import { MissionHeroCompComp } from "../map/MissionHeroComp";
@ecs.register('MoveSystem')
export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
private readonly heroFrontAnchorX = -200;
@@ -249,20 +251,12 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
const slotIndex = Math.max(0, allAllies.findIndex(entity => entity === self));
const lanePriority = [1, 0, 2]; // 中路优先,其次上路,最后下路
const laneOffsets = [100, 0, -100];
// 优先中前(1) -> 上前(0) -> 下前(2) -> 中后(4) -> 上后(3) -> 下后(5)
const slotPriority = [1, 0, 2, 4, 3, 5];
const posIndex = slotPriority[slotIndex % 6];
const pos = MissionHeroCompComp.HERO_POSITIONS[posIndex];
const col = Math.floor(slotIndex / 3);
const laneIdx = lanePriority[slotIndex % 3];
// 动态更新英雄位置数据,为战斗面板排序提供依据
model.lane = laneIdx;
model.lane_index = col;
const targetY = BoxSet.GAME_LINE + laneOffsets[laneIdx];
const targetX = this.heroFrontAnchorX - col * this.heroAllySpacingX;
return { targetX, targetY };
return { targetX: pos.x, targetY: pos.y };
}
private moveToSlot(view: HeroViewComp, move: MoveComp, model: HeroAttrsComp, targetX: number) {