global.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. export default {
  2. _caller: null, // 调用方指针
  3. // *** 非指针复制 ***
  4. storePlayers: [{
  5. id: 0, // 玩家ID
  6. marker: null, // 玩家标识
  7. trail: null, // 玩家轨迹
  8. trailData: [], // 玩家轨迹信息(数据会追加并定时清理过期数据)
  9. interval_creatCircleMarker: null,
  10. interval_showTrail: null,
  11. }],
  12. map: null,
  13. map_layer: null,
  14. players: [], // 玩家信息(指针复制 每次grpc获取数据后之前旧数据会丢弃)
  15. players_position: [], // 玩家当前位置信息(指针复制 每次grpc获取数据后之前旧数据会丢弃)
  16. focusPlayerId: 0, // 当前选中的玩家ID
  17. checkPoints: [], // 检查点列表(指针复制 每次grpc获取数据后之前旧数据会丢弃)
  18. routes: [], // 路线列表(指针复制 每次grpc获取数据后之前旧数据会丢弃)
  19. setCaller(data) {
  20. this._caller = data // 指针复制,是同一个对象
  21. },
  22. setPlayers(data) {
  23. this.players = data // 指针复制,是同一个对象
  24. },
  25. setPlayersPosition(data) {
  26. this.players_position = data // 指针复制,是同一个对象
  27. },
  28. // *** 非指针复制 ***
  29. // storePlayersTrail(data) {
  30. // this.storePlayers.trail.push(data)
  31. // },
  32. setCheckPoints(data) {
  33. this.checkPoints = data // 指针复制,是同一个对象
  34. },
  35. setRoutes(data) {
  36. this.routes = data // 指针复制,是同一个对象
  37. },
  38. getPlayerById(playerId) {
  39. if (!(playerId > 0)) return
  40. var player = null
  41. if (this.players != null && this.players.length > 0) {
  42. player = this.players.find(o => o.id === playerId)
  43. }
  44. // console.log("[getPlayerById]", playerId, player)
  45. return player
  46. },
  47. getPlayerPositionById(playerId) {
  48. if (!(playerId > 0)) return
  49. var player_position = null
  50. if (this.players_position != null && this.players_position.length > 0) {
  51. player_position = this.players_position.find(o => o.id === playerId)
  52. }
  53. // console.log("[getPlayerPositionById]", playerId, player_position)
  54. return player_position
  55. },
  56. getStorePlayersById(playerId) {
  57. if (!(playerId > 0)) return
  58. var storePlayer = null
  59. if (this.storePlayers != null && this.storePlayers.length > 0) {
  60. storePlayer = this.storePlayers.find(o => o.id === playerId)
  61. }
  62. // console.log("[getStorePlayersById]", playerId, storePlayer)
  63. return storePlayer
  64. },
  65. getCheckPointById(cpId) {
  66. if (!(cpId > 0)) return
  67. var checkPoint = null
  68. if (this.checkPoints != null && this.checkPoints.length > 0) {
  69. checkPoint = this.checkPoints.find(o => o.cp_id === cpId)
  70. }
  71. // console.log("[getCheckPointById]", cpId, checkPoint)
  72. return checkPoint
  73. },
  74. getRouteById(rtId) {
  75. if (!(rtId > 0)) return
  76. var route = null
  77. if (this.routes != null && this.routes.length > 0) {
  78. route = this.routes.find(o => o.id === rtId)
  79. }
  80. // console.log("[getCheckPointById]", rtId, route)
  81. return route
  82. },
  83. }