refactor(游戏逻辑): 拆分游戏暂停和播放状态的检查条件
将多处 `if(!smc.mission.play || smc.mission.pause)` 条件判断拆分为独立的if语句 在VictoryComp中正确设置pause状态 移除MissionComp中多余的pause状态重置
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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),则停止怪物移动
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user