fix(cast&skill): 修复技能预制体加载问题,重构代码并添加调试日志

为SCastSystem添加多处调试日志,便于排查技能施法相关问题
重构Skill类的load方法,将同步预制体获取改为异步加载逻辑
封装重复的技能节点初始化逻辑为内部函数,提升代码可读性
修复预制体未预加载时无法创建技能实体的问题
This commit is contained in:
pan
2026-06-04 15:25:43 +08:00
parent efe6cc0dd7
commit 0c9818ca27
2 changed files with 131 additions and 112 deletions

View File

@@ -128,9 +128,13 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
targetPos = this.resolveEnemyCastTargetPos(config, mockAttrs, mockView, target, maxRange);
}
// 如果全屏都没找到敌人,直接放弃释放伤害技能
if (!targetPos) return;
if (!targetPos) {
console.log("[SCastSystem] forceCastCardSkill: no enemy found for skill", s_uuid);
return;
}
}
console.log("[SCastSystem] forceCastCardSkill: casting skill", s_uuid, "castTimes", castTimes, "targetPos", targetPos);
for (let i = 0; i < castTimes; i++) {
if (isFriendly) {
const friendlyTargets = this.resolveFriendlyTargets(targetEids, FacSet.HERO);
@@ -147,7 +151,10 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
private createSkillEntityForCard(s_uuid: number, skillLv: number, mockAttrs: HeroAttrsComp, startPos: Vec3, targetPos: Vec3 | null, castIndex: number = 0, overrides?: SkillOverrides) {
const scene = smc.map.MapView.scene;
const parent = scene.entityLayer?.node?.getChildByName("SKILL");
if (!parent || !targetPos) return;
if (!parent || !targetPos) {
console.log("[SCastSystem] createSkillEntityForCard failed: parent or targetPos missing", !!parent, !!targetPos);
return;
}
const skill = ecs.getEntity<Skill>(Skill);
const actualStartPos = this.resolveRepeatCastStartPos(startPos, castIndex);
@@ -160,6 +167,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
} as any;
skill.load(actualStartPos, parent, s_uuid, targetPos.clone(), mockView, mockAttrs, skillLv, 0, overrides);
console.log("[SCastSystem] createSkillEntityForCard success for skill", s_uuid);
}
/** 空施法计划:用于“当前无可施法技能”时的统一返回 */
private readonly emptyCastPlan = { skillId: 0, skillLv: 1, isFriendly: false, targetPos: null as Vec3 | null, targetEids: [] as number[], overrides: undefined as SkillOverrides | undefined };