CheckpointModel.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. VM.remove("Checkpoint");
  65. }
  66. reset() {
  67. this.grids = []
  68. this.path_grid = []
  69. this.cells = []
  70. this.stations = []
  71. this.vehicles = []
  72. this.vmRemove();
  73. }
  74. }