fix(技能系统): 修复敌方技能施放目标位置计算
添加目标节点存在性检查,防止空引用 重构敌方目标位置计算逻辑,确保在施放范围内
This commit is contained in:
@@ -69,8 +69,9 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
if (typeof selfEid !== "number") continue;
|
if (typeof selfEid !== "number") continue;
|
||||||
return { skillId: s_uuid, isFriendly: true, targetPos: null, targetEids: [selfEid] };
|
return { skillId: s_uuid, isFriendly: true, targetPos: null, targetEids: [selfEid] };
|
||||||
}
|
}
|
||||||
if (!target) continue;
|
if (!target || !heroView.node || !target.node) continue;
|
||||||
return { skillId: s_uuid, isFriendly: false, targetPos: target.node.position.clone(), targetEids: [] };
|
const targetPos = this.buildEnemyCastTargetPos(heroView, target, maxRange);
|
||||||
|
return { skillId: s_uuid, isFriendly: false, targetPos, targetEids: [] };
|
||||||
}
|
}
|
||||||
return this.emptyCastPlan;
|
return this.emptyCastPlan;
|
||||||
}
|
}
|
||||||
@@ -212,4 +213,11 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
if (type === HType.Mid) return 360;
|
if (type === HType.Mid) return 360;
|
||||||
return this.meleeCastRange;
|
return this.meleeCastRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private buildEnemyCastTargetPos(caster: HeroViewComp, target: HeroViewComp, castRange: number): Vec3 {
|
||||||
|
const casterPos = caster.node.position;
|
||||||
|
const targetPos = target.node.position;
|
||||||
|
const direction = targetPos.x >= casterPos.x ? 1 : -1;
|
||||||
|
return new Vec3(casterPos.x + direction * castRange, casterPos.y, casterPos.z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user