refactor: 移除调试日志并统一使用日志工具

- 删除多个文件中的 console.log/console.warn/console.error 调试输出
- 将日志输出统一替换为 mLogger 工具,支持调试模式控制
- 清理注释掉的调试代码和空方法体
This commit is contained in:
panw
2026-02-03 16:49:24 +08:00
parent dc746e28da
commit 3a8f015a78
21 changed files with 65 additions and 80 deletions

View File

@@ -7,8 +7,6 @@ import { HeroViewComp } from "./HeroViewComp";
import { BoxSet, FacSet, IndexSet } from "../common/config/GameSet";
import { HeroInfo, HeroPos, HType } from "../common/config/heroSet";
import { GameEvent } from "../common/config/GameEvent";
import { SkillSet } from "../common/config/SkillSet";
import { time } from "console";
import { getNeAttrs, getAttrs ,Attrs} from "../common/config/HeroAttrs";
import { HeroSkillsComp } from "./HeroSkills";
import { HeroMoveComp } from "./HeroMove";
@@ -24,6 +22,7 @@ export class Hero extends ecs.Entity {
View!: HeroViewComp;
HeroMove!: HeroMoveComp;
TalComp!: TalComp;
debugMode: boolean = false; // 是否启用调试模式
protected init() {
this.addComponents<ecs.Comp>(
HeroMoveComp,
@@ -50,7 +49,6 @@ export class Hero extends ecs.Entity {
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,fight_pos:number=1,is_master:boolean=false,is_friend:boolean=false) {
// console.log("英雄加载:",uuid,pos,scale,info)
scale = 1
// 查找空闲英雄槽位
let size=1
@@ -66,9 +64,8 @@ export class Hero extends ecs.Entity {
// 🔥 设置初始 SiblingIndex - 英雄基础层级 + 位置偏移
console.log("hero",node.getSiblingIndex());
mLogger.log(this.debugMode,"hero",node.getSiblingIndex());
// console.log("hero load",pos)
var hv = node.getComponent(HeroViewComp)!;
const model = this.get(HeroAttrsComp);
const skillsComp = this.get(HeroSkillsComp);
@@ -89,7 +86,7 @@ export class Hero extends ecs.Entity {
model.rangeType = hero.rangeType;
// 只有主角才挂载天赋组件
if (is_master) {
console.log(`[Hero] 主角创建, uuid=${uuid}`);
mLogger.log(this.debugMode,`[Hero] 主角创建, uuid=${uuid}`);
this.add(TalComp);
this.add(HeroMasterComp)
const talComp = this.get(TalComp);

View File

@@ -28,7 +28,6 @@ export default class HeroAnmComp extends Component{
this._hasStop = true;
}
onAnimationFinished(type:Animation.EventType, state:AnimationState){
// console.log("[HeroAnmComp]: 动画播放完毕",state.name)
if(state.name!="idle"&&state.name!="move"&&state.name!="dead"&&state.name!="stun"){
this.anmcon.play(this.default_anim)
}

View File

@@ -278,7 +278,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
CView.scheduleRevive(1.0);
}
console.log(`[HeroAtkSystem] Hero waiting to revive from Thorns! Lives left: ${CAttrs.Attrs[Attrs.REVIVE_COUNT]}`);
mLogger.log(this.debugMode, 'HeroAtkSystem', `[HeroAtkSystem] Hero waiting to revive from Thorns! Lives left: ${CAttrs.Attrs[Attrs.REVIVE_COUNT]}`);
return;
}
@@ -286,7 +286,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
if (CAttrs.is_master&&CAttrs.Attrs[Attrs.REVIVE_COUNT] <= 0) {
smc.mission.stop_mon_action = true;
oops.message.dispatchEvent(GameEvent.HeroDead, { hero_uuid: CAttrs.hero_uuid});
console.log("[HeroAtkSystem] Hero died from thorns, stopping monster action (spawn/move)");
mLogger.log(this.debugMode, 'HeroAtkSystem', "[HeroAtkSystem] Hero died from thorns, stopping monster action (spawn/move)");
}
this.doDead(caster);
@@ -409,7 +409,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
this.onDeath(entity);
if (this.debugMode) {
console.log(`[HeroAtkSystem] ${TAttrsComp.hero_name} 死亡`);
mLogger.log(this.debugMode, 'HeroAtkSystem', `[HeroAtkSystem] ${TAttrsComp.hero_name} 死亡`);
}
}

View File

@@ -283,7 +283,7 @@ export class HeroAttrsComp extends ecs.Comp {
}
this.shield += addValue;
this.dirty_shield = true; // 标记护盾需要更新
console.log(`[HeroAttrs] 护盾变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldShield.toFixed(1)} -> ${this.shield.toFixed(1)}`);
mLogger.log(this.debugMode, 'HeroAttrs', `[HeroAttrs] 护盾变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldShield.toFixed(1)} -> ${this.shield.toFixed(1)}`);
}
// ==================== BUFF 管理 ====================
/**

View File

@@ -72,7 +72,7 @@ export class HeroSkillsComp extends ecs.Comp {
const s_uuid = sUuids[i];
const config = SkillSet[s_uuid];
if (!config) {
console.warn(`[HeroSkills] 技能配置不存在: ${s_uuid}`);
mLogger.warn(this.debugMode, 'HeroSkills', `[HeroSkills] 技能配置不存在: ${s_uuid}`);
continue;
}
// 第0个技能的 cd_max 取 herosinfo[uuid].as

View File

@@ -36,18 +36,15 @@ export class HeroSpine extends Component {
}
idle(){
// console.log("change to idle",this.status);
// console.log("do Idle");
if(this.status=="idle") return
this.status="idle"
this.anm.idle()
}
atk() {
// console.log("do atk");
this.anm.atk()
}
max(){
// console.log("do max");
this.anm.max()
}
play(name:string){
@@ -70,7 +67,6 @@ export class HeroSpine extends Component {
this.anm.atked()
}
dead(){
// console.log("do dead");
this.anm.dead()
}
do_buff(){
@@ -80,7 +76,6 @@ export class HeroSpine extends Component {
this.anm.buff()
}
move(){
// console.log("change to move",this.status);
if(this.status=="move") return
this.status="move"
this.anm.move()

View File

@@ -63,7 +63,6 @@ export class HeroViewComp extends CCComp {
private damageInterval: number = 0.01; // 伤害数字显示间隔
onLoad() {
this.as = this.getComponent(HeroSpine);
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
const collider = this.node.getComponent(BoxCollider2D);
this.scheduleOnce(()=>{
if (collider) {
@@ -377,7 +376,7 @@ export class HeroViewComp extends CCComp {
// 恢复怪物行动
if (this.model.is_master) {
smc.mission.stop_mon_action = false;
console.log("[HeroViewComp] Hero revived, resuming monster action");
mLogger.log(this.debugMode, 'HeroViewComp', "[HeroViewComp] Hero revived, resuming monster action");
}
}

View File

@@ -11,6 +11,7 @@ import { TalEffet, TriType } from "../common/config/TalSet";
import { BoxSet, FacSet } from "../common/config/GameSet";
import { GameConst } from "../common/config/GameConst";
import { Attrs } from "../common/config/HeroAttrs";
import { mLogger } from "../common/Logger";
/**
* ==================== 自动施法系统 ====================
@@ -29,6 +30,7 @@ import { Attrs } from "../common/config/HeroAttrs";
*/
@ecs.register('SACastSystem')
export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
debugMode: boolean = false; // 是否启用调试模式
filter(): ecs.IMatcher {
return ecs.allOf(HeroSkillsComp, HeroAttrsComp, HeroViewComp);
@@ -155,7 +157,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
const heroAttrs=casterEntity.get(HeroAttrsComp)
const config = SkillSet[s_uuid];
if (!config) {
console.error("[SACastSystem] 技能配置不存在:", s_uuid);
mLogger.error(this.debugMode, 'SACastSystem', "[SACastSystem] 技能配置不存在:", s_uuid);
return false;
}
@@ -182,7 +184,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
// 获取目标位置(伤害技能)
let targets = this.sTargets(heroView, s_uuid);
if (targets.length === 0) {
console.warn("[SACastSystem] 没有找到有效目标");
mLogger.warn(this.debugMode, 'SACastSystem', "[SACastSystem] 没有找到有效目标");
return false;
}
// 2.1 普通攻击逻辑
@@ -243,14 +245,14 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],ext_dmg:number=0) {
// 检查节点有效性
if (!caster.node || !caster.node.isValid) {
console.warn("[SACastSystem] 施法者节点无效");
mLogger.warn(this.debugMode, 'SACastSystem', "[SACastSystem] 施法者节点无效");
return;
}
// 获取场景节点
const parent = caster.node.parent;
if (!parent) {
console.warn("[SACastSystem] 场景节点无效");
mLogger.warn(this.debugMode, 'SACastSystem', "[SACastSystem] 场景节点无效");
return;
}
@@ -263,7 +265,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
const startPos = caster.node.position.clone();
const targetPos = targets[0]; // 使用第一个目标位置
// console.log(`[SACastSystem]: ${s_uuid}, 起始位置: ${startPos}, 目标位置: ${targetPos}`);
// mLogger.log(this.debugMode, 'SACastSystem', `[SACastSystem]: ${s_uuid}, 起始位置: ${startPos}, 目标位置: ${targetPos}`);
// 加载技能实体(包括预制体、组件初始化等)
skill.load(startPos, parent, s_uuid, targetPos, caster,ext_dmg);
@@ -440,7 +442,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
// 检查概率
if (buffConf.chance >= 1 || Math.random() < buffConf.chance) {
targetAttrs.addBuff(buffConf);
console.log(`[SACastSystem] Buff生效: 施法者=${casterEntity.get(HeroAttrsComp)?.hero_name}, 技能=${config.name}, 目标=${targetAttrs.hero_name}, Buff类型=${buffConf.buff}, 值=${buffConf.value}`);
mLogger.log(this.debugMode, 'SACastSystem', `[SACastSystem] Buff生效: 施法者=${casterEntity.get(HeroAttrsComp)?.hero_name}, 技能=${config.name}, 目标=${targetAttrs.hero_name}, Buff类型=${buffConf.buff}, 值=${buffConf.value}`);
}
}
}
@@ -508,7 +510,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
targetAttrs.add_hp(healAmount, true);
targetView.health(healAmount);
console.log(`[SACastSystem] 治疗生效: 施法者=${casterEntity.get(HeroAttrsComp)?.hero_name}, 技能=${config.name}, 目标=${targetAttrs.hero_name}, 治疗量=${healAmount}`);
mLogger.log(this.debugMode, 'SACastSystem', `[SACastSystem] 治疗生效: 施法者=${casterEntity.get(HeroAttrsComp)?.hero_name}, 技能=${config.name}, 目标=${targetAttrs.hero_name}, 治疗量=${healAmount}`);
}
}, delay);
@@ -537,7 +539,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
targetAttrs.add_shield(shieldAmount, true);
targetView.add_shield(shieldAmount);
console.log(`[SACastSystem] 护盾生效: 施法者=${casterEntity.get(HeroAttrsComp)?.hero_name}, 技能=${config.name}, 目标=${targetAttrs.hero_name}, 护盾量=${shieldAmount}`);
mLogger.log(this.debugMode, 'SACastSystem', `[SACastSystem] 护盾生效: 施法者=${casterEntity.get(HeroAttrsComp)?.hero_name}, 技能=${config.name}, 目标=${targetAttrs.hero_name}, 护盾量=${shieldAmount}`);
}
}, delay);