refactor(map): 重构英雄信息弹窗逻辑,移除oops.gui依赖

1.  将英雄信息弹窗从框架GUI系统改为同步实例化管理
2.  由HeroBoxComp接管弹窗的创建和销毁时机
3.  删除冗余的UIID配置和弹窗参数接口
4.  调整弹窗关闭逻辑,避免缓存节点带来的竞态问题
This commit is contained in:
pan
2026-08-05 18:02:35 +08:00
parent 1d4769b080
commit e2f5b05bc3
5 changed files with 2350 additions and 2653 deletions

View File

@@ -5,9 +5,9 @@
* 职责:
* 1. 展示单个英雄的次级属性(攻速/击晕/暴击/爆伤/冰冻/击退/穿透/风怒)与技能描述,
* 展示内容由原 HeroBoxComp 分离而来,计算口径与其完全一致。
* 2. 由 HeroBoxComp 长按英雄盒时通过 oops.gui.open(UIID.HeroMore, { eid }) 打开oops.gui 模块)
* 2. 由 HeroBoxComp 长按英雄盒时同步实例化instantiate more.prefab并调用 init(eid)
* 3. 属性受 buff/光环影响实时变化,打开期间按固定间隔降频刷新;英雄死亡/被卖出自动关闭。
* 4. 点击弹窗内任意位置(含全屏透明遮罩)关闭
* 4. 点击弹窗内任意位置(含全屏透明遮罩)或 HeroBoxComp 放开手指时由调用方 destroy
*
* 依赖:
* - HeroAttrsComp —— 英雄属性数据模型
@@ -21,12 +21,6 @@ import { buildSkillDescRich } from "../common/config/HeroSkillDesc";
const { ccclass, property } = _decorator;
/** 英雄信息弹窗参数 */
export interface HeroMoreParams {
/** 英雄 ECS 实体 ID */
eid?: number;
}
/**
* HeroMoreCom —— 英雄信息弹窗more.prefab 根节点组件)
*
@@ -105,7 +99,7 @@ export class HeroMoreCom extends Component {
// ======================== 生命周期 ========================
onLoad() {
// 全屏透明遮罩为根节点子节点,点击任意处触摸事件冒泡至此 → 关闭弹窗
// 全屏透明遮罩为根节点子节点,点击任意处触摸事件冒泡至此 → 关闭弹窗(备用交互)
this.node.on(NodeEventType.TOUCH_END, this.onTouchEndClose, this);
}
@@ -116,15 +110,13 @@ export class HeroMoreCom extends Component {
}
/**
* oops.gui 添加到舞台回调(框架约定入口)。
* @param params 见 HeroMoreParamseid 对应实体不存在时立即关闭
* 初始化并渲染英雄信息(由 HeroBoxComp 在 instantiate 后同步调用)。
* @param eid 英雄 ECS 实体 ID实体不存在时立即销毁
*/
onAdded(params: HeroMoreParams = {}) {
this.isClosing = false;
public init(eid: number) {
this.refreshElapsed = 0;
this.skillDescCache = "";
const eid = params?.eid ?? 0;
if (!eid) {
this.closeSelf();
return;
@@ -237,16 +229,18 @@ export class HeroMoreCom extends Component {
// ======================== 交互 ========================
/** 点击面板任意处(含遮罩)关闭 */
/** 点击面板任意处(含遮罩)关闭(备用交互,主路径由 HeroBoxComp 放开手指 destroy */
private onTouchEndClose() {
oops.audio.playEffect("music/button");
this.closeSelf();
}
/** 关闭弹窗(交还 oops.gui 缓存,下次打开复用节点并重新触发 onAdded */
/** 关闭弹窗(同步销毁节点 */
private closeSelf() {
if (this.isClosing) return;
this.isClosing = true;
oops.gui.removeByNode(this.node);
if (this.node && this.node.isValid) {
this.node.destroy();
}
}
}