perf: 移除调试日志并统一调试模式控制
- 将 HeroAttrsComp 中的 console.log 改为注释以提升性能 - 将 HeroViewComp 的 debugMode 默认值设为 false 并移除冗余日志 - 在 SkillView 中统一添加 debugMode 控制,替换直接 console 调用 - 在 MissionCardComp 中添加调试日志以跟踪卡牌应用效果
This commit is contained in:
@@ -249,7 +249,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.hp = Math.max(0, Math.min(this.hp, this.Attrs[Attrs.HP_MAX]));
|
||||
this.dirty_hp = true; // ✅ 仅标记需要更新
|
||||
smc.updateHeroInfo(this);
|
||||
console.log(`[HeroAttrs] HP变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldHp.toFixed(1)} -> ${this.hp.toFixed(1)}`);
|
||||
// console.log(`[HeroAttrs] HP变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldHp.toFixed(1)} -> ${this.hp.toFixed(1)}`);
|
||||
}
|
||||
add_mp(value:number,isValue:boolean){
|
||||
const oldMp = this.mp;
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface BuffInfo {
|
||||
@ccclass('HeroViewComp') // 定义Cocos Creator 组件
|
||||
@ecs.register('HeroView', false) // 定义ECS 组件
|
||||
export class HeroViewComp extends CCComp {
|
||||
private debugMode: boolean = true; // 是否启用调试模式
|
||||
private debugMode: boolean = false; // 是否启用调试模式
|
||||
|
||||
// 添加条件日志方法
|
||||
private debugLog(...args: any[]): void {
|
||||
@@ -198,7 +198,7 @@ export class HeroViewComp extends CCComp {
|
||||
// 不再基于血量是否满来决定显示状态,只更新进度条
|
||||
let hp=this.model.hp;
|
||||
let hp_max=this.model.Attrs[Attrs.HP_MAX];
|
||||
this.debugLog("hp_show",hp,hp_max)
|
||||
// this.debugLog("hp_show",hp,hp_max)
|
||||
|
||||
let targetProgress = hp / hp_max;
|
||||
let hpNode = this.top_node.getChildByName("hp");
|
||||
@@ -500,18 +500,10 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
// 伤害计算和战斗逻辑已迁移到 HeroBattleSystem
|
||||
|
||||
|
||||
|
||||
|
||||
/** 调试日志(已禁用) */
|
||||
to_console(value:any, value2:any=null, value3:any=null){
|
||||
// 调试用,生产环境已禁用
|
||||
}
|
||||
|
||||
|
||||
playSkillEffect(skill_id:number) {
|
||||
let skill = SkillSet[skill_id]
|
||||
console.log('[heroview] skill_id'+skill_id,skill)
|
||||
this.debugLog('[heroview] skill_id'+skill_id,skill)
|
||||
if (!skill) return;
|
||||
switch(skill.act){
|
||||
case "max":
|
||||
|
||||
@@ -440,7 +440,11 @@ export class MissionCardComp extends CCComp {
|
||||
// 直接调用 TalComp 添加天赋
|
||||
const talComp = role.get(TalComp);
|
||||
if (talComp) {
|
||||
const beforeCount = Object.keys(talComp.Tals).length;
|
||||
console.log(`[MissionCard] Talent Before: Count=${beforeCount}`);
|
||||
talComp.addTal(selectedData.uuid);
|
||||
const afterCount = Object.keys(talComp.Tals).length;
|
||||
console.log(`[MissionCard] Talent After: Count=${afterCount}, Added=${selectedData.uuid}`);
|
||||
}
|
||||
break;
|
||||
case CardType.Skill:
|
||||
@@ -448,7 +452,11 @@ export class MissionCardComp extends CCComp {
|
||||
// 直接调用 HeroSkillsComp 添加技能
|
||||
const skillComp = role.get(HeroSkillsComp);
|
||||
if (skillComp) {
|
||||
const beforeCount = Object.keys(skillComp.skills).length;
|
||||
console.log(`[MissionCard] Skill Before: Count=${beforeCount}`);
|
||||
skillComp.addSkill(selectedData.uuid);
|
||||
const afterCount = Object.keys(skillComp.skills).length;
|
||||
console.log(`[MissionCard] Skill After: Count=${afterCount}, Added=${selectedData.uuid}`);
|
||||
}
|
||||
break;
|
||||
case CardType.Partner:
|
||||
@@ -461,6 +469,9 @@ export class MissionCardComp extends CCComp {
|
||||
if (attrsComp) {
|
||||
const potion = PotionCards[selectedData.uuid];
|
||||
if (potion) {
|
||||
const beforeVal = attrsComp.Attrs[potion.attr] || 0;
|
||||
console.log(`[MissionCard] Potion Before: Attr[${potion.attr}]=${beforeVal}`);
|
||||
|
||||
const buffConf: BuffConf = {
|
||||
buff: potion.attr,
|
||||
value: potion.value,
|
||||
@@ -470,6 +481,8 @@ export class MissionCardComp extends CCComp {
|
||||
};
|
||||
attrsComp.addBuff(buffConf);
|
||||
smc.updateHeroInfo(attrsComp);
|
||||
|
||||
console.log(`[MissionCard] Potion Applied: ${potion.desc}, Value=${potion.value}`);
|
||||
oops.gui.toast(potion.desc);
|
||||
}
|
||||
}
|
||||
@@ -478,6 +491,17 @@ export class MissionCardComp extends CCComp {
|
||||
// 属性卡:更新全局属性并刷新主角
|
||||
const attrCard = AttrCards[selectedData.uuid];
|
||||
if (attrCard) {
|
||||
let globalBefore = 0;
|
||||
if (smc.global_attrs[attrCard.attr]) {
|
||||
globalBefore = smc.global_attrs[attrCard.attr][0];
|
||||
}
|
||||
const roleAttrs = role.get(HeroAttrsComp);
|
||||
let roleBefore = 0;
|
||||
if (roleAttrs) {
|
||||
roleBefore = roleAttrs.Attrs[attrCard.attr] || 0;
|
||||
}
|
||||
console.log(`[MissionCard] Attr Before: Global=${globalBefore}, Hero=${roleBefore}`);
|
||||
|
||||
if (!smc.global_attrs[attrCard.attr]) {
|
||||
smc.global_attrs[attrCard.attr] = [0, 0];
|
||||
}
|
||||
@@ -485,13 +509,14 @@ export class MissionCardComp extends CCComp {
|
||||
current[0] += attrCard.value;
|
||||
current[1] += 1;
|
||||
|
||||
console.log(`[MissionCard] 全局属性更新: Attr=${attrCard.attr}, Add=${attrCard.value}, Total=${current[0]}`);
|
||||
|
||||
// 直接触发主角属性重算
|
||||
const attrsComp = role.get(HeroAttrsComp);
|
||||
if (attrsComp) {
|
||||
attrsComp.recalculateSingleAttr(attrCard.attr);
|
||||
smc.updateHeroInfo(attrsComp);
|
||||
|
||||
const roleAfter = attrsComp.Attrs[attrCard.attr] || 0;
|
||||
console.log(`[MissionCard] Attr After: Global=${current[0]}, Hero=${roleAfter}`);
|
||||
}
|
||||
oops.gui.toast(attrCard.desc);
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user