Files
pixelheros/assets/script/game/map/SBox.ts
pan d9bccd7c93 refactor: 将代码中的card_lv统一替换为rarity
本次提交完成了全项目范围内术语的统一替换,将原本指代卡牌品质/等级的card_lv字段全部重命名为rarity,对齐了设计文档中的命名规范,避免了术语混淆:
1.  更新了所有配置文件、组件类、数据结构中的字段定义
2.  同步修改了注释、文档说明中的相关表述
3.  修正了英雄、技能、装备卡牌的品质显示逻辑
4.  调整了背景颜色切换、属性计算等相关业务逻辑
2026-09-02 16:42:54 +08:00

54 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { instantiate, Prefab, Vec3, Node } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { smc } from "../common/SingletonModuleComp";
import { SkillBoxComp } from "./SkillBoxComp";
import { SkillOverrides } from "../common/config/SkillSet";
/** SBox 实体:负责技能卡效果节点创建、初始化与销毁流程 */
@ecs.register(`SBox`)
export class SBox extends ecs.Entity {
/** 技能盒子视图和逻辑组件引用 */
SkillBox!: SkillBoxComp;
protected init() {
// 如果有纯逻辑数据组件可以在这里 addComponents
}
/** 销毁实体并释放视图节点,防止残留 */
destroy(): void {
const view = this.get(SkillBoxComp);
if (view && view.node && view.node.isValid) {
view.node.destroy();
}
this.remove(SkillBoxComp);
super.destroy();
}
/**
* 加载并初始化技能盒子
* 1) 创建节点并挂到 SKILL 层
* 2) 初始化表现与属性数据
*/
load(uuid: number, rarity: number, pos: Vec3, prefab: Prefab, overrides?: SkillOverrides): Node {
let node = instantiate(prefab);
let scene = smc.map.MapView.scene;
// 统一挂到实体显示层 SKILL 节点下
let parent = scene.entityLayer!.node!.getChildByName("SKILL");
if (parent) {
node.parent = parent;
}
node.setPosition(pos);
// 获取并注册组件
let sboxComp = node.getComponent(SkillBoxComp) || node.addComponent(SkillBoxComp);
this.add(sboxComp);
// 初始化业务逻辑(透传药水卡 overrides,含 buff_value)
sboxComp.init(uuid, rarity, overrides);
return node;
}
}