refactor(MissionHeroComp): 移除闲置的驻场技能总加成计算方法
This commit is contained in:
33
assets/script/game/hero/FieldSkillHelper.ts
Normal file
33
assets/script/game/hero/FieldSkillHelper.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { FacSet } from "../common/config/GameSet";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { FieldSkillSet, FieldSkillType } from "../common/config/SkillSet";
|
||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||
|
||||
/**
|
||||
* 驻场技能(光环属性)计算辅助类
|
||||
*
|
||||
* 核心职责:
|
||||
* 统一管理全场存活英雄带来的全局加成属性计算。
|
||||
* 解耦原先写在 HeroAttrsComp 中的静态计算逻辑,符合单一职责原则。
|
||||
*/
|
||||
export class FieldSkillHelper {
|
||||
/** 获取指定驻场技能类型的总加成值(只计算存活的友方英雄) */
|
||||
public static getFieldSkillTotalValue(type: FieldSkillType): number {
|
||||
let total = 0;
|
||||
ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => {
|
||||
const model = entity.get(HeroAttrsComp);
|
||||
if (!model || model.is_dead || model.fac !== FacSet.HERO) return;
|
||||
const heroConfig = HeroInfo[model.hero_uuid];
|
||||
if (heroConfig && heroConfig.field) {
|
||||
for (const skillUuid of heroConfig.field) {
|
||||
const skillConfig = FieldSkillSet[skillUuid];
|
||||
if (skillConfig && skillConfig.type === type) {
|
||||
total += skillConfig.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return total;
|
||||
}
|
||||
}
|
||||
9
assets/script/game/hero/FieldSkillHelper.ts.meta
Normal file
9
assets/script/game/hero/FieldSkillHelper.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "140c8aaf-42b4-4f1c-880a-dd43af7588a2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { FacSet, FightSet } from "../common/config/GameSet";
|
||||
import { FieldSkillSet, FieldSkillType } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { TalentConfig, TalentType } from "../common/config/TalentSet";
|
||||
import { FieldSkillHelper } from "./FieldSkillHelper";
|
||||
@ecs.register('HeroAttrs')
|
||||
export class HeroAttrsComp extends ecs.Comp {
|
||||
public debugMode: boolean = false;
|
||||
@@ -203,7 +204,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
|
||||
/** 将驻场配置值统一换算成百分比数值,兼容 0.2 和 20 两种写法。 */
|
||||
private getFieldPercentValue(type: FieldSkillType): number {
|
||||
const rawValue = HeroAttrsComp.getFieldSkillTotalValue(type);
|
||||
const rawValue = FieldSkillHelper.getFieldSkillTotalValue(type);
|
||||
if (Math.abs(rawValue) <= HeroAttrsComp.percentRateThreshold) {
|
||||
return rawValue * 100;
|
||||
}
|
||||
@@ -340,24 +341,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.dirty_shield = false;
|
||||
}
|
||||
|
||||
/** 获取指定驻场技能类型的总加成值(只计算存活的英雄) */
|
||||
public static getFieldSkillTotalValue(type: FieldSkillType): number {
|
||||
let total = 0;
|
||||
ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => {
|
||||
const model = entity.get(HeroAttrsComp);
|
||||
if (!model || model.is_dead || model.fac !== FacSet.HERO) return;
|
||||
const heroConfig = HeroInfo[model.hero_uuid];
|
||||
if (heroConfig && heroConfig.field) {
|
||||
for (const skillUuid of heroConfig.field) {
|
||||
const skillConfig = FieldSkillSet[skillUuid];
|
||||
if (skillConfig && skillConfig.type === type) {
|
||||
total += skillConfig.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
/** 获取指定天赋的加成数值 */
|
||||
public static getTalentValue(talentId: TalentType): number {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { FacSet } from "../common/config/GameSet";
|
||||
import { FieldSkillType } from "../common/config/SkillSet";
|
||||
import { TalentType } from "../common/config/TalentSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { FieldSkillHelper } from "./FieldSkillHelper";
|
||||
|
||||
|
||||
/**
|
||||
@@ -65,7 +66,7 @@ export class SkillTriggerHelper {
|
||||
let triggerCount = 1;
|
||||
// 仅英雄享受加成,怪物始终只触发 1 次
|
||||
if (model.fac === FacSet.HERO) {
|
||||
triggerCount += HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.SummonCount);
|
||||
triggerCount += FieldSkillHelper.getFieldSkillTotalValue(FieldSkillType.SummonCount);
|
||||
triggerCount += HeroAttrsComp.getTalentValue(TalentType.Summon);
|
||||
}
|
||||
triggerCount = Math.max(1, Math.floor(triggerCount)); // 确保最少触发 1 次
|
||||
@@ -84,7 +85,7 @@ export class SkillTriggerHelper {
|
||||
|
||||
let triggerCount = 1;
|
||||
if (model.fac === FacSet.HERO) {
|
||||
triggerCount += HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.DeadCount);
|
||||
triggerCount += FieldSkillHelper.getFieldSkillTotalValue(FieldSkillType.DeadCount);
|
||||
// 【局内战绩评分系统】统计死亡触发技能生效次数(用于局后防守评分结算)
|
||||
smc.vmdata.scores.dead_trigger_count += model.dead.length;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user