refactor(英雄技能): 重构天赋触发逻辑和技能施放系统
- 将HeroAttrsComp中的isDSill和isWFuny改为talTrigger结构体 - 移除TalComp中不再使用的checkTriggers和checkIsTrigger方法 - 优化SACastSystem中的技能施放逻辑,分离天赋处理代码块 - 为Skill.load方法添加damage参数 - 重命名executeCast返回变量为castSucess以提高可读性
This commit is contained in:
@@ -96,39 +96,6 @@ export class TalComp extends ecs.Comp {
|
||||
checkTal() {
|
||||
return Object.keys(this.Tals).length > 0;
|
||||
}
|
||||
/**
|
||||
* 检查并触发指定类型的天赋
|
||||
* @param triType 要检查的天赋触发类型
|
||||
* @returns 触发的天赋对象集合,若没有触发则返回false
|
||||
*
|
||||
* 检查逻辑:
|
||||
* 1. 遍历所有同类型天赋
|
||||
* 2. 检查累积值是否达到触发条件
|
||||
* 3. 触发后重置累积值
|
||||
* 4. 收集并返回所有触发的天赋
|
||||
*/
|
||||
checkTriggers(effet: TalEffet) {
|
||||
// 存储所有触发的天赋
|
||||
let Triggers: Record<string, TalSlot> = {};
|
||||
// 遍历所有天赋
|
||||
for (let uuid in this.Tals) {
|
||||
const talent = this.Tals[uuid];
|
||||
// 匹配天赋类型
|
||||
if (talent.effet == effet) {
|
||||
// 修复触发条件逻辑:累积值达到或超过触发阈值时触发
|
||||
// 原逻辑中 `talent.Trigger-talent.Trigger` 总是为0,导致任何累积值都能触发
|
||||
if (talent.cur >= (talent.Trigger - talent.Trigger_add)) { // 修复触发条件,累积值达到或超过触发阈值时触发
|
||||
console.log(`[TalComp]天赋触发,天赋ID:${uuid}`);
|
||||
// 重置累积值
|
||||
talent.cur = 0;
|
||||
// 添加到触发列表
|
||||
Triggers[uuid] = talent;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 判断是否有天赋被触发
|
||||
return Triggers;
|
||||
}
|
||||
getTriggers() {
|
||||
// 存储所有触发的天赋
|
||||
let Triggers: Record<string, TalSlot> = {};
|
||||
@@ -146,19 +113,7 @@ export class TalComp extends ecs.Comp {
|
||||
// 判断是否有天赋被触发
|
||||
return Triggers;
|
||||
}
|
||||
checkIsTrigger() {
|
||||
let res = {
|
||||
isDSill:false,
|
||||
isWFuny:false,
|
||||
}
|
||||
for(let uuid in this.Tals){
|
||||
let trigger=this.Tals[uuid]
|
||||
if(trigger.effet==TalEffet.WFUNY) res.isWFuny=true
|
||||
if(trigger.effet==TalEffet.D_SKILL) res.isDSill=true
|
||||
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新天赋的效果数值
|
||||
* @param talUuid 天赋ID
|
||||
|
||||
Reference in New Issue
Block a user