refactor(skill): 重构技能盒子管理为ECS实体架构

新增SBox ECS实体,统一管理技能盒子的创建、挂载与销毁
重构MissSkillsComp,改用SBox实体替代直接实例化技能节点
更新SkillBoxComp,新增实体引用以通过ECS生命周期销毁节点
临时调整SCastSystem的索敌范围为全屏级,方便测试
This commit is contained in:
pan
2026-06-04 14:41:27 +08:00
parent c5d521136d
commit efe6cc0dd7
5 changed files with 95 additions and 17 deletions

View File

@@ -143,7 +143,11 @@ export class SkillBoxComp extends CCComp {
if (this.keep_waves === 0 && this.current_trigger_times >= this.trigger_times) {
// 次数已满且不跨波次维持 → 延迟 1 秒后销毁(保留短暂视觉反馈)
this.scheduleOnce(() => {
if (this.node && this.node.isValid) this.node.destroy();
if (this.ent) {
(this.ent as ecs.Entity).destroy();
} else if (this.node && this.node.isValid) {
this.node.destroy();
}
}, 1.0);
}
}
@@ -212,7 +216,11 @@ export class SkillBoxComp extends CCComp {
if (this.keep_waves > 0) {
this.keep_waves--;
if (this.keep_waves <= 0) {
if (this.node && this.node.isValid) this.node.destroy();
if (this.ent) {
(this.ent as ecs.Entity).destroy();
} else if (this.node && this.node.isValid) {
this.node.destroy();
}
return;
}
}
@@ -230,7 +238,11 @@ export class SkillBoxComp extends CCComp {
// 默认逻辑:不跨波次维持
if (!this.is_instant) {
if (this.current_trigger_times >= this.trigger_times) {
if (this.node && this.node.isValid) this.node.destroy();
if (this.ent) {
(this.ent as ecs.Entity).destroy();
} else if (this.node && this.node.isValid) {
this.node.destroy();
}
}
}
}
@@ -238,7 +250,11 @@ export class SkillBoxComp extends CCComp {
/** 任务结束:强制销毁 */
private onMissionEnd() {
this.node.destroy();
if (this.ent) {
(this.ent as ecs.Entity).destroy();
} else if (this.node && this.node.isValid) {
this.node.destroy();
}
}
// ======================== 帧更新 ========================
@@ -264,7 +280,11 @@ export class SkillBoxComp extends CCComp {
// 次数用完且不跨波次维持 → 延迟销毁
if (this.keep_waves === 0 && this.current_trigger_times >= this.trigger_times) {
this.scheduleOnce(() => {
if (this.node && this.node.isValid) this.node.destroy();
if (this.ent) {
(this.ent as ecs.Entity).destroy();
} else if (this.node && this.node.isValid) {
this.node.destroy();
}
}, 0.5);
}
}
@@ -295,6 +315,8 @@ export class SkillBoxComp extends CCComp {
/** ECS 组件移除时销毁节点 */
reset() {
this.node.destroy();
if (this.node && this.node.isValid) {
this.node.destroy();
}
}
}