CheckpointModel.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { Vec3 } from "cc";
  2. import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  3. import { ECSEntity } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECSEntity";
  4. import { VM } from "../../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
  5. import { Grid } from "../../grid/Grid";
  6. import { Obstacle } from "../../obstacle/Obstacle";
  7. import { Puppet } from "../../puppet/puppet";
  8. import { Station } from "../../station/Station";
  9. import { Vehicle } from "../../vehicle/Vehicle";
  10. type Cell = Puppet | Obstacle
  11. export interface MapInfo {
  12. x: number,
  13. y: number,
  14. fill?: string | number
  15. pos: Vec3
  16. }
  17. @ecs.register('CheckpointModel')
  18. export class CheckpointModelComp extends ecs.Comp {
  19. private vm: any = {};
  20. private _grid: Grid[][] = []
  21. private _path_grid: MapInfo[][] = []
  22. private _cells: Cell[][] = []
  23. private _station: Station[] = []
  24. private _vehicles: Vehicle[] = []
  25. /** 格子 */
  26. get grids(): Grid[][] {
  27. return this._grid;
  28. }
  29. set grids(value: Grid[][]) {
  30. this._grid = value;
  31. }
  32. /** 寻路数据 */
  33. get path_grid(): MapInfo[][] {
  34. return this._path_grid;
  35. }
  36. set path_grid(value: MapInfo[][]) {
  37. this._path_grid = value;
  38. }
  39. /** 站台 */
  40. get stations(): Station[] {
  41. return this._station;
  42. }
  43. set stations(value: Station[]) {
  44. this._station = value;
  45. }
  46. /** 车辆 */
  47. get vehicles(): Vehicle[] {
  48. return this._vehicles;
  49. }
  50. set vehicles(value: Vehicle[]) {
  51. this._vehicles = value;
  52. }
  53. /** 棋盘格中物体 */
  54. get cells(): Cell[][] {
  55. return this._cells;
  56. }
  57. set cells(value: Cell[][]) {
  58. this._cells = value;
  59. }
  60. vmAdd() {
  61. VM.add(this.vm, "Checkpoint");
  62. }
  63. vmRemove() {
  64. this.vm.reset();
  65. VM.remove("Checkpoint");
  66. }
  67. reset() {
  68. this.vmRemove();
  69. }
  70. }