Station.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. protected init() {
  13. // 添加关卡数据组件
  14. this.addComponents<ecs.Comp>(StationModelComp);
  15. }
  16. destroy(): void {
  17. // 如果该组件对象是由ecs系统外部创建的,则不可回收,需要用户自己手动进行回收。
  18. this.remove(StationViewComp);
  19. super.destroy();
  20. }
  21. /** 加载关卡显示对象(cc.Component在创建后,添加到ECS框架中,使实体上任何一个ECS组件都可以通过 ECS API 获取到视图层对象 */
  22. load(parent: Node, pos: Vec3 = Vec3.ZERO) {
  23. var node = ViewUtil.createPrefabNode("game/prefab/station");
  24. var mv = node.getComponent(StationViewComp)!;
  25. this.add(mv);
  26. node.parent = parent;
  27. node.setPosition(pos);
  28. }
  29. }
  30. export class EcsStationSystem extends ecs.System {
  31. constructor() {
  32. super();
  33. }
  34. }