Station.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Vec3, Node } from "cc";
  2. import { ViewUtil } from "../../../../extensions/oops-plugin-framework/assets/core/utils/ViewUtil";
  3. import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  4. import { StationModelComp } from "./model/StationModel";
  5. import { StationViewComp } from "./view/StationViewComp";
  6. /**
  7. * 站台实体
  8. */
  9. @ecs.register('Station')
  10. export class Station extends ecs.Entity {
  11. StationModel!: StationModelComp;
  12. StationView!: StationViewComp;
  13. protected init() {
  14. // 添加关卡数据组件
  15. this.addComponents<ecs.Comp>(StationModelComp);
  16. }
  17. destroy(): void {
  18. // 如果该组件对象是由ecs系统外部创建的,则不可回收,需要用户自己手动进行回收。
  19. this.remove(StationViewComp);
  20. super.destroy();
  21. }
  22. /** 加载关卡显示对象(cc.Component在创建后,添加到ECS框架中,使实体上任何一个ECS组件都可以通过 ECS API 获取到视图层对象 */
  23. load(parent: Node, pos: Vec3 = Vec3.ZERO) {
  24. var node = ViewUtil.createPrefabNode("game/prefab/station");
  25. var mv = node.getComponent(StationViewComp)!;
  26. this.add(mv);
  27. node.parent = parent;
  28. node.setPosition(pos);
  29. }
  30. }
  31. export class EcsStationSystem extends ecs.System {
  32. constructor() {
  33. super();
  34. }
  35. }