@open-core/framework 1.0.5-beta.2 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +2 -8
  2. package/dist/adapters/contracts/IEngineEvents.d.ts +3 -3
  3. package/dist/adapters/contracts/IExports.d.ts +2 -2
  4. package/dist/adapters/contracts/client/IClientLocalPlayerBridge.d.ts +21 -0
  5. package/dist/adapters/contracts/client/IClientLocalPlayerBridge.js +6 -0
  6. package/dist/adapters/contracts/client/IClientRuntimeBridge.d.ts +5 -5
  7. package/dist/adapters/contracts/client/camera/IClientCameraPort.d.ts +107 -0
  8. package/dist/adapters/contracts/client/camera/IClientCameraPort.js +8 -0
  9. package/dist/adapters/contracts/client/camera/index.d.ts +1 -0
  10. package/dist/adapters/contracts/client/camera/index.js +1 -0
  11. package/dist/adapters/contracts/client/index.d.ts +4 -0
  12. package/dist/adapters/contracts/client/index.js +4 -0
  13. package/dist/adapters/contracts/client/ped/IClientPedPort.d.ts +62 -0
  14. package/dist/adapters/contracts/client/ped/IClientPedPort.js +5 -0
  15. package/dist/adapters/contracts/client/ped/index.d.ts +1 -0
  16. package/dist/adapters/contracts/client/ped/index.js +1 -0
  17. package/dist/adapters/contracts/client/progress/IClientProgressPort.d.ts +53 -0
  18. package/dist/adapters/contracts/client/progress/IClientProgressPort.js +8 -0
  19. package/dist/adapters/contracts/client/progress/index.d.ts +1 -0
  20. package/dist/adapters/contracts/client/progress/index.js +1 -0
  21. package/dist/adapters/contracts/client/spawn/IClientSpawnBridge.d.ts +5 -6
  22. package/dist/adapters/contracts/client/spawn/IClientSpawnBridge.js +5 -1
  23. package/dist/adapters/contracts/client/spawn/IClientSpawnPort.d.ts +19 -0
  24. package/dist/adapters/contracts/client/spawn/IClientSpawnPort.js +2 -0
  25. package/dist/adapters/contracts/client/spawn/index.d.ts +2 -0
  26. package/dist/adapters/contracts/client/spawn/index.js +2 -0
  27. package/dist/adapters/contracts/client/spawn/types.d.ts +3 -0
  28. package/dist/adapters/contracts/client/ui/webview/IClientWebViewBridge.d.ts +1 -0
  29. package/dist/adapters/contracts/client/ui/webview/types.d.ts +2 -0
  30. package/dist/adapters/contracts/client/vehicle/IClientVehiclePort.d.ts +166 -0
  31. package/dist/adapters/contracts/client/vehicle/IClientVehiclePort.js +8 -0
  32. package/dist/adapters/contracts/client/vehicle/index.d.ts +1 -0
  33. package/dist/adapters/contracts/client/vehicle/index.js +1 -0
  34. package/dist/adapters/contracts/transport/events.api.d.ts +3 -3
  35. package/dist/adapters/contracts/transport/index.d.ts +1 -0
  36. package/dist/adapters/contracts/transport/index.js +1 -0
  37. package/dist/adapters/contracts/transport/rpc-error.d.ts +17 -0
  38. package/dist/adapters/contracts/transport/rpc-error.js +28 -0
  39. package/dist/adapters/contracts/transport/rpc.api.d.ts +3 -3
  40. package/dist/adapters/node/transport/node.events.d.ts +4 -4
  41. package/dist/adapters/node/transport/node.rpc.d.ts +3 -3
  42. package/dist/adapters/node/transport/node.rpc.js +1 -1
  43. package/dist/contracts.d.ts +1 -0
  44. package/dist/contracts.js +1 -0
  45. package/dist/index.d.ts +1 -0
  46. package/dist/index.js +1 -0
  47. package/dist/kernel/logger/client-log-console.js +8 -8
  48. package/dist/kernel/logger/index.d.ts +1 -1
  49. package/dist/kernel/logger/index.js +1 -1
  50. package/dist/kernel/logger/logger.types.d.ts +1 -0
  51. package/dist/kernel/logger/logger.types.js +35 -0
  52. package/dist/kernel/logger/transports/buffered.transport.js +4 -4
  53. package/dist/kernel/logger/transports/console.transport.js +2 -2
  54. package/dist/kernel/logger/transports/simple-console.transport.js +2 -2
  55. package/dist/runtime/client/adapter/index.d.ts +5 -0
  56. package/dist/runtime/client/adapter/index.js +5 -0
  57. package/dist/runtime/client/adapter/node-camera-port.d.ts +19 -0
  58. package/dist/runtime/client/adapter/node-camera-port.js +31 -0
  59. package/dist/runtime/client/adapter/node-client-adapter.js +15 -1
  60. package/dist/runtime/client/adapter/node-local-player-bridge.d.ts +3 -0
  61. package/dist/runtime/client/adapter/node-local-player-bridge.js +9 -0
  62. package/dist/runtime/client/adapter/node-log-console.js +8 -8
  63. package/dist/runtime/client/adapter/node-ped-port.d.ts +20 -0
  64. package/dist/runtime/client/adapter/node-ped-port.js +38 -0
  65. package/dist/runtime/client/adapter/node-progress-port.d.ts +8 -0
  66. package/dist/runtime/client/adapter/node-progress-port.js +27 -0
  67. package/dist/runtime/client/adapter/node-runtime-bridge.d.ts +2 -4
  68. package/dist/runtime/client/adapter/node-spawn-bridge.d.ts +5 -5
  69. package/dist/runtime/client/adapter/node-spawn-bridge.js +8 -4
  70. package/dist/runtime/client/adapter/node-vehicle-port.d.ts +31 -0
  71. package/dist/runtime/client/adapter/node-vehicle-port.js +73 -0
  72. package/dist/runtime/client/adapter/node-webview-bridge.d.ts +1 -0
  73. package/dist/runtime/client/adapter/node-webview-bridge.js +2 -0
  74. package/dist/runtime/client/controllers/appearance.controller.d.ts +3 -3
  75. package/dist/runtime/client/controllers/appearance.controller.js +11 -10
  76. package/dist/runtime/client/controllers/spawner.controller.js +4 -3
  77. package/dist/runtime/client/services/camera.d.ts +4 -26
  78. package/dist/runtime/client/services/camera.js +21 -27
  79. package/dist/runtime/client/services/notification.service.d.ts +3 -3
  80. package/dist/runtime/client/services/notification.service.js +7 -7
  81. package/dist/runtime/client/services/ped.service.d.ts +6 -21
  82. package/dist/runtime/client/services/ped.service.js +31 -78
  83. package/dist/runtime/client/services/progress.service.d.ts +4 -50
  84. package/dist/runtime/client/services/progress.service.js +11 -143
  85. package/dist/runtime/client/services/session-bridge.service.js +3 -2
  86. package/dist/runtime/client/services/spawn.service.d.ts +3 -5
  87. package/dist/runtime/client/services/spawn.service.js +12 -17
  88. package/dist/runtime/client/services/vehicle-client.service.d.ts +3 -3
  89. package/dist/runtime/client/services/vehicle-client.service.js +43 -143
  90. package/dist/runtime/client/services/vehicle.service.d.ts +4 -41
  91. package/dist/runtime/client/services/vehicle.service.js +24 -130
  92. package/dist/runtime/client/webview-bridge.d.ts +3 -0
  93. package/dist/runtime/client/webview-bridge.js +6 -0
  94. package/dist/runtime/client/webview.service.d.ts +1 -0
  95. package/dist/runtime/client/webview.service.js +5 -0
  96. package/dist/runtime/server/adapter/node-player-appearance-lifecycle-server.js +3 -2
  97. package/dist/runtime/server/adapter/node-player-lifecycle-server.js +4 -3
  98. package/dist/runtime/server/adapter/node-vehicle-lifecycle-server.js +2 -1
  99. package/dist/runtime/server/apis/chat.api.js +6 -5
  100. package/dist/runtime/server/apis/npcs.api.js +2 -1
  101. package/dist/runtime/server/apis/parallel-compute.api.js +1 -0
  102. package/dist/runtime/server/apis/vehicle-modification.api.js +6 -4
  103. package/dist/runtime/server/apis/vehicles.api.js +7 -4
  104. package/dist/runtime/server/bootstrap.js +13 -12
  105. package/dist/runtime/server/controllers/command-export.controller.js +4 -2
  106. package/dist/runtime/server/controllers/remote-command-execution.controller.js +2 -1
  107. package/dist/runtime/server/controllers/vehicle.controller.js +6 -5
  108. package/dist/runtime/server/decorators/command.d.ts +2 -0
  109. package/dist/runtime/server/decorators/command.js +3 -1
  110. package/dist/runtime/server/entities/npc.d.ts +1 -1
  111. package/dist/runtime/server/entities/player.d.ts +1 -1
  112. package/dist/runtime/server/entities/player.js +10 -3
  113. package/dist/runtime/server/helpers/command-validation.helper.js +20 -7
  114. package/dist/runtime/server/helpers/function-helper.d.ts +1 -0
  115. package/dist/runtime/server/helpers/function-helper.js +15 -8
  116. package/dist/runtime/server/implementations/local/channel.local.d.ts +1 -1
  117. package/dist/runtime/server/implementations/local/channel.local.js +3 -2
  118. package/dist/runtime/server/ports/channel.api-port.d.ts +1 -1
  119. package/dist/runtime/server/services/parallel/worker-pool.d.ts +1 -1
  120. package/dist/runtime/server/services/parallel/worker-pool.js +38 -6
  121. package/dist/runtime/server/services/parallel/worker.js +1 -0
  122. package/dist/runtime/server/system/processors/onRpc.processor.js +14 -3
  123. package/dist/runtime/server/system/schema-generator.d.ts +1 -1
  124. package/dist/runtime/server/system/schema-generator.js +6 -3
  125. package/dist/runtime/shared/helpers/process-tuple-schema.js +3 -0
  126. package/dist/runtime/shared/types/system-types.d.ts +55 -0
  127. package/dist/runtime/shared/types/system-types.js +54 -0
  128. package/package.json +21 -11
