From e5c4849e96d5ecde67283acce0574445c42fe1a0 Mon Sep 17 00:00:00 2001 From: pan Date: Fri, 28 Aug 2026 21:25:13 +0800 Subject: [PATCH] =?UTF-8?q?refactor(SSkillBoxComp):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=8B=B1=E9=9B=84=E9=85=8D=E7=BD=AE=E8=AF=AD=E5=A2=83=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E6=8A=80=E8=83=BD=E5=90=8D=E7=A7=B0=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增resolveHeroSkillName方法,实现英雄图鉴模式下的技能名称智能解析,优先从英雄配置中获取技能展示名,未命中时回退原有逻辑。 --- assets/script/game/map/SSkillBoxComp.ts | 41 +++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/assets/script/game/map/SSkillBoxComp.ts b/assets/script/game/map/SSkillBoxComp.ts index ddb38694..851f5a88 100644 --- a/assets/script/game/map/SSkillBoxComp.ts +++ b/assets/script/game/map/SSkillBoxComp.ts @@ -4,7 +4,10 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu import { oops } from "db://oops-framework/core/Oops"; import { CardTriggerType } from "../common/config/CardSet"; import { SkillSet, FieldSkillSet } from "../common/config/SkillSet"; -import { FieldEntry } from "../common/config/heroSet"; +import { + FieldEntry, HeroInfo, TriggerGrouped, SkillTriggerType, + getGroupedTriggerName, getFieldSkillName, getReviveSkillName, +} from "../common/config/heroSet"; import { UIID } from "../common/config/GameUIConfig"; import { smc } from "../common/SingletonModuleComp"; const { ccclass, property } = _decorator; @@ -149,10 +152,17 @@ export class SSkillBoxComp extends CCComp { /** * 解析技能名称: - * 优先取显式设置的卡牌名;否则按图标来源从 SkillSet / FieldSkillSet 取技能名。 + * 1. 显式设置的卡牌名(最高优先级); + * 2. 英雄图鉴模式(hero_uuid>0):从 heroSet 英雄配置解析英雄语境名 + * (普攻/大招 HSkillInfo.name、trigger 组名、光环 FieldEntry.name、复活 LvReviveEntry.name); + * 3. 回退 SkillSet / FieldSkillSet 底座名。 */ private resolveSkillName(): string { if (this.skill_name) return this.skill_name; + if (this.hero_uuid > 0) { + const heroName = this.resolveHeroSkillName(); + if (heroName) return heroName; + } if (this.hero_icon_source === "field") { return this.s_uuid ? (FieldSkillSet[this.s_uuid]?.name ?? "") : ""; } @@ -169,6 +179,33 @@ export class SSkillBoxComp extends CCComp { return ""; } + /** + * 英雄图鉴模式:按技能 uuid 在英雄配置中定位,取英雄语境展示名。 + * 覆盖普攻/大招(skills)、5 类触发技能、驻场光环(field)、复活(revive)。 + * 未命中返回空串,由调用方回退底座名。 + */ + private resolveHeroSkillName(): string { + const hero = HeroInfo[this.hero_uuid]; + if (!hero) return ""; + // 普攻/大招 + const hSkill = hero.skills?.[this.s_uuid]; + if (hSkill?.name) return hSkill.name; + // 触发技能组(call/dead/fstart/atking/atked) + for (const type of [SkillTriggerType.Call, SkillTriggerType.Dead, SkillTriggerType.FStart, SkillTriggerType.Atking, SkillTriggerType.Atked]) { + const grouped = hero[type] as TriggerGrouped | undefined; + if (grouped?.[this.s_uuid]?.length) return getGroupedTriggerName(grouped, this.s_uuid); + } + // 驻场光环词条 + if (hero.field?.some(e => e.uuids.some(u => u.uuid === this.s_uuid))) { + return getFieldSkillName(hero, this.s_uuid); + } + // 复活技能 + if (hero.revive?.some(e => e.s_uuid === this.s_uuid)) { + return getReviveSkillName(hero, this.s_uuid); + } + return ""; + } + /** * 更新 UI: * - 背景:根据技能等级切换对应颜色子节点显示