refactor(英雄系统): 将调试模式变量移至Monster类
将HeroAttrSystem中的debugMode改为public,并在Monster类中添加私有debugMode字段,为后续调试功能做准备。
This commit is contained in:
@@ -29,7 +29,7 @@ export class HeroAttrSystem extends ecs.ComblockSystem
|
|||||||
// ==================== 调试统计(可选)====================
|
// ==================== 调试统计(可选)====================
|
||||||
private entityCount: number = 0; // 本帧处理的实体数
|
private entityCount: number = 0; // 本帧处理的实体数
|
||||||
private frameCount: number = 0; // 总帧数
|
private frameCount: number = 0; // 总帧数
|
||||||
private debugMode: boolean = false; // 是否启用调试模式
|
public debugMode: boolean = false; // 是否启用调试模式
|
||||||
private timer:Timer=new Timer(1)
|
private timer:Timer=new Timer(1)
|
||||||
/**
|
/**
|
||||||
* 过滤器:只处理拥有 HeroAttrsComp 的实体
|
* 过滤器:只处理拥有 HeroAttrsComp 的实体
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export class Monster extends ecs.Entity {
|
|||||||
HeroSkills!: HeroSkillsComp;
|
HeroSkills!: HeroSkillsComp;
|
||||||
HeroView!: HeroViewComp;
|
HeroView!: HeroViewComp;
|
||||||
MonMove!: MonMoveComp;
|
MonMove!: MonMoveComp;
|
||||||
|
private debugMode: boolean = false; // 是否启用调试模式
|
||||||
|
|
||||||
// 多键对象池:Map<prefabPath, NodePool>
|
// 多键对象池:Map<prefabPath, NodePool>
|
||||||
static pools: Map<string, NodePool> = new Map();
|
static pools: Map<string, NodePool> = new Map();
|
||||||
@@ -158,6 +159,7 @@ export class Monster extends ecs.Entity {
|
|||||||
@ecs.register('MonLifecycleSystem')
|
@ecs.register('MonLifecycleSystem')
|
||||||
export class MonLifecycleSystem extends ecs.ComblockSystem
|
export class MonLifecycleSystem extends ecs.ComblockSystem
|
||||||
implements ecs.IEntityEnterSystem, ecs.IEntityRemoveSystem {
|
implements ecs.IEntityEnterSystem, ecs.IEntityRemoveSystem {
|
||||||
|
debugMode: boolean = false; // 是否启用调试模式
|
||||||
|
|
||||||
filter() {
|
filter() {
|
||||||
return ecs.allOf(MonMoveComp);
|
return ecs.allOf(MonMoveComp);
|
||||||
@@ -167,9 +169,9 @@ export class MonLifecycleSystem extends ecs.ComblockSystem
|
|||||||
// 怪物实体创建时的特殊处理
|
// 怪物实体创建时的特殊处理
|
||||||
const heroAttrs = e.get(HeroAttrsComp);
|
const heroAttrs = e.get(HeroAttrsComp);
|
||||||
if (heroAttrs) {
|
if (heroAttrs) {
|
||||||
mLogger.log(heroAttrs.debugMode, 'MonLifecycleSystem', `怪物进入世界: ${heroAttrs.hero_name}`);
|
mLogger.log(this.debugMode, 'MonLifecycleSystem', `怪物进入世界: ${heroAttrs.hero_name}`);
|
||||||
} else {
|
} else {
|
||||||
mLogger.log(heroAttrs.debugMode, 'MonLifecycleSystem', `怪物进入世界: 实体ID ${e.eid}`);
|
mLogger.log(this.debugMode, 'MonLifecycleSystem', `怪物进入世界: 实体ID ${e.eid}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,9 +179,9 @@ export class MonLifecycleSystem extends ecs.ComblockSystem
|
|||||||
// 怪物实体销毁时的清理工作
|
// 怪物实体销毁时的清理工作
|
||||||
const heroAttrs = e.get(HeroAttrsComp);
|
const heroAttrs = e.get(HeroAttrsComp);
|
||||||
if (heroAttrs) {
|
if (heroAttrs) {
|
||||||
mLogger.log(heroAttrs.debugMode, 'MonLifecycleSystem', `怪物离开世界: ${heroAttrs.hero_name}`);
|
mLogger.log(this.debugMode, 'MonLifecycleSystem', `怪物离开世界: ${heroAttrs.hero_name}`);
|
||||||
} else {
|
} else {
|
||||||
mLogger.log(heroAttrs.debugMode, 'MonLifecycleSystem', `怪物离开世界: 实体ID ${e.eid}`);
|
mLogger.log(this.debugMode, 'MonLifecycleSystem', `怪物离开世界: 实体ID ${e.eid}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user