diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index 40331a48..e6621422 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -51,9 +51,10 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd * 处理伤害队列中的所有伤害事件 */ update(e: ecs.Entity): void { - if(!smc.mission.play || smc.mission.pause) return; - const TAttrsComp = e.get(HeroAttrsComp); - const damageQueue = e.get(DamageQueueComp); + if(!smc.mission.play ) return + if(smc.mission.pause) return + const TAttrsComp = e.get(HeroAttrsComp) + const damageQueue = e.get(DamageQueueComp) if (!TAttrsComp || !damageQueue || damageQueue.isEmpty()) return; diff --git a/assets/script/game/hero/HeroAttrEventSystem.ts b/assets/script/game/hero/HeroAttrEventSystem.ts index f3c89edd..9584e07c 100644 --- a/assets/script/game/hero/HeroAttrEventSystem.ts +++ b/assets/script/game/hero/HeroAttrEventSystem.ts @@ -23,11 +23,12 @@ export class HeroAttrEventSystem extends ecs.ComblockSystem return ecs.allOf(HeroAttrsComp,HeroAttrEvent); } entityEnter(e: ecs.Entity): void { - if(!smc.mission.play || smc.mission.pause) return; + } update(e: ecs.Entity): void { - if(!smc.mission.play || smc.mission.pause) return; + if(!smc.mission.play ) return; + if(smc.mission.pause) return const model = e.get(HeroAttrsComp); if (!model || model.is_dead) return; const event = e.get(HeroAttrEvent); diff --git a/assets/script/game/hero/HeroAttrsSystem.ts b/assets/script/game/hero/HeroAttrsSystem.ts index 887fdd11..7f128158 100644 --- a/assets/script/game/hero/HeroAttrsSystem.ts +++ b/assets/script/game/hero/HeroAttrsSystem.ts @@ -41,7 +41,6 @@ export class HeroAttrSystem extends ecs.ComblockSystem * 实体首次进入系统时调用(每个实体只调用一次) */ entityEnter(e: ecs.Entity): void { - if(!smc.mission.play || smc.mission.pause) return; const model = e.get(HeroAttrsComp); if (!model) return; @@ -64,7 +63,8 @@ export class HeroAttrSystem extends ecs.ComblockSystem * - 这是正确的设计,不是 bug */ update(e: ecs.Entity): void { - if(!smc.mission.play || smc.mission.pause) return; + if(!smc.mission.play ) return; + if(smc.mission.pause) return const model = e.get(HeroAttrsComp); if (!model || model.is_dead || model.is_reviving) return; diff --git a/assets/script/game/hero/HeroMove.ts b/assets/script/game/hero/HeroMove.ts index d535c51e..b47c14a5 100644 --- a/assets/script/game/hero/HeroMove.ts +++ b/assets/script/game/hero/HeroMove.ts @@ -32,8 +32,8 @@ export class HeroMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpd } update(e: ecs.Entity) { - if (!smc.mission.play || smc.mission.pause) return; - + if (!smc.mission.play ) return; + if(smc.mission.pause) return const move = e.get(HeroMoveComp); const model = e.get(HeroAttrsComp); const view = e.get(HeroViewComp); diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 6f3e890e..0e640d0f 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -126,8 +126,8 @@ export class HeroViewComp extends CCComp { * 注意:数据更新逻辑已移到 HeroAttrSystem,这里只负责显示 */ update(dt: number){ - if(!smc.mission.play || smc.mission.pause) return; - + if(!smc.mission.play ) return; + if(smc.mission.pause) return // 🔥 修复:添加安全检查,防止在实体销毁过程中访问null的model if(!this.ent) return; if (!this.model) return; diff --git a/assets/script/game/hero/MonMove.ts b/assets/script/game/hero/MonMove.ts index 59c48012..ba0d9513 100644 --- a/assets/script/game/hero/MonMove.ts +++ b/assets/script/game/hero/MonMove.ts @@ -40,8 +40,8 @@ export class MonMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpda } update(e: ecs.Entity) { - if (!smc.mission.play || smc.mission.pause) return; - + if (!smc.mission.play ) return; + if(smc.mission.pause) return const view = e.get(HeroViewComp); // 如果英雄死亡(停止怪物行动标志为true),则停止怪物移动 diff --git a/assets/script/game/hero/SACastSystem.ts b/assets/script/game/hero/SACastSystem.ts index b0ab02a6..8602bcdd 100644 --- a/assets/script/game/hero/SACastSystem.ts +++ b/assets/script/game/hero/SACastSystem.ts @@ -35,7 +35,8 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat } update(e: ecs.Entity): void { - if(!smc.mission.play || smc.mission.pause) return; + if(!smc.mission.play ) return; + if(smc.mission.pause) return const skills = e.get(HeroSkillsComp); if (!skills) return; diff --git a/assets/script/game/hero/SCDSystem.ts b/assets/script/game/hero/SCDSystem.ts index 26cf7551..507b2667 100644 --- a/assets/script/game/hero/SCDSystem.ts +++ b/assets/script/game/hero/SCDSystem.ts @@ -25,7 +25,8 @@ export class SkillCDSystem extends ecs.ComblockSystem implements ecs.ISystemUpda } update(e: ecs.Entity): void { - if(!smc.mission.play || smc.mission.pause) return; + if(!smc.mission.play ) return; + if(smc.mission.pause) return const skills = e.get(HeroSkillsComp); if (!skills) return; const attrsCom = e.get(HeroAttrsComp); diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index c7b9f565..03bb7bff 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -43,9 +43,8 @@ export class MissionComp extends CCComp { this.on(GameEvent.ReviveSuccess, this.onReviveSuccess, this) } protected update(dt: number): void { - if(!smc.mission.play||smc.mission.pause){ - return - } + if(!smc.mission.play) return + if(smc.mission.pause) return if(smc.mission.in_fight){ smc.vmdata.mission_data.fight_time+=dt smc.vmdata.mission_data.time-=dt @@ -188,7 +187,6 @@ export class MissionComp extends CCComp { // 延迟0.5秒后执行任务结束逻辑 this.scheduleOnce(() => { smc.mission.play=false - smc.mission.pause=false this.cleanComponents() }, 0.5) } @@ -197,7 +195,6 @@ export class MissionComp extends CCComp { // console.log("[MissionComp] mission_end") // 合并 FightEnd 逻辑:清理组件、停止游戏循环 smc.mission.play=false - smc.mission.pause=false this.cleanComponents() this.node.active=false diff --git a/assets/script/game/map/MissionMonComp.ts b/assets/script/game/map/MissionMonComp.ts index 05249dd9..390c89ad 100644 --- a/assets/script/game/map/MissionMonComp.ts +++ b/assets/script/game/map/MissionMonComp.ts @@ -60,7 +60,8 @@ export class MissionMonCompComp extends CCComp { } protected update(dt: number): void { - if(!smc.mission.play||smc.mission.pause) return + if(!smc.mission.play) return + if(smc.mission.pause) return // 如果英雄死亡(停止怪物行动标志为true),则停止刷怪逻辑 if(smc.mission.stop_mon_action) return; diff --git a/assets/script/game/map/VictoryComp.ts b/assets/script/game/map/VictoryComp.ts index c68244e3..84223af8 100644 --- a/assets/script/game/map/VictoryComp.ts +++ b/assets/script/game/map/VictoryComp.ts @@ -51,7 +51,7 @@ export class VictoryComp extends CCComp { this.node.getChildByName("btns").getChildByName("next").active=!args.can_revive this.node.getChildByName("btns").getChildByName("alive").active=args.can_revive - + smc.mission.pause=true } @@ -62,7 +62,7 @@ export class VictoryComp extends CCComp { oops.gui.removeByNode(this.node) } clear_data(){ - + smc.mission.pause=false } //看广告双倍 watch_ad(){ diff --git a/assets/script/game/skill/SMoveSystem.ts b/assets/script/game/skill/SMoveSystem.ts index afdb8233..9e7b71ea 100644 --- a/assets/script/game/skill/SMoveSystem.ts +++ b/assets/script/game/skill/SMoveSystem.ts @@ -27,7 +27,6 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } entityEnter(entity: ecs.Entity): void { - if(!smc.mission.play || smc.mission.pause) return; const moveComp = entity.get(SMoveDataComp); const skillView = entity.get(SkillView); @@ -107,7 +106,8 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } update(entity: ecs.Entity): void { - if(!smc.mission.play || smc.mission.pause) return; + if(!smc.mission.play ) return; + if(smc.mission.pause) return const moveComp = entity.get(SMoveDataComp); const skillView = entity.get(SkillView);