fix: 修复移动系统中过近检测忽略敌对阵营的问题
调整hasAnyActorTooClose方法,在判断其他角色是否过近时,增加阵营校验逻辑,确保只检测同阵营角色,避免误判敌对角色位置。
This commit is contained in:
@@ -111,8 +111,8 @@
|
|||||||
},
|
},
|
||||||
"_lscale": {
|
"_lscale": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 1.8,
|
"x": 2,
|
||||||
"y": -1.6,
|
"y": -1,
|
||||||
"z": 1
|
"z": 1
|
||||||
},
|
},
|
||||||
"_mobility": 0,
|
"_mobility": 0,
|
||||||
@@ -460,6 +460,7 @@
|
|||||||
},
|
},
|
||||||
"atk_x": 0,
|
"atk_x": 0,
|
||||||
"atk_y": 0,
|
"atk_y": 0,
|
||||||
|
"debugMode": true,
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -289,10 +289,13 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
}
|
}
|
||||||
|
|
||||||
private hasAnyActorTooClose(self: ecs.Entity, x: number, y: number): boolean {
|
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 => {
|
return ecs.query(ecs.allOf(HeroAttrsComp, HeroViewComp)).some(e => {
|
||||||
if (e === self) return false;
|
if (e === self) return false;
|
||||||
const attrs = e.get(HeroAttrsComp);
|
const attrs = e.get(HeroAttrsComp);
|
||||||
if (!attrs || attrs.is_dead) return false;
|
if (!attrs || attrs.is_dead) return false;
|
||||||
|
if (attrs.fac !== myAttrs.fac) return false;
|
||||||
const view = e.get(HeroViewComp);
|
const view = e.get(HeroViewComp);
|
||||||
if (!view || !view.node) return false;
|
if (!view || !view.node) return false;
|
||||||
return Math.abs(view.node.position.x - x) < this.minSpacingX
|
return Math.abs(view.node.position.x - x) < this.minSpacingX
|
||||||
|
|||||||
Reference in New Issue
Block a user