fix: 修复移动系统中过近检测忽略敌对阵营的问题
调整hasAnyActorTooClose方法,在判断其他角色是否过近时,增加阵营校验逻辑,确保只检测同阵营角色,避免误判敌对角色位置。
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user