fix: 将调试日志从console.log替换为mLogger并默认关闭调试模式
- 在MissionCardComp中默认关闭调试模式 - 在MissionHomeComp、Mon、HeroAttrsSystem和HInfoComp中引入mLogger - 使用debugMode控制日志输出,避免生产环境产生过多console日志
This commit is contained in:
@@ -5,6 +5,7 @@ import { Attrs } from "../common/config/HeroAttrs";
|
|||||||
import { HeroUpSet } from "../common/config/heroSet";
|
import { HeroUpSet } from "../common/config/heroSet";
|
||||||
import { HeroSkillsComp } from "./HeroSkills";
|
import { HeroSkillsComp } from "./HeroSkills";
|
||||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||||
|
import { mLogger } from "../common/Logger";
|
||||||
/**
|
/**
|
||||||
* ==================== 英雄属性更新系统 ====================
|
* ==================== 英雄属性更新系统 ====================
|
||||||
*
|
*
|
||||||
@@ -44,14 +45,14 @@ export class HeroAttrSystem extends ecs.ComblockSystem
|
|||||||
const model = e.get(HeroAttrsComp);
|
const model = e.get(HeroAttrsComp);
|
||||||
if (!model) return;
|
if (!model) return;
|
||||||
|
|
||||||
console.log(`[HeroAttrSystem] 英雄进入系统: ${model.hero_name} (uuid: ${model.hero_uuid})`);
|
mLogger.log(this.debugMode, 'HeroAttrSystem', `[HeroAttrSystem] 英雄进入系统: ${model.hero_name} (uuid: ${model.hero_uuid})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统首次更新前调用(整个系统只调用一次)
|
* 系统首次更新前调用(整个系统只调用一次)
|
||||||
*/
|
*/
|
||||||
firstUpdate(): void {
|
firstUpdate(): void {
|
||||||
console.log("[HeroAttrSystem] 系统首次更新");
|
mLogger.log(this.debugMode, 'HeroAttrSystem', "[HeroAttrSystem] 系统首次更新");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,7 +74,7 @@ export class HeroAttrSystem extends ecs.ComblockSystem
|
|||||||
|
|
||||||
// 调试日志(可选,调试时启用)
|
// 调试日志(可选,调试时启用)
|
||||||
if (this.debugMode) {
|
if (this.debugMode) {
|
||||||
console.log(` [${this.entityCount}] 更新英雄: ${model.hero_name}, HP: ${model.hp.toFixed(2)}`);
|
mLogger.log(this.debugMode, 'HeroAttrSystem', ` [${this.entityCount}] 更新英雄: ${model.hero_name}, HP: ${model.hp.toFixed(2)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 更新临时 Buff/Debuff(时间递减,过期自动移除)
|
// 1. 更新临时 Buff/Debuff(时间递减,过期自动移除)
|
||||||
@@ -106,7 +107,7 @@ export class HeroAttrSystem extends ecs.ComblockSystem
|
|||||||
// 每 60 帧输出一次统计
|
// 每 60 帧输出一次统计
|
||||||
this.frameCount++;
|
this.frameCount++;
|
||||||
if (this.frameCount % 60 === 0 && this.entityCount === 1) {
|
if (this.frameCount % 60 === 0 && this.entityCount === 1) {
|
||||||
console.log(`[HeroAttrSystem] 第 ${this.frameCount} 帧,处理 ${this.entityCount} 个英雄`);
|
mLogger.log(this.debugMode, 'HeroAttrSystem', `[HeroAttrSystem] 第 ${this.frameCount} 帧,处理 ${this.entityCount} 个英雄`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:显示更新由 HeroViewComp 负责,这里只处理数据
|
// 注意:显示更新由 HeroViewComp 负责,这里只处理数据
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { getMonAttr, MonType } from "../map/RogueConfig";
|
|||||||
import { HeroViewComp } from "./HeroViewComp";
|
import { HeroViewComp } from "./HeroViewComp";
|
||||||
import { HeroSkillsComp } from "./HeroSkills";
|
import { HeroSkillsComp } from "./HeroSkills";
|
||||||
import { MonMoveComp } from "./MonMove";
|
import { MonMoveComp } from "./MonMove";
|
||||||
|
import { mLogger } from "../common/Logger";
|
||||||
/** 角色实体 */
|
/** 角色实体 */
|
||||||
@ecs.register(`Monster`)
|
@ecs.register(`Monster`)
|
||||||
export class Monster extends ecs.Entity {
|
export class Monster extends ecs.Entity {
|
||||||
@@ -166,9 +167,9 @@ export class MonLifecycleSystem extends ecs.ComblockSystem
|
|||||||
// 怪物实体创建时的特殊处理
|
// 怪物实体创建时的特殊处理
|
||||||
const heroAttrs = e.get(HeroAttrsComp);
|
const heroAttrs = e.get(HeroAttrsComp);
|
||||||
if (heroAttrs) {
|
if (heroAttrs) {
|
||||||
console.log(`怪物进入世界: ${heroAttrs.hero_name}`);
|
mLogger.log(heroAttrs.debugMode, 'MonLifecycleSystem', `怪物进入世界: ${heroAttrs.hero_name}`);
|
||||||
} else {
|
} else {
|
||||||
console.log(`怪物进入世界: 实体ID ${e.eid}`);
|
mLogger.log(heroAttrs.debugMode, 'MonLifecycleSystem', `怪物进入世界: 实体ID ${e.eid}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +177,9 @@ export class MonLifecycleSystem extends ecs.ComblockSystem
|
|||||||
// 怪物实体销毁时的清理工作
|
// 怪物实体销毁时的清理工作
|
||||||
const heroAttrs = e.get(HeroAttrsComp);
|
const heroAttrs = e.get(HeroAttrsComp);
|
||||||
if (heroAttrs) {
|
if (heroAttrs) {
|
||||||
console.log(`怪物离开世界: ${heroAttrs.hero_name}`);
|
mLogger.log(heroAttrs.debugMode, 'MonLifecycleSystem', `怪物离开世界: ${heroAttrs.hero_name}`);
|
||||||
} else {
|
} else {
|
||||||
console.log(`怪物离开世界: 实体ID ${e.eid}`);
|
mLogger.log(heroAttrs.debugMode, 'MonLifecycleSystem', `怪物离开世界: 实体ID ${e.eid}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,14 @@ import { GameEvent } from '../common/config/GameEvent';
|
|||||||
import { CCComp } from 'db://oops-framework/module/common/CCComp';
|
import { CCComp } from 'db://oops-framework/module/common/CCComp';
|
||||||
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
|
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
|
||||||
import { SkillSet } from '../common/config/SkillSet';
|
import { SkillSet } from '../common/config/SkillSet';
|
||||||
|
import { mLogger } from '../common/Logger';
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass('HInfoComp')
|
@ccclass('HInfoComp')
|
||||||
@ecs.register('HInfoComp', false)
|
@ecs.register('HInfoComp', false)
|
||||||
export class HInfoComp extends CCComp {
|
export class HInfoComp extends CCComp {
|
||||||
|
debugMode: boolean = false;
|
||||||
|
|
||||||
h_uuid:number=0
|
h_uuid:number=0
|
||||||
private uiconsAtlas: SpriteAtlas | null = null;
|
private uiconsAtlas: SpriteAtlas | null = null;
|
||||||
name_node:any=null
|
name_node:any=null
|
||||||
@@ -116,15 +119,15 @@ export class HInfoComp extends CCComp {
|
|||||||
*/
|
*/
|
||||||
private updateSkillIcon(node: Node, iconId: string) {
|
private updateSkillIcon(node: Node, iconId: string) {
|
||||||
if (!node || !iconId) return;
|
if (!node || !iconId) return;
|
||||||
console.log("iconId",iconId)
|
mLogger.log(this.debugMode, 'HInfoComp', "iconId",iconId)
|
||||||
const iconNode = node.getChildByName("icon");
|
const iconNode = node.getChildByName("icon");
|
||||||
console.log("iconNode",iconNode)
|
mLogger.log(this.debugMode, 'HInfoComp', "iconNode",iconNode)
|
||||||
if (!iconNode) return;
|
if (!iconNode) return;
|
||||||
const sprite = iconNode.getComponent(Sprite);
|
const sprite = iconNode.getComponent(Sprite);
|
||||||
console.log("sprite",sprite)
|
mLogger.log(this.debugMode, 'HInfoComp', "sprite",sprite)
|
||||||
if (!sprite) return;
|
if (!sprite) return;
|
||||||
if (this.uiconsAtlas) {
|
if (this.uiconsAtlas) {
|
||||||
console.log("this.uiconsAtlas",this.uiconsAtlas)
|
mLogger.log(this.debugMode, 'HInfoComp', "this.uiconsAtlas",this.uiconsAtlas)
|
||||||
const frame = this.uiconsAtlas.getSpriteFrame(iconId);
|
const frame = this.uiconsAtlas.getSpriteFrame(iconId);
|
||||||
if (frame) {
|
if (frame) {
|
||||||
sprite.spriteFrame = frame;
|
sprite.spriteFrame = frame;
|
||||||
@@ -133,11 +136,11 @@ export class HInfoComp extends CCComp {
|
|||||||
// 加载图集
|
// 加载图集
|
||||||
resources.load("gui/uicons", SpriteAtlas, (err, atlas) => {
|
resources.load("gui/uicons", SpriteAtlas, (err, atlas) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error("[HInfoComp] Failed to load uicons atlas", err);
|
mLogger.log(this.debugMode, 'HInfoComp', "[HInfoComp] Failed to load uicons atlas", err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.uiconsAtlas = atlas;
|
this.uiconsAtlas = atlas;
|
||||||
console.log("atlas",atlas)
|
mLogger.log(this.debugMode, 'HInfoComp', "atlas",atlas)
|
||||||
const frame = atlas.getSpriteFrame(iconId);
|
const frame = atlas.getSpriteFrame(iconId);
|
||||||
if (frame) {
|
if (frame) {
|
||||||
sprite.spriteFrame = frame;
|
sprite.spriteFrame = frame;
|
||||||
@@ -207,7 +210,7 @@ export class HInfoComp extends CCComp {
|
|||||||
animComponent.play("idle");
|
animComponent.play("idle");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error(`[HInfoComp]: Failed to load animation for hero ${uuid}`, err);
|
mLogger.log(this.debugMode, 'HInfoComp', `[HInfoComp]: Failed to load animation for hero ${uuid}`, err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -291,7 +294,7 @@ export class HInfoComp extends CCComp {
|
|||||||
this.node.getChildByName("ranks").active=false
|
this.node.getChildByName("ranks").active=false
|
||||||
}
|
}
|
||||||
buy_hero(){
|
buy_hero(){
|
||||||
console.info("[HInfoComp]:buy_hero",this.h_uuid)
|
mLogger.log(this.debugMode, 'HInfoComp', "[HInfoComp]:buy_hero",this.h_uuid)
|
||||||
if(smc.vmdata.gold < HeroConf.COST) {
|
if(smc.vmdata.gold < HeroConf.COST) {
|
||||||
oops.gui.toast("金币不足")
|
oops.gui.toast("金币不足")
|
||||||
return
|
return
|
||||||
@@ -302,6 +305,7 @@ export class HInfoComp extends CCComp {
|
|||||||
this.close_buy()
|
this.close_buy()
|
||||||
}
|
}
|
||||||
start_mission() {
|
start_mission() {
|
||||||
|
mLogger.log(this.debugMode, 'HInfoComp', "[HInfoComp]:start_mission")
|
||||||
oops.message.dispatchEvent(GameEvent.MissionStart, {})
|
oops.message.dispatchEvent(GameEvent.MissionStart, {})
|
||||||
this.node.active=false;
|
this.node.active=false;
|
||||||
}
|
}
|
||||||
@@ -315,6 +319,7 @@ export class HInfoComp extends CCComp {
|
|||||||
this.isMoving = true;
|
this.isMoving = true;
|
||||||
|
|
||||||
// 在动画开始前,直接销毁hero_pos[6]上的节点
|
// 在动画开始前,直接销毁hero_pos[6]上的节点
|
||||||
|
mLogger.log(this.debugMode, 'HInfoComp', "hero_pos[6]",this.hero_pos[6])
|
||||||
if (this.heroNodes[6]) {
|
if (this.heroNodes[6]) {
|
||||||
this.heroNodes[6].destroy();
|
this.heroNodes[6].destroy();
|
||||||
this.heroNodes[6] = null;
|
this.heroNodes[6] = null;
|
||||||
@@ -323,6 +328,7 @@ export class HInfoComp extends CCComp {
|
|||||||
// 移动所有现有节点向左(除了已销毁的heroNodes[6])
|
// 移动所有现有节点向左(除了已销毁的heroNodes[6])
|
||||||
for (let i = 0; i < 6; i++) {
|
for (let i = 0; i < 6; i++) {
|
||||||
if (this.heroNodes[i]) {
|
if (this.heroNodes[i]) {
|
||||||
|
mLogger.log(this.debugMode, 'HInfoComp', "i",i)
|
||||||
// 计算目标位置:向左移动
|
// 计算目标位置:向左移动
|
||||||
let targetPos = this.hero_pos[i + 1];
|
let targetPos = this.hero_pos[i + 1];
|
||||||
|
|
||||||
@@ -339,11 +345,13 @@ export class HInfoComp extends CCComp {
|
|||||||
this.moveTimeoutId = setTimeout(() => {
|
this.moveTimeoutId = setTimeout(() => {
|
||||||
// 移动数组元素(向后平移)
|
// 移动数组元素(向后平移)
|
||||||
for (let i = 6; i > 0; i--) {
|
for (let i = 6; i > 0; i--) {
|
||||||
|
mLogger.log(this.debugMode, 'HInfoComp', "i",i)
|
||||||
this.heroNodes[i] = this.heroNodes[i - 1];
|
this.heroNodes[i] = this.heroNodes[i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建新节点放在hero_pos[0]位置
|
// 创建新节点放在hero_pos[0]位置
|
||||||
let heros = getHeroList();
|
let heros = getHeroList();
|
||||||
|
mLogger.log(this.debugMode, 'HInfoComp', "heros",heros)
|
||||||
let currentIndex = heros.indexOf(this.h_uuid);
|
let currentIndex = heros.indexOf(this.h_uuid);
|
||||||
let newIndex = currentIndex - 3; // 新的最左侧英雄索引
|
let newIndex = currentIndex - 3; // 新的最左侧英雄索引
|
||||||
|
|
||||||
@@ -356,6 +364,7 @@ export class HInfoComp extends CCComp {
|
|||||||
|
|
||||||
// 确保新创建的节点使用正确的缩放值
|
// 确保新创建的节点使用正确的缩放值
|
||||||
if (this.heroNodes[0]) {
|
if (this.heroNodes[0]) {
|
||||||
|
mLogger.log(this.debugMode, 'HInfoComp', "this.heroNodes[0]",this.heroNodes[0])
|
||||||
this.heroNodes[0].setScale(this.getHeroScale(0));
|
this.heroNodes[0].setScale(this.getHeroScale(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ interface ICardEvent {
|
|||||||
@ecs.register('MissionCard', false)
|
@ecs.register('MissionCard', false)
|
||||||
export class MissionCardComp extends CCComp {
|
export class MissionCardComp extends CCComp {
|
||||||
@property({ tooltip: "是否启用调试日志" })
|
@property({ tooltip: "是否启用调试日志" })
|
||||||
private debugMode: boolean = true;
|
private debugMode: boolean = false;
|
||||||
|
|
||||||
/** 视图层逻辑代码分离演示 */
|
/** 视图层逻辑代码分离演示 */
|
||||||
@property(Node)
|
@property(Node)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
|
|||||||
import { smc } from "../common/SingletonModuleComp";
|
import { smc } from "../common/SingletonModuleComp";
|
||||||
import { GameEvent } from "../common/config/GameEvent";
|
import { GameEvent } from "../common/config/GameEvent";
|
||||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||||
|
import { mLogger } from "../common/Logger";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@@ -12,6 +13,8 @@ const { ccclass, property } = _decorator;
|
|||||||
@ccclass('MissionHomeComp')
|
@ccclass('MissionHomeComp')
|
||||||
@ecs.register('MissionHome', false)
|
@ecs.register('MissionHome', false)
|
||||||
export class MissionHomeComp extends CCComp {
|
export class MissionHomeComp extends CCComp {
|
||||||
|
debugMode: boolean = false;
|
||||||
|
|
||||||
protected onLoad(): void {
|
protected onLoad(): void {
|
||||||
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
||||||
this.on(GameEvent.MissionStart,this.mission_start,this)
|
this.on(GameEvent.MissionStart,this.mission_start,this)
|
||||||
@@ -29,7 +32,7 @@ export class MissionHomeComp extends CCComp {
|
|||||||
|
|
||||||
|
|
||||||
mission_end(){
|
mission_end(){
|
||||||
console.log("[MissionHomeComp]=>mission_end")
|
mLogger.log(this.debugMode, 'MissionHomeComp', "[MissionHomeComp]=>mission_end")
|
||||||
this.home_active()
|
this.home_active()
|
||||||
}
|
}
|
||||||
mission_start(){
|
mission_start(){
|
||||||
|
|||||||
Reference in New Issue
Block a user