@@ -11,18 +11,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
13
  import { inject, injectable } from 'tsyringe';
14
- import { IClientPlatformBridge } from '../adapter/platform-bridge';
14
+ import { IClientCameraPort, } from '../../../adapters/contracts/client/camera/IClientCameraPort';
15
15
  let Camera = class Camera {
16
- platform;
16
+ cameras;
17
17
  activeCam = null;
18
18
  rendering = false;
19
- constructor(platform) {
20
- this.platform = platform;
19
+ constructor(cameras) {
20
+ this.cameras = cameras;
21
21
  }
22
22
  create(options = {}) {
23
- const cam = this.platform.createCam(options.camName ?? 'DEFAULT_SCRIPTED_CAMERA', options.active ?? false);
24
- if (options.transform)
25
- this.setTransform(cam, options.transform);
23
+ const cam = this.cameras.create(options);
26
24
  if (options.active)
27
25
  this.activeCam = cam;
28
26
  return cam;
@@ -31,62 +29,58 @@ let Camera = class Camera {
31
29
  return this.activeCam;
32
30
  }
33
31
  setActive(cam, active) {
34
- this.platform.setCamActive(cam, active);
32
+ this.cameras.setActive(cam, active);
35
33
  if (active)
36
34
  this.activeCam = cam;
37
35
  else if (this.activeCam === cam)
38
36
  this.activeCam = null;
39
37
  }
40
38
  render(enable, options = {}) {
41
- this.platform.renderScriptCams(enable, options.ease ?? false, options.easeTimeMs ?? 0, true, true);
39
+ this.cameras.render(enable, options);
42
40
  this.rendering = enable;
43
41
  }
44
42
  isRendering() {
45
43
  return this.rendering;
46
44
  }
47
45
  destroy(cam, destroyActiveCam = false) {
48
- this.platform.destroyCam(cam, destroyActiveCam);
46
+ this.cameras.destroy(cam, destroyActiveCam);
49
47
  if (this.activeCam === cam)
50
48
  this.activeCam = null;
51
49
  }
52
50
  destroyAll(destroyActiveCam = false) {
53
- this.platform.destroyAllCams(destroyActiveCam);
51
+ this.cameras.destroyAll(destroyActiveCam);
54
52
  this.activeCam = null;
55
53
  }
56
54
  setPosition(cam, position) {
57
- this.platform.setCamCoord(cam, position);
55
+ this.cameras.setPosition(cam, position);
58
56
  }
59
57
  setRotation(cam, rotation, rotationOrder = 2) {
60
- this.platform.setCamRot(cam, rotation, rotationOrder);
58
+ this.cameras.setRotation(cam, rotation, rotationOrder);
61
59
  }
62
60
  setFov(cam, fov) {
63
- this.platform.setCamFov(cam, fov);
61
+ this.cameras.setFov(cam, fov);
64
62
  }
65
63
  setTransform(cam, transform) {
66
- this.setPosition(cam, transform.position);
67
- if (transform.rotation)
68
- this.setRotation(cam, transform.rotation);
69
- if (typeof transform.fov === 'number')
70
- this.setFov(cam, transform.fov);
64
+ this.cameras.setTransform(cam, transform);
71
65
  }
72
66
  pointAtCoords(cam, position) {
73
- this.platform.pointCamAtCoord(cam, position);
67
+ this.cameras.pointAtCoords(cam, position);
74
68
  }
75
69
  pointAtEntity(cam, entity, offset = { x: 0, y: 0, z: 0 }) {
76
- this.platform.pointCamAtEntity(cam, entity, offset);
70
+ this.cameras.pointAtEntity(cam, entity, offset);
77
71
  }
78
72
  stopPointing(cam) {
79
- this.platform.stopCamPointing(cam);
73
+ this.cameras.stopPointing(cam);
80
74
  }
81
75
  interpolate(fromCam, toCam, durationMs, easeLocation = true, easeRotation = true) {
82
- this.platform.setCamActiveWithInterp(toCam, fromCam, durationMs, easeLocation ? 1 : 0, easeRotation ? 1 : 0);
76
+ this.cameras.interpolate(fromCam, toCam, durationMs, easeLocation, easeRotation);
83
77
  this.activeCam = toCam;
84
78
  }
85
79
  shake(cam, options) {
86
- this.platform.shakeCam(cam, options.type, options.amplitude);
80
+ this.cameras.shake(cam, options);
87
81
  }
88
82
  stopShaking(cam, stopImmediately = true) {
89
- this.platform.stopCamShaking(cam, stopImmediately);
83
+ this.cameras.stopShaking(cam, stopImmediately);
90
84
  }
91
85
  reset(options = {}) {
92
86
  if (this.rendering)
@@ -96,7 +90,7 @@ let Camera = class Camera {
96
90
  };
97
91
  Camera = __decorate([
98
92
  injectable(),
99
- __param(0, inject(IClientPlatformBridge)),
100
- __metadata("design:paramtypes", [IClientPlatformBridge])
93
+ __param(0, inject(IClientCameraPort)),
94
+ __metadata("design:paramtypes", [IClientCameraPort])
101
95
  ], Camera);
102
96
  export { Camera };
@@ -1,5 +1,5 @@
1
1
  import { IClientNotificationBridge, type ClientNotificationDefinition } from '../../../adapters/contracts/client/ui/IClientNotificationBridge';
2
- import { IClientPlatformBridge } from '../adapter/platform-bridge';
2
+ import { IClientLocalPlayerBridge } from '../adapter/local-player-bridge';
3
3
  export type NotificationType = 'info' | 'success' | 'warning' | 'error';
4
4
  export interface AdvancedNotificationOptions {
5
5
  title: string;
@@ -11,8 +11,8 @@ export interface AdvancedNotificationOptions {
11
11
  }
12
12
  export declare class NotificationService {
13
13
  private readonly notifications;
14
- private readonly platform;
15
- constructor(notifications: IClientNotificationBridge, platform: IClientPlatformBridge);
14
+ private readonly localPlayer;
15
+ constructor(notifications: IClientNotificationBridge, localPlayer: IClientLocalPlayerBridge);
16
16
  show(message: string, blink?: boolean): void;
17
17
  showWithType(message: string, type?: NotificationType): void;
18
18
  showAdvanced(options: AdvancedNotificationOptions): void;
@@ -12,13 +12,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  };
13
13
  import { inject, injectable } from 'tsyringe';
14
14
  import { IClientNotificationBridge, } from '../../../adapters/contracts/client/ui/IClientNotificationBridge';
15
- import { IClientPlatformBridge } from '../adapter/platform-bridge';
15
+ import { IClientLocalPlayerBridge } from '../adapter/local-player-bridge';
16
16
  let NotificationService = class NotificationService {
17
17
  notifications;
18
- platform;
19
- constructor(notifications, platform) {
18
+ localPlayer;
19
+ constructor(notifications, localPlayer) {
20
20
  this.notifications = notifications;
21
- this.platform = platform;
21
+ this.localPlayer = localPlayer;
22
22
  }
23
23
  show(message, blink = false) {
24
24
  this.notifications.show({ kind: 'feed', message, blink, saveToBrief: true });
@@ -53,7 +53,7 @@ let NotificationService = class NotificationService {
53
53
  this.notifications.show({
54
54
  kind: 'floating',
55
55
  message,
56
- worldPosition: this.platform.getEntityCoords(this.platform.getLocalPlayerPed()),
56
+ worldPosition: this.localPlayer.getPosition(),
57
57
  });
58
58
  }
59
59
  showRaw(definition) {
@@ -63,8 +63,8 @@ let NotificationService = class NotificationService {
63
63
  NotificationService = __decorate([
64
64
  injectable(),
65
65
  __param(0, inject(IClientNotificationBridge)),
66
- __param(1, inject(IClientPlatformBridge)),
66
+ __param(1, inject(IClientLocalPlayerBridge)),
67
67
  __metadata("design:paramtypes", [IClientNotificationBridge,
68
- IClientPlatformBridge])
68
+ IClientLocalPlayerBridge])
69
69
  ], NotificationService);
70
70
  export { NotificationService };
@@ -1,23 +1,7 @@
1
1
  import { Vector3 } from '../../../kernel/utils/vector3';
2
- import { IClientPlatformBridge } from '../adapter/platform-bridge';
3
- export interface PedSpawnOptions {
4
- model: string;
5
- position: Vector3;
6
- heading?: number;
7
- networked?: boolean;
8
- missionEntity?: boolean;
9
- relationshipGroup?: string;
10
- blockEvents?: boolean;
11
- }
12
- export interface PedAnimationOptions {
13
- dict: string;
14
- anim: string;
15
- blendInSpeed?: number;
16
- blendOutSpeed?: number;
17
- duration?: number;
18
- flags?: number;
19
- playbackRate?: number;
20
- }
2
+ import { type ClientPedAnimationOptions as PedAnimationOptions, type ClientPedSpawnOptions as PedSpawnOptions, IClientPedPort } from '../../../adapters/contracts/client/ped/IClientPedPort';
3
+ import { IClientLocalPlayerBridge } from '../adapter/local-player-bridge';
4
+ export type { PedSpawnOptions, PedAnimationOptions };
21
5
  export interface ManagedPed {
22
6
  id: string;
23
7
  handle: number;
@@ -25,10 +9,11 @@ export interface ManagedPed {
25
9
  position: Vector3;
26
10
  }
27
11
  export declare class PedService {
28
- private readonly platform;
12
+ private readonly pedsPort;
13
+ private readonly localPlayer;
29
14
  private peds;
30
15
  private idCounter;
31
- constructor(platform: IClientPlatformBridge);
16
+ constructor(pedsPort: IClientPedPort, localPlayer: IClientLocalPlayerBridge);
32
17
  spawn(options: PedSpawnOptions): Promise<{
33
18
  id: string;
34
19
  handle: number;
@@ -11,53 +11,35 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
13
  import { inject, injectable } from 'tsyringe';
14
- import { IClientPlatformBridge } from '../adapter/platform-bridge';
14
+ import { IClientPedPort, } from '../../../adapters/contracts/client/ped/IClientPedPort';
15
+ import { IClientLocalPlayerBridge } from '../adapter/local-player-bridge';
15
16
  let PedService = class PedService {
16
- platform;
17
+ pedsPort;
18
+ localPlayer;
17
19
  peds = new Map();
18
20
  idCounter = 0;
19
- constructor(platform) {
20
- this.platform = platform;
21
+ constructor(pedsPort, localPlayer) {
22
+ this.pedsPort = pedsPort;
23
+ this.localPlayer = localPlayer;
21
24
  }
22
25
  async spawn(options) {
23
- const { model, position, heading = 0, networked = false, missionEntity = true, blockEvents = true, } = options;
24
- const modelHash = this.platform.getHashKey(model);
25
- if (!this.platform.isModelInCdimage(modelHash) || !this.platform.isModelValid(modelHash)) {
26
- throw new Error(`Invalid ped model: ${model}`);
27
- }
28
- this.platform.requestModel(modelHash);
29
- while (!this.platform.hasModelLoaded(modelHash)) {
30
- await new Promise((r) => setTimeout(r, 0));
31
- }
32
- const ped = this.platform.createPed(4, modelHash, position, heading, networked, true);
33
- this.platform.setModelAsNoLongerNeeded(modelHash);
26
+ const ped = await this.pedsPort.spawn(options);
34
27
  if (!ped || ped === 0)
35
28
  throw new Error('Failed to create ped');
36
- if (missionEntity)
37
- this.platform.setEntityAsMissionEntity(ped, true, true);
38
- if (blockEvents)
39
- this.platform.setBlockingOfNonTemporaryEvents(ped, true);
40
- this.platform.setPedRelationshipGroupHash(ped, this.platform.getHashKey('CIVMALE'));
41
29
  const id = `ped_${++this.idCounter}`;
42
- this.peds.set(id, { id, handle: ped, model, position });
30
+ this.peds.set(id, { id, handle: ped, model: options.model, position: options.position });
43
31
  return { id, handle: ped };
44
32
  }
45
33
  delete(id) {
46
34
  const ped = this.peds.get(id);
47
35
  if (!ped)
48
36
  return false;
49
- if (this.platform.doesEntityExist(ped.handle)) {
50
- this.platform.setEntityAsMissionEntity(ped.handle, true, true);
51
- this.platform.deletePed(ped.handle);
52
- }
37
+ this.pedsPort.delete(ped.handle);
53
38
  this.peds.delete(id);
54
39
  return true;
55
40
  }
56
41
  deleteByHandle(handle) {
57
- if (this.platform.doesEntityExist(handle)) {
58
- this.platform.setEntityAsMissionEntity(handle, true, true);
59
- this.platform.deletePed(handle);
60
- }
42
+ this.pedsPort.delete(handle);
61
43
  for (const [id, ped] of this.peds) {
62
44
  if (ped.handle === handle) {
63
45
  this.peds.delete(id);
@@ -67,56 +49,34 @@ let PedService = class PedService {
67
49
  }
68
50
  deleteAll() {
69
51
  for (const ped of this.peds.values()) {
70
- if (this.platform.doesEntityExist(ped.handle)) {
71
- this.platform.setEntityAsMissionEntity(ped.handle, true, true);
72
- this.platform.deletePed(ped.handle);
73
- }
52
+ this.pedsPort.delete(ped.handle);
74
53
  }
75
54
  this.peds.clear();
76
55
  }
77
56
  async playAnimation(handle, options) {
78
- const { dict, anim, blendInSpeed = 8.0, blendOutSpeed = -8.0, duration = -1, flags = 1, playbackRate = 0.0, } = options;
79
- if (!this.platform.doesEntityExist(handle))
80
- return;
81
- this.platform.requestAnimDict(dict);
82
- while (!this.platform.hasAnimDictLoaded(dict)) {
83
- await new Promise((r) => setTimeout(r, 0));
84
- }
85
- this.platform.taskPlayAnim(handle, dict, anim, blendInSpeed, blendOutSpeed, duration, flags, playbackRate);
57
+ await this.pedsPort.playAnimation(handle, options);
86
58
  }
87
59
  stopAnimation(handle) {
88
- if (!this.platform.doesEntityExist(handle))
89
- return;
90
- this.platform.clearPedTasks(handle);
60
+ this.pedsPort.stopAnimation(handle);
91
61
  }
92
62
  stopAnimationImmediately(handle) {
93
- if (!this.platform.doesEntityExist(handle))
94
- return;
95
- this.platform.clearPedTasksImmediately(handle);
63
+ this.pedsPort.stopAnimationImmediately(handle);
96
64
  }
97
65
  freeze(handle, freeze) {
98
- if (!this.platform.doesEntityExist(handle))
99
- return;
100
- this.platform.freezeEntityPosition(handle, freeze);
66
+ this.pedsPort.freeze(handle, freeze);
101
67
  }
102
68
  setInvincible(handle, invincible) {
103
- if (!this.platform.doesEntityExist(handle))
104
- return;
105
- this.platform.setEntityInvincible(handle, invincible);
69
+ this.pedsPort.setInvincible(handle, invincible);
106
70
  }
107
71
  giveWeapon(handle, weapon, ammo = 100, hidden = false, forceInHand = true) {
108
- if (!this.platform.doesEntityExist(handle))
109
- return;
110
- this.platform.giveWeaponToPed(handle, this.platform.getHashKey(weapon), ammo, hidden, forceInHand);
72
+ this.pedsPort.giveWeapon(handle, weapon, ammo, hidden, forceInHand);
111
73
  }
112
74
  removeAllWeapons(handle) {
113
- if (!this.platform.doesEntityExist(handle))
114
- return;
115
- this.platform.removeAllPedWeapons(handle, true);
75
+ this.pedsPort.removeAllWeapons(handle);
116
76
  }
117
77
  getClosest(radius = 10.0, excludePlayer = true) {
118
- const playerPed = this.platform.getLocalPlayerPed();
119
- const handle = this.platform.getClosestPed(this.platform.getEntityCoords(playerPed), radius);
78
+ const playerPed = this.localPlayer.getHandle();
79
+ const handle = this.pedsPort.getClosest(radius, excludePlayer);
120
80
  if (!handle)
121
81
  return null;
122
82
  if (excludePlayer && handle === playerPed)
@@ -124,28 +84,19 @@ let PedService = class PedService {
124
84
  return handle;
125
85
  }
126
86
  getNearby(position, radius, excludePlayer = true) {
127
- return this.platform.getNearbyPeds(position, radius, excludePlayer ? this.platform.getLocalPlayerPed() : undefined);
87
+ return this.pedsPort.getNearby(position, radius, excludePlayer ? this.localPlayer.getHandle() : undefined);
128
88
  }
129
89
  lookAtEntity(handle, entity, duration = -1) {
130
- if (!this.platform.doesEntityExist(handle))
131
- return;
132
- this.platform.taskLookAtEntity(handle, entity, duration);
90
+ this.pedsPort.lookAtEntity(handle, entity, duration);
133
91
  }
134
92
  lookAtCoords(handle, position, duration = -1) {
135
- if (!this.platform.doesEntityExist(handle))
136
- return;
137
- this.platform.taskLookAtCoord(handle, position, duration);
93
+ this.pedsPort.lookAtCoords(handle, position, duration);
138
94
  }
139
95
  walkTo(handle, position, speed = 1.0) {
140
- if (!this.platform.doesEntityExist(handle))
141
- return;
142
- this.platform.taskGoStraightToCoord(handle, position, speed);
96
+ this.pedsPort.walkTo(handle, position, speed);
143
97
  }
144
98
  setCombatAttributes(handle, canFight, canUseCover = true) {
145
- if (!this.platform.doesEntityExist(handle))
146
- return;
147
- this.platform.setPedCombatAttributes(handle, 46, canFight);
148
- this.platform.setPedCombatAttributes(handle, 0, canUseCover);
99
+ this.pedsPort.setCombatAttributes(handle, canFight, canUseCover);
149
100
  }
150
101
  get(id) {
151
102
  return this.peds.get(id);
@@ -155,12 +106,14 @@ let PedService = class PedService {
155
106
  }
156
107
  exists(id) {
157
108
  const ped = this.peds.get(id);
158
- return ped ? this.platform.doesEntityExist(ped.handle) : false;
109
+ return ped ? this.pedsPort.exists(ped.handle) : false;
159
110
  }
160
111
  };
161
112
  PedService = __decorate([
162
113
  injectable(),
163
- __param(0, inject(IClientPlatformBridge)),
164
- __metadata("design:paramtypes", [IClientPlatformBridge])
114
+ __param(0, inject(IClientPedPort)),
115
+ __param(1, inject(IClientLocalPlayerBridge)),
116
+ __metadata("design:paramtypes", [IClientPedPort,
117
+ IClientLocalPlayerBridge])
165
118
  ], PedService);
166
119
  export { PedService };
@@ -1,57 +1,11 @@
1
- import { IClientPlatformBridge } from '../adapter/platform-bridge';
2
- import { IClientRuntimeBridge } from '../adapter/runtime-bridge';
3
- export interface ProgressOptions {
4
- label: string;
5
- duration: number;
6
- useCircular?: boolean;
7
- canCancel?: boolean;
8
- disableControls?: boolean;
9
- disableMovement?: boolean;
10
- disableCombat?: boolean;
11
- animation?: {
12
- dict: string;
13
- anim: string;
14
- flags?: number;
15
- };
16
- prop?: {
17
- model: string;
18
- bone: number;
19
- offset: {
20
- x: number;
21
- y: number;
22
- z: number;
23
- };
24
- rotation: {
25
- x: number;
26
- y: number;
27
- z: number;
28
- };
29
- };
30
- }
31
- export interface ProgressState {
32
- active: boolean;
33
- progress: number;
34
- label: string;
35
- startTime: number;
36
- duration: number;
37
- options: ProgressOptions;
38
- }
1
+ import { type ClientProgressOptions as ProgressOptions, type ClientProgressState as ProgressState, IClientProgressPort } from '../../../adapters/contracts/client/progress/IClientProgressPort';
2
+ export type { ProgressOptions, ProgressState };
39
3
  export declare class ProgressService {
40
- private readonly platform;
41
- private readonly runtime;
42
- private state;
43
- private tickHandle;
44
- private callback;
45
- private propHandle;
46
- constructor(platform: IClientPlatformBridge, runtime: IClientRuntimeBridge);
4
+ private readonly progressPort;
5
+ constructor(progressPort: IClientProgressPort);
47
6
  start(options: ProgressOptions): Promise<boolean>;
48
7
  cancel(): void;
49
8
  isActive(): boolean;
50
9
  getProgress(): number;
51
10
  getState(): ProgressState | null;
52
- private startProgress;
53
- private drawProgressBar;
54
- private cleanup;
55
- private loadAnimDict;
56
- private loadModel;
57
11
  }
@@ -11,163 +11,31 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
13
  import { inject, injectable } from 'tsyringe';
14
- import { IClientPlatformBridge } from '../adapter/platform-bridge';
15
- import { IClientRuntimeBridge } from '../adapter/runtime-bridge';
14
+ import { IClientProgressPort, } from '../../../adapters/contracts/client/progress/IClientProgressPort';
16
15
  let ProgressService = class ProgressService {
17
- platform;
18
- runtime;
19
- state = null;
20
- tickHandle = null;
21
- callback = null;
22
- propHandle = null;
23
- constructor(platform, runtime) {
24
- this.platform = platform;
25
- this.runtime = runtime;
16
+ progressPort;
17
+ constructor(progressPort) {
18
+ this.progressPort = progressPort;
26
19
  }
27
20
  async start(options) {
28
- if (this.state?.active)
29
- return false;
30
- return new Promise((resolve) => {
31
- this.state = {
32
- active: true,
33
- progress: 0,
34
- label: options.label,
35
- startTime: this.runtime.getGameTimer(),
36
- duration: options.duration,
37
- options,
38
- };
39
- this.callback = resolve;
40
- void this.startProgress();
41
- });
21
+ return this.progressPort.start(options);
42
22
  }
43
23
  cancel() {
44
- if (!this.state?.active)
45
- return;
46
- this.cleanup(false);
24
+ this.progressPort.cancel();
47
25
  }
48
26
  isActive() {
49
- return this.state?.active ?? false;
27
+ return this.progressPort.isActive();
50
28
  }
51
29
  getProgress() {
52
- return this.state?.progress ?? 0;
30
+ return this.progressPort.getProgress();
53
31
  }
54
32
  getState() {
55
- return this.state;
56
- }
57
- async startProgress() {
58
- if (!this.state)
59
- return;
60
- const { options } = this.state;
61
- const ped = this.platform.getLocalPlayerPed();
62
- if (options.animation) {
63
- await this.loadAnimDict(options.animation.dict);
64
- this.platform.taskPlayAnim(ped, options.animation.dict, options.animation.anim, 8.0, -8.0, options.duration, options.animation.flags ?? 1, 0.0);
65
- }
66
- if (options.prop) {
67
- await this.loadModel(options.prop.model);
68
- const propHash = this.platform.getHashKey(options.prop.model);
69
- const coords = this.platform.getEntityCoords(ped);
70
- this.propHandle = this.platform.createObject(propHash, coords, true, true, true);
71
- this.platform.attachEntityToEntity(this.propHandle, ped, this.platform.getPedBoneIndex(ped, options.prop.bone), options.prop.offset, options.prop.rotation);
72
- }
73
- this.tickHandle = this.runtime.setTick(() => {
74
- if (!this.state)
75
- return;
76
- const elapsed = this.runtime.getGameTimer() - this.state.startTime;
77
- this.state.progress = Math.min((elapsed / this.state.duration) * 100, 100);
78
- if (options.disableControls) {
79
- this.platform.disableAllControlActions(0);
80
- }
81
- else {
82
- if (options.disableMovement) {
83
- this.platform.disableControlAction(0, 30, true);
84
- this.platform.disableControlAction(0, 31, true);
85
- this.platform.disableControlAction(0, 21, true);
86
- this.platform.disableControlAction(0, 22, true);
87
- }
88
- if (options.disableCombat) {
89
- this.platform.disableControlAction(0, 24, true);
90
- this.platform.disableControlAction(0, 25, true);
91
- this.platform.disableControlAction(0, 47, true);
92
- this.platform.disableControlAction(0, 58, true);
93
- this.platform.disableControlAction(0, 263, true);
94
- this.platform.disableControlAction(0, 264, true);
95
- }
96
- }
97
- if (options.canCancel && this.platform.isControlJustPressed(0, 200)) {
98
- this.cancel();
99
- return;
100
- }
101
- this.drawProgressBar();
102
- if (elapsed >= this.state.duration)
103
- this.cleanup(true);
104
- });
105
- }
106
- drawProgressBar() {
107
- if (!this.state)
108
- return;
109
- const { label, progress, options } = this.state;
110
- if (options.useCircular) {
111
- this.platform.beginTextCommandBusyspinnerOn('STRING');
112
- this.platform.addTextComponentString(label);
113
- this.platform.endTextCommandBusyspinnerOn(4);
114
- return;
115
- }
116
- const barWidth = 0.15;
117
- const barHeight = 0.015;
118
- const x = 0.5 - barWidth / 2;
119
- const y = 0.88;
120
- this.platform.drawRect(0.5, y + barHeight / 2, barWidth, barHeight, 0, 0, 0, 180);
121
- const fillWidth = (barWidth * progress) / 100;
122
- this.platform.drawRect(x + fillWidth / 2, y + barHeight / 2, fillWidth, barHeight, 255, 255, 255, 255);
123
- this.platform.setTextFont(4);
124
- this.platform.setTextScale(0.35);
125
- this.platform.setTextColour({ r: 255, g: 255, b: 255, a: 255 });
126
- this.platform.setTextCentre(true);
127
- this.platform.beginTextCommandDisplayText('STRING');
128
- this.platform.addTextComponentString(`${label} (${Math.floor(progress)}%)`);
129
- this.platform.endTextCommandDisplayText(0.5, y - 0.03);
130
- }
131
- cleanup(completed) {
132
- const ped = this.platform.getLocalPlayerPed();
133
- if (this.state?.options.animation) {
134
- this.platform.stopAnimTask(ped, this.state.options.animation.dict, this.state.options.animation.anim, 1.0);
135
- }
136
- if (this.propHandle) {
137
- this.platform.deleteEntity(this.propHandle);
138
- this.propHandle = null;
139
- }
140
- if (this.tickHandle !== null) {
141
- this.runtime.clearTick(this.tickHandle);
142
- this.tickHandle = null;
143
- }
144
- if (this.state?.options.useCircular)
145
- this.platform.busyspinnerOff();
146
- this.state = null;
147
- if (this.callback) {
148
- this.callback(completed);
149
- this.callback = null;
150
- }
151
- }
152
- async loadAnimDict(dict) {
153
- this.platform.requestAnimDict(dict);
154
- while (!this.platform.hasAnimDictLoaded(dict)) {
155
- await new Promise((r) => setTimeout(r, 0));
156
- }
157
- }
158
- async loadModel(model) {
159
- const hash = this.platform.getHashKey(model);
160
- this.platform.requestModel(hash);
161
- while (!this.platform.hasModelLoaded(hash)) {
162
- await new Promise((r) => setTimeout(r, 0));
163
- }
33
+ return this.progressPort.getState();
164
34
  }
165
35
  };
166
36
  ProgressService = __decorate([
167
37
  injectable(),
168
- __param(0, inject(IClientPlatformBridge)),
169
- __param(1, inject(IClientRuntimeBridge)),
170
- __metadata("design:paramtypes", [IClientPlatformBridge,
171
- IClientRuntimeBridge])
38
+ __param(0, inject(IClientProgressPort)),
39
+ __metadata("design:paramtypes", [IClientProgressPort])
172
40
  ], ProgressService);
173
41
  export { ProgressService };
@@ -14,6 +14,7 @@ import { inject, injectable } from 'tsyringe';
14
14
  import { EventsAPI } from '../../../adapters/contracts/transport/events.api';
15
15
  import { coreLogger, LogDomain } from '../../../kernel/logger';
16
16
  import { Vec3 } from '../../../kernel/utils/vector3';
17
+ import { SYSTEM_EVENTS } from '../../shared/types/system-types';
17
18
  import { IClientLocalPlayerBridge } from '../adapter/local-player-bridge';
18
19
  import { IClientRuntimeBridge } from '../adapter/runtime-bridge';
19
20
  const clientSession = coreLogger.child('Session', LogDomain.CLIENT);
@@ -37,11 +38,11 @@ let ClientSessionBridgeService = class ClientSessionBridgeService {
37
38
  return;
38
39
  clientSession.debug('Client session bridge initialized');
39
40
  });
40
- this.events.on('core:playerSessionInit', (_ctx, data) => {
41
+ this.events.on(SYSTEM_EVENTS.session.playerInit, (_ctx, data) => {
41
42
  this.playerId = data.playerId;
42
43
  clientSession.info('Player session initialized', { playerId: data.playerId });
43
44
  });
44
- this.events.on('core:teleportTo', (_ctx, x, y, z, heading) => {
45
+ this.events.on(SYSTEM_EVENTS.session.teleportTo, (_ctx, x, y, z, heading) => {
45
46
  this.localPlayer.setPosition(Vec3.create(x, y, z), heading);
46
47
  });
47
48
  }