refactor(hero): 重命名天赋相关方法以区分计数型和数值型
将计数型天赋操作方法从addTalent/consumeTalent重命名为addCountTal/useCountTal 将数值型天赋操作方法从addTalBuff/clearTalBuff重命名为addValueTal/useValueTalByUuid 更新相关文档和调用代码以保持一致性
This commit is contained in:
@@ -35,7 +35,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
shield: number = 0; // 当前护盾
|
||||
Attrs: any = []; // 最终属性数组(经过Buff计算后)
|
||||
NeAttrs: any = []; // 负面状态数组
|
||||
Talents: Record<number, talTrigger> = {};
|
||||
//计数型天赋buff
|
||||
Talents: Record<number, talTrigger> = {};
|
||||
//数值型天赋buff
|
||||
BUFFS_TAL: Record<number, {count:number,BType:BType,attrIndex:number,value: number}> = {};
|
||||
|
||||
// ==================== 技能距离缓存 ====================
|
||||
@@ -407,7 +409,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
}
|
||||
|
||||
|
||||
addTalBuff(t_uuid: number, attrIndex?: number, bType?: BType, value: number = 0) {
|
||||
addValueTal(t_uuid: number, attrIndex?: number, bType?: BType, value: number = 0) {
|
||||
if (attrIndex === undefined || bType === undefined) return;
|
||||
const buff = this.BUFFS_TAL[t_uuid];
|
||||
if (!buff) {
|
||||
@@ -418,14 +420,27 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
}
|
||||
this.recalculateSingleAttr(attrIndex);
|
||||
}
|
||||
clearTalBuff(t_uuid: number) {
|
||||
addCountTal(eff: number, value: number) {
|
||||
const t = this.Talents[eff] || { value: 0, count: 0 };
|
||||
t.value = value;
|
||||
t.count += 1;
|
||||
this.Talents[eff] = t;
|
||||
}
|
||||
|
||||
useCountTal(eff: number): boolean {
|
||||
const t = this.Talents[eff];
|
||||
if (!t || t.count <= 0) return false;
|
||||
t.count -= 1;
|
||||
return true;
|
||||
}
|
||||
useValueTalByUuid(t_uuid: number) {
|
||||
const buff = this.BUFFS_TAL[t_uuid];
|
||||
if (!buff) return;
|
||||
const attrIndex = buff.attrIndex;
|
||||
delete this.BUFFS_TAL[t_uuid];
|
||||
this.recalculateSingleAttr(attrIndex);
|
||||
}
|
||||
clearTalBuffByAttr(attrIndex: number) {
|
||||
useValueTalByAttr(attrIndex: number) {
|
||||
let changed = false;
|
||||
for (const key in this.BUFFS_TAL) {
|
||||
const b = this.BUFFS_TAL[Number(key)];
|
||||
@@ -436,20 +451,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
}
|
||||
if (changed) this.recalculateSingleAttr(attrIndex);
|
||||
}
|
||||
|
||||
addTalent(eff: number, value: number) {
|
||||
const t = this.Talents[eff] || { value: 0, count: 0 };
|
||||
t.value = value;
|
||||
t.count += 1;
|
||||
this.Talents[eff] = t;
|
||||
}
|
||||
consumeTalent(eff: number): boolean {
|
||||
const t = this.Talents[eff];
|
||||
if (!t || t.count <= 0) return false;
|
||||
t.count -= 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
reset() {
|
||||
// 重置为初始状态
|
||||
this.hero_uuid = 1001;
|
||||
|
||||
Reference in New Issue
Block a user