31 lines
978 B
TypeScript
31 lines
978 B
TypeScript
import { instantiate, Prefab } from "cc";
|
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { GoodsComp } from "./GoodsComp";
|
|
|
|
/** Goods 模块 */
|
|
@ecs.register(`Goods`)
|
|
export class Goods extends ecs.Entity {
|
|
|
|
/** 实始添加的数据层组件 */
|
|
protected init() {
|
|
// this.addComponents<ecs.Comp>();
|
|
}
|
|
|
|
load(smc_index:number,praent:any){
|
|
var path = "game/gui/goods";
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
node.parent = praent
|
|
let gc = node.getComponent(GoodsComp)!;
|
|
gc.smc_index = smc_index
|
|
gc.update_data()
|
|
this.add(gc)
|
|
}
|
|
/** 模块资源释放 */
|
|
destroy() {
|
|
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
|
super.destroy();
|
|
}
|
|
}
|