feat(移动): 根据战斗优先级调整同阵营英雄的横向间距

在clampXByAllies方法中增加战斗优先级判断,高优先级英雄不会因低优先级盟友而调整横向位置。新增getCombatPriority方法根据英雄类型和射程类型计算优先级,近战>中程>远程。
This commit is contained in:
panw
2026-03-16 15:20:50 +08:00
parent 4171865efb
commit acaa6125c2

View File

@@ -267,6 +267,8 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
}
private clampXByAllies(self: ecs.Entity, fac: number, baseY: number, currentX: number, proposedX: number, direction: number): number {
const selfAttrs = self.get(HeroAttrsComp);
const selfPriority = selfAttrs ? this.getCombatPriority(selfAttrs) : 0;
let nearestAheadX = Infinity;
let nearestBehindX = -Infinity;
ecs.query(ecs.allOf(HeroAttrsComp, HeroViewComp, MoveComp)).forEach(e => {
@@ -276,6 +278,8 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
if (!attrs || !view?.node || attrs.is_dead) return;
if (attrs.fac !== fac) return;
if (Math.abs(view.node.position.y - baseY) >= this.minSpacingY) return;
const allyPriority = this.getCombatPriority(attrs);
if (allyPriority < selfPriority) return;
const x = view.node.position.x;
if (x > currentX && x < nearestAheadX) nearestAheadX = x;
if (x < currentX && x > nearestBehindX) nearestBehindX = x;
@@ -290,6 +294,22 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
return proposedX;
}
private getCombatPriority(model: HeroAttrsComp): number {
let rangeType = model.rangeType;
if (rangeType === undefined || rangeType === null) {
if (model.type === HType.warrior || model.type === HType.assassin) {
rangeType = SkillRange.Melee;
} else if (model.type === HType.remote) {
rangeType = SkillRange.Long;
} else {
rangeType = SkillRange.Mid;
}
}
if (rangeType === SkillRange.Melee) return 3;
if (rangeType === SkillRange.Mid) return 2;
return 1;
}
private hasAnyActorTooClose(self: ecs.Entity, x: number, y: number): boolean {
const myAttrs = self.get(HeroAttrsComp);
if (!myAttrs) return false;