fix: 修复移动系统中过近检测忽略敌对阵营的问题

调整hasAnyActorTooClose方法,在判断其他角色是否过近时,增加阵营校验逻辑,确保只检测同阵营角色,避免误判敌对角色位置。
This commit is contained in:
walkpan
2026-03-15 22:00:48 +08:00
parent 8af04d61e0
commit 0b85345369
2 changed files with 6 additions and 2 deletions

View File

@@ -289,10 +289,13 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
}
private hasAnyActorTooClose(self: ecs.Entity, x: number, y: number): boolean {
const myAttrs = self.get(HeroAttrsComp);
if (!myAttrs) return false;
return ecs.query(ecs.allOf(HeroAttrsComp, HeroViewComp)).some(e => {
if (e === self) return false;
const attrs = e.get(HeroAttrsComp);
if (!attrs || attrs.is_dead) return false;
if (attrs.fac !== myAttrs.fac) return false;
const view = e.get(HeroViewComp);
if (!view || !view.node) return false;
return Math.abs(view.node.position.x - x) < this.minSpacingX