feat(技能系统): 扩展Buff运行类型并修复治疗与护盾配置
- 扩展BuffRunType枚举,新增Permanent和Timed类型,明确区分永久、定时和间隔效果 - 在HeroAttrsComp中重构addBuff方法,根据配置智能解析运行类型 - 为治疗(10301)和护盾(10302)配置显式添加runType: Permanent,确保逻辑一致性 - 修复定时Buff的持续时间处理,避免time为0时使用默认值1
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { Attrs, BType } from "../common/config/HeroAttrs";
|
||||
import { BuffConf, BuffRunType, SkillDisVal, SkillRange } from "../common/config/SkillSet";
|
||||
import { HeroInfo, HType } from "../common/config/heroSet";
|
||||
@@ -9,12 +7,7 @@ import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroViewComp } from "./HeroViewComp";
|
||||
import { _decorator } from "cc";
|
||||
|
||||
const { property } = _decorator;
|
||||
|
||||
interface talTrigger{
|
||||
value:number
|
||||
count:number
|
||||
}
|
||||
interface ActiveBuffState {
|
||||
id: number
|
||||
attr: Attrs
|
||||
@@ -180,7 +173,8 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
*/
|
||||
addBuff(buffConf: BuffConf) {
|
||||
const normalized = this.normalizeBuffValue(buffConf);
|
||||
if (buffConf.runType === BuffRunType.Interval) {
|
||||
const runType = this.resolveRunType(buffConf);
|
||||
if (runType === BuffRunType.Interval) {
|
||||
const interval = buffConf.interval && buffConf.interval > 0 ? buffConf.interval : 1;
|
||||
const remain = buffConf.time > 0 ? buffConf.time : interval;
|
||||
this.INTERVAL_EFFECTS.push({
|
||||
@@ -195,10 +189,11 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (buffConf.time <= 0) {
|
||||
if (runType === BuffRunType.Permanent) {
|
||||
this.applyAttrChange(buffConf.buff, normalized.value, normalized.BType);
|
||||
return;
|
||||
}
|
||||
const duration = buffConf.time > 0 ? buffConf.time : 1;
|
||||
|
||||
const targetList = buffConf.isDebuff ? this.DEBUFFS : this.BUFFS;
|
||||
const attrKey = buffConf.buff as unknown as number; // 强制转换 key 类型以适配 Record
|
||||
@@ -213,12 +208,18 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
sourceUuid: buffConf.uuid,
|
||||
value: normalized.value,
|
||||
BType: normalized.BType,
|
||||
time: buffConf.time
|
||||
time: duration
|
||||
});
|
||||
|
||||
this.applyAttrChange(buffConf.buff, normalized.value, normalized.BType);
|
||||
|
||||
mLogger.log(this.debugMode, 'HeroAttrs', `添加Buff: ${buffConf.name}, 属性:${buffConf.buff}, 值:${normalized.value}, 时间:${buffConf.time}`);
|
||||
mLogger.log(this.debugMode, 'HeroAttrs', `添加Buff: ${buffConf.name}, 属性:${buffConf.buff}, 值:${normalized.value}, 时间:${duration}`);
|
||||
}
|
||||
|
||||
private resolveRunType(buffConf: BuffConf): BuffRunType {
|
||||
if (buffConf.runType !== undefined) return buffConf.runType;
|
||||
if (buffConf.interval && buffConf.interval > 0) return BuffRunType.Interval;
|
||||
return buffConf.time > 0 ? BuffRunType.Timed : BuffRunType.Permanent;
|
||||
}
|
||||
|
||||
private normalizeBuffValue(buffConf: BuffConf): { value: number; BType: BType } {
|
||||
|
||||
Reference in New Issue
Block a user