feat(talents): 重构驻场技能页面为天赋图鉴页面

- 调整天赋预制体布局参数,包含容器宽度、边距和间距
- 移除旧的驻场技能相关UI节点引用
- 替换数据来源为卡牌池技能卡,重构列表渲染与排序逻辑
- 更新UI展示逻辑,显示天赋名称、描述、图标和对应品质背景
- 优化组件注释与属性描述,统一代码风格
This commit is contained in:
pan
2026-06-09 10:01:44 +08:00
parent dfbac61ed9
commit 12449c8d1d
4 changed files with 496 additions and 2427 deletions

View File

@@ -1,36 +1,34 @@
/**
* @file TalentsComp.ts
* @description 驻场技能信息展示页组件UI 视图层)
* @description 天赋图鉴页组件UI 视图层)
*
* 职责:
* 1. 展示当前所有 FieldSkillSet 配置项的名称、基础值、当前场上总加成
* 2. 通过 FieldSkillHelper 实时聚合英雄驻场数据并下发给每个 TalentItemComp
* 1. 展示当前所有天赋卡(技能卡)的图鉴
* 2. 从 CardPoolList 获取所有的 type=Skill 卡牌
* 3. 兼容旧的 `@ecs.register('Talents')` 资源引用。
*
* 依赖:
* - SkillSetFieldSkillSet / FieldSkillConfig)—— 驻场技能配置
* - FieldSkillHelper —— 场上英雄驻场技能聚合
* - TalentItemComp —— 单条驻场技能项视图
* - CardPoolListCardSet)—— 获取技能配置
* - TalentItemComp —— 单条天赋图鉴项视图
*/
import { _decorator, instantiate, Node, Prefab } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { mLogger } from "../common/Logger";
import { FieldSkillSet, FieldSkillConfig } from "../common/config/SkillSet";
import { FieldSkillHelper } from "../hero/FieldSkillHelper";
import { CardPoolList, CardType, CardConfig } from "../common/config/CardSet";
import { TalentItemComp } from "./TalentItemComp";
const { ccclass, property } = _decorator;
/** TalentsComp —— 驻场技能信息页组件 */
/** TalentsComp —— 天赋图鉴信息页组件 */
@ccclass('TalentsComp')
@ecs.register('Talents', false)
export class TalentsComp extends CCComp {
@property({ type: Node, tooltip: "驻场技能列表容器" })
@property({ type: Node, tooltip: "天赋技能列表容器" })
talents_content: Node = null!;
@property({ type: Prefab, tooltip: "单条驻场技能项预制" })
@property({ type: Prefab, tooltip: "单条天赋项预制" })
prefab_talent_item: Prefab = null!;
/** 调试日志开关 */
@@ -40,7 +38,7 @@ export class TalentsComp extends CCComp {
private rendered: boolean = false;
/** 缓存的稳定配置顺序,避免重复渲染时列表抖动 */
private cachedConfigs: FieldSkillConfig[] = [];
private cachedConfigs: CardConfig[] = [];
protected onEnable(): void {
this.refreshUI();
@@ -50,30 +48,36 @@ export class TalentsComp extends CCComp {
public refreshUI(): void {
if (!this.talents_content || !this.prefab_talent_item) return;
// 第一次:实例化所有子节点;之后只更新数据
// 第一次:实例化所有子节点
if (!this.rendered) {
this.cachedConfigs = Object.values(FieldSkillSet)
.sort((a, b) => a.uuid - b.uuid);
// 获取所有天赋(技能卡)并按 wave 和 uuid 排序
this.cachedConfigs = CardPoolList.filter(card => card.type === CardType.Skill)
.sort((a, b) => {
const waveA = a.wave || 1;
const waveB = b.wave || 1;
if (waveA !== waveB) return waveA - waveB;
return a.uuid - b.uuid;
});
this.cachedConfigs.forEach((cfg) => {
const itemNode = instantiate(this.prefab_talent_item);
this.talents_content.addChild(itemNode);
const comp = itemNode.getComponent(TalentItemComp);
if (comp) {
comp.updateItem(cfg, 0);
comp.updateItem(cfg);
}
});
this.rendered = true;
} else {
// 如果已渲染,则仅更新数据(图鉴一般不会变动,这里做个兜底更新)
this.cachedConfigs.forEach((cfg, index) => {
const child = this.talents_content.children[index];
if (!child) return;
const comp = child.getComponent(TalentItemComp);
if (!comp) return;
comp.updateItem(cfg);
});
}
// 按相同顺序回填最新场上聚合值
this.cachedConfigs.forEach((cfg, index) => {
const child = this.talents_content.children[index];
if (!child) return;
const comp = child.getComponent(TalentItemComp);
if (!comp) return;
const total = FieldSkillHelper.getFieldSkillTotalValue(cfg.type);
comp.updateItem(cfg, total);
});
}
/** ECS 组件移除时销毁节点 */