diff --git a/assets/script/game/skill/STimeComp.ts b/assets/script/game/skill/STimeComp.ts index 01d36249..356a568e 100644 --- a/assets/script/game/skill/STimeComp.ts +++ b/assets/script/game/skill/STimeComp.ts @@ -9,7 +9,6 @@ export class StimeDataComp extends ecs.Comp { elapsedTime: number = 0; hitInterval: number = 0; hitElapsed: number = 0; - pendingClose: boolean = false; reset() { this.s_uuid = 0; @@ -17,7 +16,6 @@ export class StimeDataComp extends ecs.Comp { this.elapsedTime = 0; this.hitInterval = 0; this.hitElapsed = 0; - this.pendingClose = false; } } @@ -35,10 +33,6 @@ export class STimeSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate if (!timeComp || !skillView) return; const conf = SkillSet[timeComp.s_uuid]; if (!conf || conf.EType !== EType.timeEnd) return; - if (timeComp.pendingClose) { - skillView.close_collider(); - timeComp.pendingClose = false; - } if (timeComp.totalTime <= 0) { skillView.close_collider(); entity.destroy(); @@ -46,10 +40,9 @@ export class STimeSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } timeComp.elapsedTime += this.dt; timeComp.hitElapsed += this.dt; - if (timeComp.hitInterval > 0 && timeComp.hitElapsed >= timeComp.hitInterval && !timeComp.pendingClose) { + if (timeComp.hitInterval > 0 && timeComp.hitElapsed >= timeComp.hitInterval) { timeComp.hitElapsed -= timeComp.hitInterval; skillView.atk(null); - timeComp.pendingClose = true; } if (timeComp.elapsedTime >= timeComp.totalTime) { skillView.close_collider(); diff --git a/assets/script/game/skill/SkillView.ts b/assets/script/game/skill/SkillView.ts index 6e342272..80331197 100644 --- a/assets/script/game/skill/SkillView.ts +++ b/assets/script/game/skill/SkillView.ts @@ -105,8 +105,12 @@ export class SkillView extends CCComp { this.attackFrameCount++; if (this.enable_collider_safely()) { mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 第${this.attackFrameCount}次攻击帧开启碰撞检测`); + this.scheduleOnce(() => { + if (!this.node || !this.node.isValid || this.isDisposing) return; + this.close_collider(); + mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 第${this.attackFrameCount}次攻击帧关闭碰撞检测`); + }, 0); } - } //伤害应用 apply_damage(target:HeroViewComp,is_range:boolean=false){ @@ -120,13 +124,6 @@ export class SkillView extends CCComp { this.close_collider() return } - // 对于非持续碰撞类型的技能,在造成伤害后立即关闭碰撞检测 - // 这样可以避免同一帧内的重复伤害 - if(this.SConf.EType !== EType.collision && this.collider) { - this.close_collider(); - mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf.name}] 伤害后关闭碰撞检测`); - } - // 安全获取名称,防止实体销毁导致的空指针异常 const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? "未知施法者"; const targetName = target.ent.get(HeroAttrsComp)?.hero_name ?? "未知目标";