| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { Vec3, Node } from "cc";
- import { ViewUtil } from "../../../../extensions/oops-plugin-framework/assets/core/utils/ViewUtil";
- import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
- import { GridModelComp } from "./model/GridModelComp";
- import { GridViewComp } from "./view/GridViewComp";
- /**
- * 棋盘格实体
- */
- @ecs.register('Grid')
- export class Grid extends ecs.Entity {
- GridModel!: GridModelComp;
- GridView!: GridViewComp;
- protected init() {
- // 添加关卡数据组件
- this.addComponents<ecs.Comp>(GridModelComp);
- }
- destroy(): void {
- // 如果该组件对象是由ecs系统外部创建的,则不可回收,需要用户自己手动进行回收。
- this.remove(GridViewComp);
- super.destroy();
- }
- /** 加载关卡显示对象(cc.Component在创建后,添加到ECS框架中,使实体上任何一个ECS组件都可以通过 ECS API 获取到视图层对象 */
- load(parent: Node, pos: Vec3 = Vec3.ZERO) {
- var node = ViewUtil.createPrefabNode("game/prefab/grid");
- var mv = node.getComponent(GridViewComp)!;
- this.add(mv);
- node.parent = parent;
- node.setPosition(pos);
- }
- }
- export class EcsGridSystem extends ecs.System {
- constructor() {
- super();
- }
- }
|