feat(天赋系统): 重构天赋buff处理逻辑并添加vType支持

- 在TalSlot接口和talConf配置中添加vType字段区分数值型和百分比型buff
- 重构HeroAttrsComp中BUFFS_TAL数据结构,改为以天赋uuid为key的映射
- 实现新的addTalBuff和clearTalBuff方法处理天赋buff
- 在TalComp中添加BUFF类型天赋的触发处理
This commit is contained in:
2025-11-20 14:35:29 +08:00
parent 94d5aa8920
commit f2ec48bd2b
3 changed files with 53 additions and 74 deletions

View File

@@ -1,4 +1,5 @@
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { BType } from "../common/config/HeroAttrs";
import { TalAttrs, talConf, TalEffet, TalTarget, TriType} from "../common/config/TalSet";
import { HeroAttrsComp } from "./HeroAttrsComp";
import { HeroViewComp } from "./HeroViewComp";
@@ -14,6 +15,7 @@ export interface TalSlot {
target: TalTarget;
effet: TalEffet;
attrs?:TalAttrs //触发的attrs效果的对应attrs value: number; // 触发的效果数值
vType:BType; // 数值型还是百分比型
value: number; // 触发的效果数值
value_add: number; // 触发的效果数值增量
Trigger: number; // 天赋触发阈值
@@ -86,6 +88,7 @@ export class TalComp extends ecs.Comp {
target: tConf.target,
effet: tConf.effet,
attrs: tConf.attrs,
vType: tConf.vType,
value: tConf.value, // 效果数值初始为配置值
value_add: 0, // 效果数值增量初始为0
Trigger: tConf.Trigger, // 触发阈值(后续可从配置中读取)
@@ -179,6 +182,7 @@ export class TalComp extends ecs.Comp {
}
}
//执行天赋触发效果
doTriggerTal(uuid: number) {
// 检查天赋是否存在
if (!this.Tals[uuid]) {
@@ -196,16 +200,13 @@ export class TalComp extends ecs.Comp {
heroAttrs.tal_DSill.count += 1;
heroAttrs.tal_DSill.value = talent.value+talent.value_add;
break;
case TalEffet.BUFF:
heroAttrs.addTalBuff(talent.uuid, talent.attrs, talent.vType, talent.value + talent.value_add);
break;
}
}
/**
* 重置组件状态
*
* 功能:
* - 清空所有天赋数据
* - 重置英雄ID
* - 清除英雄视图引用
* - 为组件的复用做准备
*/
reset() {
this.Tals = {};