refactor: 统一替换内置console日志为可配置化日志系统
1. 将各业务模块中的硬编码console日志替换为自定义Logger模块,新增DEBUG开关控制日志输出 2. 为MissSkillsComp新增道具卡牌使用处理逻辑,支持药水类技能直接给全队施加buff 3. 修复了道具卡牌事件监听绑定错误的问题 4. 新增了hero预制体的meta配置文件 5. 调整了装备预制体的UI布局参数
This commit is contained in:
@@ -11,6 +11,10 @@
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { BuffCategory, BuffList } from "../common/config/BuffSet";
|
||||
import { BuffComp, ActiveBuff } from "./BuffComp";
|
||||
import { mLogger } from "../common/Logger";
|
||||
|
||||
/** Buff 模块调试日志开关 */
|
||||
const DEBUG = false;
|
||||
|
||||
/** applyBuff 的覆盖参数(预留按需覆写持续时间 / 修饰数值) */
|
||||
export interface BuffApplyOverrides {
|
||||
@@ -37,10 +41,10 @@ class BuffManagerImpl {
|
||||
applyBuff(target: ecs.Entity, buffId: number, sourceUuid: number = 0, sourceAp: number = 0, overrides?: BuffApplyOverrides): void {
|
||||
const cfg = BuffList[buffId];
|
||||
if (!cfg) {
|
||||
console.log(`[BuffManager] applyBuff: buffId=${buffId} 配置不存在,跳过`);
|
||||
mLogger.warn(true, "BuffManager", `applyBuff: buffId=${buffId} 配置不存在,跳过`);
|
||||
return;
|
||||
}
|
||||
console.log(`[BuffManager] applyBuff: buff=${cfg.name}(${buffId}) target_eid=${target.eid} duration=${overrides?.duration ?? cfg.duration} value_override=${overrides?.value} source_ap=${sourceAp}`);
|
||||
mLogger.log(DEBUG, "BuffManager", `applyBuff: buff=${cfg.name}(${buffId}) target_eid=${target.eid} duration=${overrides?.duration ?? cfg.duration} value_override=${overrides?.value} source_ap=${sourceAp}`);
|
||||
|
||||
const buffComp = this.ensureBuffComp(target);
|
||||
const duration = overrides?.duration ?? cfg.duration;
|
||||
|
||||
@@ -15,6 +15,10 @@ import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { BuffList } from "../common/config/BuffSet";
|
||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||
import { BuffComp, ActiveBuff } from "./BuffComp";
|
||||
import { mLogger } from "../common/Logger";
|
||||
|
||||
/** Buff 模块调试日志开关 */
|
||||
const DEBUG = false;
|
||||
|
||||
/** 固定步长(秒) */
|
||||
const TICK_STEP = 0.1;
|
||||
@@ -60,7 +64,7 @@ export class BuffSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
if (cfg.duration > 0 && layer.remaining <= 0) {
|
||||
layers.splice(i, 1);
|
||||
anyChanged = true;
|
||||
console.log(`[BuffSystem] buff 到期移除: ${cfg.name}(${buffId}) eid=${e.eid} 剩余层数=${layers.length}`);
|
||||
mLogger.log(DEBUG, "BuffSystem", `buff 到期移除: ${cfg.name}(${buffId}) eid=${e.eid} 剩余层数=${layers.length}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
for (const mod of cfg.modifiers) {
|
||||
if (mod.attr !== attr) continue;
|
||||
const value = layerVal !== undefined ? layerVal : mod.value;
|
||||
console.log(`[HeroAttrs] aggregateTimedMods 命中: ${this.hero_name} buff=${cfg.name} attr=${attr} op=${mod.op} value=${value} remaining=${layers[i].remaining.toFixed(1)}`);
|
||||
mLogger.log(this.debugMode, "HeroAttrs", `aggregateTimedMods 命中: ${this.hero_name} buff=${cfg.name} attr=${attr} op=${mod.op} value=${value} remaining=${layers[i].remaining.toFixed(1)}`);
|
||||
if (mod.op === ModOp.Flat) {
|
||||
result.flatSum += value;
|
||||
} else {
|
||||
@@ -377,8 +377,8 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
const runtimeAp = this.getRuntimeAp(this.ap);
|
||||
const mods = this.aggregateTimedMods(Attrs.ap);
|
||||
const final = (runtimeAp + mods.flatSum) * (1 + mods.pctSum / 100);
|
||||
if (mods.flatSum !== 0 || mods.pctSum !== 0) {
|
||||
console.log(`[HeroAttrs] getFinalAp: ${this.hero_name} base=${this.ap} runtime=${runtimeAp.toFixed(1)} flat=${mods.flatSum} pct=${mods.pctSum} final=${final.toFixed(1)}`);
|
||||
if (this.debugMode && (mods.flatSum !== 0 || mods.pctSum !== 0)) {
|
||||
mLogger.log(this.debugMode, "HeroAttrs", `getFinalAp: ${this.hero_name} base=${this.ap} runtime=${runtimeAp.toFixed(1)} flat=${mods.flatSum} pct=${mods.pctSum} final=${final.toFixed(1)}`);
|
||||
}
|
||||
return final;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { GameEvent } from "../common/config/GameEvent";
|
||||
import { SkillTriggerType } from "../common/config/heroSet";
|
||||
import { SkillTriggerHelper } from "./SkillTriggerHelper";
|
||||
import { MissionEconomy } from "../map/MissionEconomy";
|
||||
import { mLogger } from "../common/Logger";
|
||||
import { MissionHeroComp } from "../map/MissionHeroComp";
|
||||
import { buffManager } from "./BuffManager";
|
||||
|
||||
@@ -142,11 +143,11 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
}
|
||||
}
|
||||
|
||||
console.log("[SCastSystem] forceCastCardSkill: casting skill", s_uuid, "castTimes", castTimes, "targetPos", targetPos, "isFriendly", isFriendly, "buff_value", config.buff_value, "timed_buff_id", config.timed_buff_id);
|
||||
mLogger.log(this.debugMode, "SCastSystem", "forceCastCardSkill: casting skill", s_uuid, "castTimes", castTimes, "targetPos", targetPos, "isFriendly", isFriendly, "buff_value", config.buff_value, "timed_buff_id", config.timed_buff_id);
|
||||
for (let i = 0; i < castTimes; i++) {
|
||||
if (isFriendly) {
|
||||
const friendlyTargets = this.resolveFriendlyTargets(targetEids, FacSet.HERO);
|
||||
console.log("[SCastSystem] friendlyTargets count =", friendlyTargets.length);
|
||||
mLogger.log(this.debugMode, "SCastSystem", "friendlyTargets count =", friendlyTargets.length);
|
||||
if (friendlyTargets.length === 0) continue;
|
||||
this.applyFriendlySkillEffects(s_uuid, cardLv, config, null as any, mockAttrs, friendlyTargets, spawnPos);
|
||||
} else {
|
||||
@@ -460,7 +461,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
if (!target.ent) return;
|
||||
const model = target.ent.get(HeroAttrsComp);
|
||||
if (!model || model.is_dead) return;
|
||||
console.log(`[SCastSystem] applyActualFriendlyEffect: skill=${config.uuid} kind=${kind} buff_type=${config.buff_type} timed_buff_id=${config.timed_buff_id} buff_value=${config.buff_value} target=${model.hero_name}`);
|
||||
mLogger.log(this.debugMode, "SCastSystem", `applyActualFriendlyEffect: skill=${config.uuid} kind=${kind} buff_type=${config.buff_type} timed_buff_id=${config.timed_buff_id} buff_value=${config.buff_value} target=${model.hero_name}`);
|
||||
|
||||
if (config.endAnm && config.endAnm !== "") {
|
||||
target.playEnd(config.endAnm);
|
||||
|
||||
@@ -28,7 +28,9 @@ import { SBox } from "./SBox";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { BoxSet } from "../common/config/GameSet";
|
||||
import { SkillOverrides } from "../common/config/SkillSet";
|
||||
import { SkillOverrides, SkillSet } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { buffManager } from "../hero/BuffManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 技能槽位数据结构 */
|
||||
@@ -74,7 +76,7 @@ export class MissSkillsComp extends CCComp {
|
||||
/** 注册事件监听 */
|
||||
onLoad() {
|
||||
oops.message.on(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
||||
oops.message.on(GameEvent.UseItemCard, this.onUseSkillCard, this);
|
||||
oops.message.on(GameEvent.UseItemCard, this.onUseItemCard, this);
|
||||
oops.message.on(GameEvent.RemoveSkillBox, this.onRemoveSkillBox, this);
|
||||
}
|
||||
|
||||
@@ -82,7 +84,7 @@ export class MissSkillsComp extends CCComp {
|
||||
onDestroy() {
|
||||
super.onDestroy();
|
||||
oops.message.off(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
||||
oops.message.off(GameEvent.UseItemCard, this.onUseSkillCard, this);
|
||||
oops.message.off(GameEvent.UseItemCard, this.onUseItemCard, this);
|
||||
oops.message.off(GameEvent.RemoveSkillBox, this.onRemoveSkillBox, this);
|
||||
}
|
||||
|
||||
@@ -149,6 +151,42 @@ export class MissSkillsComp extends CCComp {
|
||||
this.addSkill(skillUuid, card_lv, payload?.overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理药水卡使用事件:直接对全队存活英雄施加计时 buff,不经过 SBox 施法流程。
|
||||
*
|
||||
* 设计:
|
||||
* 药水是"即时全队强化",无需节点、动画、槽位;
|
||||
* 从技能配置取 timed_buff_id,遍历 heroGrid 对每个存活英雄 applyBuff,
|
||||
* buff_value 覆写值透传到 ActiveBuff.value_override。
|
||||
*
|
||||
* @param event 事件名
|
||||
* @param args 卡牌数据(含 skill、overrides)
|
||||
*/
|
||||
private onUseItemCard(event: string, args: any) {
|
||||
const payload = args ?? event;
|
||||
const skillId = Number(payload?.skill ?? 0);
|
||||
const config = SkillSet[skillId];
|
||||
if (!config) {
|
||||
mLogger.warn(this.debugMode, "MissSkillsComp", `potion skill ${skillId} config not found`);
|
||||
return;
|
||||
}
|
||||
const buffId = config.timed_buff_id;
|
||||
if (buffId === undefined) {
|
||||
mLogger.warn(this.debugMode, "MissSkillsComp", `potion skill ${skillId} has no timed_buff_id`);
|
||||
return;
|
||||
}
|
||||
const buffValue = payload?.overrides?.buff_value;
|
||||
let applied = 0;
|
||||
for (const eid of smc.mission.heroGrid) {
|
||||
if (eid <= 0) continue;
|
||||
const entity = ecs.getEntityByEid(eid);
|
||||
if (!entity) continue;
|
||||
buffManager.applyBuff(entity, buffId, 0, 0, buffValue !== undefined ? { value: buffValue } : undefined);
|
||||
applied++;
|
||||
}
|
||||
mLogger.log(this.debugMode, "MissSkillsComp", `potion applied: skill=${skillId} buff=${buffId} value=${buffValue} heroes=${applied}`);
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user