perf: 移除调试日志并统一调试模式控制

- 将 HeroAttrsComp 中的 console.log 改为注释以提升性能
- 将 HeroViewComp 的 debugMode 默认值设为 false 并移除冗余日志
- 在 SkillView 中统一添加 debugMode 控制,替换直接 console 调用
- 在 MissionCardComp 中添加调试日志以跟踪卡牌应用效果
This commit is contained in:
panw
2026-02-03 10:36:41 +08:00
parent 031b91311a
commit c07678f31f
4 changed files with 51 additions and 19 deletions

View File

@@ -20,6 +20,21 @@ export class SkillView extends CCComp {
@property({ type: CCInteger })
atk_y: number = 0
@property({ tooltip: "是否启用调试日志" })
private debugMode: boolean = false;
private debugLog(...args: any[]): void {
if (this.debugMode) {
console.log(...args);
}
}
private debugWarn(...args: any[]): void {
if (this.debugMode) {
console.warn(...args);
}
}
anim:Animation=null;
group:number=0;
SConf:SkillConfig=null;
@@ -63,10 +78,10 @@ export class SkillView extends CCComp {
const targetView = oCol.getComponent(HeroViewComp);
const targetName = targetView?.ent?.get(HeroAttrsComp)?.hero_name ?? '非英雄对象';
const targetEid = targetView?.ent?.eid ?? '未知EID';
console.log(`[skillView] 碰撞1 [${this.sData.caster.box_group}][${casterName}][${casterEid}]的[${seCol.group}]:[${this.SConf.name}][${this.ent.eid}]碰撞了 [${oCol.group}]:[ ${targetName}][${targetEid}]`);
this.debugLog(`[skillView] 碰撞1 [${this.sData.caster.box_group}][${casterName}][${casterEid}]的[${seCol.group}]:[${this.SConf.name}][${this.ent.eid}]碰撞了 [${oCol.group}]:[ ${targetName}][${targetEid}]`);
// 基本空值与同组过滤
if (!this.sData || !this.SConf) {
console.warn('[SkillView] onBeginContact 缺少 sData 或 SConf忽略此次碰撞');
this.debugWarn('[SkillView] onBeginContact 缺少 sData 或 SConf忽略此次碰撞');
return;
}
if (oCol.group === seCol.group) return;
@@ -98,7 +113,7 @@ export class SkillView extends CCComp {
// 开启碰撞检测
if(this.collider) {
this.collider.enabled = true;
console.log(`[SkillView] [${this.SConf?.name}] 第${this.attackFrameCount}次攻击帧开启碰撞检测`);
this.debugLog(`[SkillView] [${this.SConf?.name}] 第${this.attackFrameCount}次攻击帧开启碰撞检测`);
}
// let dis=this.node.getComponent(UITransform).width/2
@@ -155,9 +170,9 @@ export class SkillView extends CCComp {
// 这样可以避免同一帧内的重复伤害
if(this.SConf.EType !== EType.collision && this.collider) {
this.collider.enabled = false;
console.log(`[SkillView] [${this.SConf.name}] 伤害后关闭碰撞检测`);
this.debugLog(`[SkillView] [${this.SConf.name}] 伤害后关闭碰撞检测`);
}
// console.log(`[skillView] 伤害 [${this.group}][${this.sData.caster.ent.get(HeroAttrsComp).hero_name}][${this.sData.caster.ent.eid}]的 [${this.SConf.name}]对 [${target.box_group}][ ${target.ent.get(HeroAttrsComp).hero_name}][${target.ent.eid}]`);
this.debugLog(`[skillView] 伤害 [${this.group}][${this.sData.caster.ent.get(HeroAttrsComp).hero_name}][${this.sData.caster.ent.eid}]的 [${this.SConf.name}]对 [${target.box_group}][ ${target.ent.get(HeroAttrsComp).hero_name}][${target.ent.eid}]`);
// if(this.sData.hit_count > this.SConf.hit_num) return 不能超出 最大伤害数量
// 使用伤害队列系统处理伤害
DamageQueueHelper.addDamageToEntity(