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.hp = Math.max(0, Math.min(this.hp, this.Attrs[Attrs.HP_MAX]));
|
||||||
this.dirty_hp = true; // ✅ 仅标记需要更新
|
this.dirty_hp = true; // ✅ 仅标记需要更新
|
||||||
smc.updateHeroInfo(this);
|
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){
|
add_mp(value:number,isValue:boolean){
|
||||||
const oldMp = this.mp;
|
const oldMp = this.mp;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export interface BuffInfo {
|
|||||||
@ccclass('HeroViewComp') // 定义Cocos Creator 组件
|
@ccclass('HeroViewComp') // 定义Cocos Creator 组件
|
||||||
@ecs.register('HeroView', false) // 定义ECS 组件
|
@ecs.register('HeroView', false) // 定义ECS 组件
|
||||||
export class HeroViewComp extends CCComp {
|
export class HeroViewComp extends CCComp {
|
||||||
private debugMode: boolean = true; // 是否启用调试模式
|
private debugMode: boolean = false; // 是否启用调试模式
|
||||||
|
|
||||||
// 添加条件日志方法
|
// 添加条件日志方法
|
||||||
private debugLog(...args: any[]): void {
|
private debugLog(...args: any[]): void {
|
||||||
@@ -198,7 +198,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
// 不再基于血量是否满来决定显示状态,只更新进度条
|
// 不再基于血量是否满来决定显示状态,只更新进度条
|
||||||
let hp=this.model.hp;
|
let hp=this.model.hp;
|
||||||
let hp_max=this.model.Attrs[Attrs.HP_MAX];
|
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 targetProgress = hp / hp_max;
|
||||||
let hpNode = this.top_node.getChildByName("hp");
|
let hpNode = this.top_node.getChildByName("hp");
|
||||||
@@ -501,17 +501,9 @@ export class HeroViewComp extends CCComp {
|
|||||||
// 伤害计算和战斗逻辑已迁移到 HeroBattleSystem
|
// 伤害计算和战斗逻辑已迁移到 HeroBattleSystem
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 调试日志(已禁用) */
|
|
||||||
to_console(value:any, value2:any=null, value3:any=null){
|
|
||||||
// 调试用,生产环境已禁用
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
playSkillEffect(skill_id:number) {
|
playSkillEffect(skill_id:number) {
|
||||||
let skill = SkillSet[skill_id]
|
let skill = SkillSet[skill_id]
|
||||||
console.log('[heroview] skill_id'+skill_id,skill)
|
this.debugLog('[heroview] skill_id'+skill_id,skill)
|
||||||
if (!skill) return;
|
if (!skill) return;
|
||||||
switch(skill.act){
|
switch(skill.act){
|
||||||
case "max":
|
case "max":
|
||||||
|
|||||||
@@ -440,7 +440,11 @@ export class MissionCardComp extends CCComp {
|
|||||||
// 直接调用 TalComp 添加天赋
|
// 直接调用 TalComp 添加天赋
|
||||||
const talComp = role.get(TalComp);
|
const talComp = role.get(TalComp);
|
||||||
if (talComp) {
|
if (talComp) {
|
||||||
|
const beforeCount = Object.keys(talComp.Tals).length;
|
||||||
|
console.log(`[MissionCard] Talent Before: Count=${beforeCount}`);
|
||||||
talComp.addTal(selectedData.uuid);
|
talComp.addTal(selectedData.uuid);
|
||||||
|
const afterCount = Object.keys(talComp.Tals).length;
|
||||||
|
console.log(`[MissionCard] Talent After: Count=${afterCount}, Added=${selectedData.uuid}`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CardType.Skill:
|
case CardType.Skill:
|
||||||
@@ -448,7 +452,11 @@ export class MissionCardComp extends CCComp {
|
|||||||
// 直接调用 HeroSkillsComp 添加技能
|
// 直接调用 HeroSkillsComp 添加技能
|
||||||
const skillComp = role.get(HeroSkillsComp);
|
const skillComp = role.get(HeroSkillsComp);
|
||||||
if (skillComp) {
|
if (skillComp) {
|
||||||
|
const beforeCount = Object.keys(skillComp.skills).length;
|
||||||
|
console.log(`[MissionCard] Skill Before: Count=${beforeCount}`);
|
||||||
skillComp.addSkill(selectedData.uuid);
|
skillComp.addSkill(selectedData.uuid);
|
||||||
|
const afterCount = Object.keys(skillComp.skills).length;
|
||||||
|
console.log(`[MissionCard] Skill After: Count=${afterCount}, Added=${selectedData.uuid}`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CardType.Partner:
|
case CardType.Partner:
|
||||||
@@ -461,6 +469,9 @@ export class MissionCardComp extends CCComp {
|
|||||||
if (attrsComp) {
|
if (attrsComp) {
|
||||||
const potion = PotionCards[selectedData.uuid];
|
const potion = PotionCards[selectedData.uuid];
|
||||||
if (potion) {
|
if (potion) {
|
||||||
|
const beforeVal = attrsComp.Attrs[potion.attr] || 0;
|
||||||
|
console.log(`[MissionCard] Potion Before: Attr[${potion.attr}]=${beforeVal}`);
|
||||||
|
|
||||||
const buffConf: BuffConf = {
|
const buffConf: BuffConf = {
|
||||||
buff: potion.attr,
|
buff: potion.attr,
|
||||||
value: potion.value,
|
value: potion.value,
|
||||||
@@ -470,6 +481,8 @@ export class MissionCardComp extends CCComp {
|
|||||||
};
|
};
|
||||||
attrsComp.addBuff(buffConf);
|
attrsComp.addBuff(buffConf);
|
||||||
smc.updateHeroInfo(attrsComp);
|
smc.updateHeroInfo(attrsComp);
|
||||||
|
|
||||||
|
console.log(`[MissionCard] Potion Applied: ${potion.desc}, Value=${potion.value}`);
|
||||||
oops.gui.toast(potion.desc);
|
oops.gui.toast(potion.desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,6 +491,17 @@ export class MissionCardComp extends CCComp {
|
|||||||
// 属性卡:更新全局属性并刷新主角
|
// 属性卡:更新全局属性并刷新主角
|
||||||
const attrCard = AttrCards[selectedData.uuid];
|
const attrCard = AttrCards[selectedData.uuid];
|
||||||
if (attrCard) {
|
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]) {
|
if (!smc.global_attrs[attrCard.attr]) {
|
||||||
smc.global_attrs[attrCard.attr] = [0, 0];
|
smc.global_attrs[attrCard.attr] = [0, 0];
|
||||||
}
|
}
|
||||||
@@ -485,13 +509,14 @@ export class MissionCardComp extends CCComp {
|
|||||||
current[0] += attrCard.value;
|
current[0] += attrCard.value;
|
||||||
current[1] += 1;
|
current[1] += 1;
|
||||||
|
|
||||||
console.log(`[MissionCard] 全局属性更新: Attr=${attrCard.attr}, Add=${attrCard.value}, Total=${current[0]}`);
|
|
||||||
|
|
||||||
// 直接触发主角属性重算
|
// 直接触发主角属性重算
|
||||||
const attrsComp = role.get(HeroAttrsComp);
|
const attrsComp = role.get(HeroAttrsComp);
|
||||||
if (attrsComp) {
|
if (attrsComp) {
|
||||||
attrsComp.recalculateSingleAttr(attrCard.attr);
|
attrsComp.recalculateSingleAttr(attrCard.attr);
|
||||||
smc.updateHeroInfo(attrsComp);
|
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);
|
oops.gui.toast(attrCard.desc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,21 @@ export class SkillView extends CCComp {
|
|||||||
@property({ type: CCInteger })
|
@property({ type: CCInteger })
|
||||||
atk_y: number = 0
|
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;
|
anim:Animation=null;
|
||||||
group:number=0;
|
group:number=0;
|
||||||
SConf:SkillConfig=null;
|
SConf:SkillConfig=null;
|
||||||
@@ -63,10 +78,10 @@ export class SkillView extends CCComp {
|
|||||||
const targetView = oCol.getComponent(HeroViewComp);
|
const targetView = oCol.getComponent(HeroViewComp);
|
||||||
const targetName = targetView?.ent?.get(HeroAttrsComp)?.hero_name ?? '非英雄对象';
|
const targetName = targetView?.ent?.get(HeroAttrsComp)?.hero_name ?? '非英雄对象';
|
||||||
const targetEid = targetView?.ent?.eid ?? '未知EID';
|
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) {
|
if (!this.sData || !this.SConf) {
|
||||||
console.warn('[SkillView] onBeginContact 缺少 sData 或 SConf,忽略此次碰撞');
|
this.debugWarn('[SkillView] onBeginContact 缺少 sData 或 SConf,忽略此次碰撞');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (oCol.group === seCol.group) return;
|
if (oCol.group === seCol.group) return;
|
||||||
@@ -98,7 +113,7 @@ export class SkillView extends CCComp {
|
|||||||
// 开启碰撞检测
|
// 开启碰撞检测
|
||||||
if(this.collider) {
|
if(this.collider) {
|
||||||
this.collider.enabled = true;
|
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
|
// 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) {
|
if(this.SConf.EType !== EType.collision && this.collider) {
|
||||||
this.collider.enabled = false;
|
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 不能超出 最大伤害数量
|
// if(this.sData.hit_count > this.SConf.hit_num) return 不能超出 最大伤害数量
|
||||||
// 使用伤害队列系统处理伤害
|
// 使用伤害队列系统处理伤害
|
||||||
DamageQueueHelper.addDamageToEntity(
|
DamageQueueHelper.addDamageToEntity(
|
||||||
|
|||||||
Reference in New Issue
Block a user