@armoury/fivem-framework-client 0.0.0-stage → 1.0.8

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 (87) hide show
  1. package/dist/cjs/client/client-action-points.js +179 -0
  2. package/dist/cjs/client/client-entities.js +287 -0
  3. package/dist/cjs/client/client-hud.controller.js +17 -0
  4. package/dist/cjs/client/client-ui.controller.js +91 -0
  5. package/dist/cjs/client/client.base.js +72 -0
  6. package/dist/cjs/client/client.controller.js +28 -0
  7. package/dist/cjs/client/constants/color.mappings.js +91 -0
  8. package/dist/cjs/client/index.js +45 -0
  9. package/dist/cjs/client/interfaces/client-ui.interface.js +2 -0
  10. package/dist/cjs/client/models/action-point.model.js +2 -0
  11. package/dist/cjs/client/models/blip.model.js +2 -0
  12. package/dist/cjs/client/models/index.js +21 -0
  13. package/dist/cjs/client/models/marker.model.js +2 -0
  14. package/dist/cjs/client/models/ui-button.model.js +2 -0
  15. package/dist/cjs/client/models/ui-dialog.model.js +2 -0
  16. package/dist/cjs/client/services/client-action-points.service.js +158 -0
  17. package/dist/cjs/client/services/client-blips.service.js +80 -0
  18. package/dist/cjs/client/services/client-checkpoints.service.js +41 -0
  19. package/dist/cjs/client/services/client-hud.service.js +25 -0
  20. package/dist/cjs/client/services/client-markers.service.js +62 -0
  21. package/dist/cjs/client/services/client-peds.service.js +104 -0
  22. package/dist/cjs/client/services/client-session.service.js +24 -0
  23. package/dist/cjs/client/services/client-ticks.service.js +77 -0
  24. package/dist/cjs/client/services/client-translate.service.js +41 -0
  25. package/dist/cjs/client/services/client-ui.service.js +112 -0
  26. package/dist/cjs/client/services/client-vehicles.service.js +66 -0
  27. package/dist/cjs/client/services/client-waypoints.service.js +72 -0
  28. package/dist/cjs/client/services/index.js +28 -0
  29. package/dist/esm/client/client-action-points.js +176 -0
  30. package/dist/esm/client/client-entities.js +284 -0
  31. package/dist/esm/client/client-hud.controller.js +13 -0
  32. package/dist/esm/client/client-ui.controller.js +84 -0
  33. package/dist/esm/client/client.base.js +68 -0
  34. package/dist/esm/client/client.controller.js +24 -0
  35. package/dist/esm/client/constants/color.mappings.js +88 -0
  36. package/dist/esm/client/index.js +27 -0
  37. package/dist/esm/client/interfaces/client-ui.interface.js +1 -0
  38. package/dist/esm/client/models/action-point.model.js +1 -0
  39. package/dist/esm/client/models/blip.model.js +1 -0
  40. package/dist/esm/client/models/index.js +5 -0
  41. package/dist/esm/client/models/marker.model.js +1 -0
  42. package/dist/esm/client/models/ui-button.model.js +1 -0
  43. package/dist/esm/client/models/ui-dialog.model.js +1 -0
  44. package/dist/esm/client/services/client-action-points.service.js +155 -0
  45. package/dist/esm/client/services/client-blips.service.js +77 -0
  46. package/dist/esm/client/services/client-checkpoints.service.js +38 -0
  47. package/dist/esm/client/services/client-hud.service.js +22 -0
  48. package/dist/esm/client/services/client-markers.service.js +59 -0
  49. package/dist/esm/client/services/client-peds.service.js +101 -0
  50. package/dist/esm/client/services/client-session.service.js +21 -0
  51. package/dist/esm/client/services/client-ticks.service.js +74 -0
  52. package/dist/esm/client/services/client-translate.service.js +38 -0
  53. package/dist/esm/client/services/client-ui.service.js +109 -0
  54. package/dist/esm/client/services/client-vehicles.service.js +63 -0
  55. package/dist/esm/client/services/client-waypoints.service.js +69 -0
  56. package/dist/esm/client/services/index.js +12 -0
  57. package/dist/types/ambient.declarations.d.ts +62840 -0
  58. package/dist/types/client/client-action-points.d.ts +30 -0
  59. package/dist/types/client/client-entities.d.ts +43 -0
  60. package/dist/types/client/client-hud.controller.d.ts +4 -0
  61. package/dist/types/client/client-ui.controller.d.ts +19 -0
  62. package/dist/types/client/client.base.d.ts +22 -0
  63. package/dist/types/client/client.controller.d.ts +12 -0
  64. package/dist/types/client/constants/color.mappings.d.ts +3 -0
  65. package/dist/types/client/index.d.ts +10 -0
  66. package/dist/types/client/interfaces/client-ui.interface.d.ts +4 -0
  67. package/dist/types/client/models/action-point.model.d.ts +10 -0
  68. package/dist/types/client/models/blip.model.d.ts +14 -0
  69. package/dist/types/client/models/index.d.ts +5 -0
  70. package/dist/types/client/models/marker.model.d.ts +22 -0
  71. package/dist/types/client/models/ui-button.model.d.ts +8 -0
  72. package/dist/types/client/models/ui-dialog.model.d.ts +9 -0
  73. package/dist/types/client/services/client-action-points.service.d.ts +29 -0
  74. package/dist/types/client/services/client-blips.service.d.ts +10 -0
  75. package/dist/types/client/services/client-checkpoints.service.d.ts +7 -0
  76. package/dist/types/client/services/client-hud.service.d.ts +3 -0
  77. package/dist/types/client/services/client-markers.service.d.ts +11 -0
  78. package/dist/types/client/services/client-peds.service.d.ts +10 -0
  79. package/dist/types/client/services/client-session.service.d.ts +3 -0
  80. package/dist/types/client/services/client-ticks.service.d.ts +21 -0
  81. package/dist/types/client/services/client-translate.service.d.ts +13 -0
  82. package/dist/types/client/services/client-ui.service.d.ts +19 -0
  83. package/dist/types/client/services/client-vehicles.service.d.ts +8 -0
  84. package/dist/types/client/services/client-waypoints.service.d.ts +13 -0
  85. package/dist/types/client/services/index.d.ts +12 -0
  86. package/package.json +32 -5
  87. package/README.md +0 -3
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ClientSessionService = void 0;
10
+ const injection_js_1 = require("injection-js");
11
+ const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
12
+ let ClientSessionService = class ClientSessionService {
13
+ getPlayerInfo(stat, playerId) {
14
+ let value = Cfx.Client.GetConvar(`${playerId || Cfx.Client.GetPlayerServerId(Cfx.Client.PlayerId())}_PI_${stat}`, '-1');
15
+ if ((0, fivem_framework_common_1.isJSON)(value.toString())) {
16
+ value = JSON.parse(value.toString(), function (_k, v) { return (typeof v === "object" || isNaN(v)) ? v : Number(v); });
17
+ }
18
+ return value;
19
+ }
20
+ };
21
+ exports.ClientSessionService = ClientSessionService;
22
+ exports.ClientSessionService = ClientSessionService = __decorate([
23
+ (0, injection_js_1.Injectable)()
24
+ ], ClientSessionService);
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ClientTicksService = void 0;
13
+ const injection_js_1 = require("injection-js");
14
+ let ClientTicksService = class ClientTicksService {
15
+ constructor() {
16
+ this.tickInstance = null;
17
+ this.tickFunctions = [];
18
+ this.routingBucket = 0;
19
+ this.assignBaseListeners();
20
+ }
21
+ /** ATTENTION! The ID of a tick function needs to be UNIQUE! */
22
+ add(...functions) {
23
+ functions.forEach((func) => {
24
+ if (this.tickFunctions.findIndex((_func) => _func.id === func.id) !== -1) {
25
+ console.error(`[ClientBase]: A tick function with the id ${func.id} already exists in the stack! The newly added tick function will not be executed.`);
26
+ }
27
+ });
28
+ this.tickFunctions.push(...functions);
29
+ this.removeTickDuplicates();
30
+ this.refreshTicks();
31
+ }
32
+ addUnique(...functions) {
33
+ functions.forEach((func) => {
34
+ this.remove(func.id);
35
+ });
36
+ this.add(...functions);
37
+ }
38
+ /** Removes tick function with the provided id. */
39
+ remove(id) {
40
+ this.tickFunctions = this.tickFunctions.filter((func) => func.id != id);
41
+ }
42
+ refreshTicks() {
43
+ if (this.tickInstance) {
44
+ Cfx.Client.clearTick(this.tickInstance);
45
+ this.tickInstance = null;
46
+ }
47
+ if (this.tickFunctions.length > 0) {
48
+ this.tickInstance = Cfx.Client.setTick(() => {
49
+ if (!this.tickFunctions.length) {
50
+ Cfx.Client.clearTick(this.tickInstance);
51
+ this.tickInstance = null;
52
+ return;
53
+ }
54
+ this.tickFunctions.forEach((tick) => {
55
+ tick.function();
56
+ });
57
+ });
58
+ }
59
+ }
60
+ removeTickDuplicates() {
61
+ this.tickFunctions = this.tickFunctions.filter((func) => this.tickFunctions.findIndex((_func) => _func.id == func.id) == this.tickFunctions.indexOf(func));
62
+ }
63
+ assignBaseListeners() {
64
+ Cfx.Client.onNet(`${Cfx.Client.GetCurrentResourceName()}:set-routing-bucket`, (routingBucket) => {
65
+ this.routingBucket = routingBucket;
66
+ });
67
+ }
68
+ setEntityRoutingBucket(routingBucket) {
69
+ Cfx.Client.TriggerServerEvent(`${Cfx.Client.GetCurrentResourceName()}:set-client-routing-bucket`, routingBucket);
70
+ this.routingBucket = routingBucket;
71
+ }
72
+ };
73
+ exports.ClientTicksService = ClientTicksService;
74
+ exports.ClientTicksService = ClientTicksService = __decorate([
75
+ (0, injection_js_1.Injectable)(),
76
+ __metadata("design:paramtypes", [])
77
+ ], ClientTicksService);
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ClientTranslateService = void 0;
16
+ const injection_js_1 = require("injection-js");
17
+ const client_session_service_1 = require("./client-session.service");
18
+ let ClientTranslateService = class ClientTranslateService {
19
+ get language() {
20
+ if (!this._language) {
21
+ this._language = this._session.getPlayerInfo('language');
22
+ }
23
+ return this._language || 'en';
24
+ }
25
+ constructor(_translations, _session) {
26
+ this._translations = _translations;
27
+ this._session = _session;
28
+ this._language = null;
29
+ }
30
+ instant(key) {
31
+ var _a;
32
+ return ((_a = this._translations[this.language]) === null || _a === void 0 ? void 0 : _a[key]) || key;
33
+ }
34
+ };
35
+ exports.ClientTranslateService = ClientTranslateService;
36
+ exports.ClientTranslateService = ClientTranslateService = __decorate([
37
+ (0, injection_js_1.Injectable)(),
38
+ __param(0, (0, injection_js_1.Inject)('translations')),
39
+ __param(1, (0, injection_js_1.Inject)(client_session_service_1.ClientSessionService)),
40
+ __metadata("design:paramtypes", [Object, client_session_service_1.ClientSessionService])
41
+ ], ClientTranslateService);
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ClientUIService = void 0;
16
+ const injection_js_1 = require("injection-js");
17
+ const client_ticks_service_1 = require("./client-ticks.service");
18
+ const rxjs_1 = require("rxjs");
19
+ const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
20
+ let ClientUIService = class ClientUIService {
21
+ get onShow$() {
22
+ return this._onShow$.asObservable();
23
+ }
24
+ get onHide$() {
25
+ return this._onHide$.asObservable();
26
+ }
27
+ get visible() {
28
+ return this._visible;
29
+ }
30
+ constructor(_ticksService) {
31
+ this._ticksService = _ticksService;
32
+ this._onShow$ = new rxjs_1.Subject();
33
+ this._onHide$ = new rxjs_1.Subject();
34
+ this._visible = false;
35
+ this.cooldownTimestamp = 0;
36
+ }
37
+ show(ignoreCursorMode = false, ignoreFocus = false) {
38
+ if (!this._visible) {
39
+ if (!ignoreCursorMode) {
40
+ Cfx.Client.EnterCursorMode();
41
+ }
42
+ if (!ignoreFocus) {
43
+ Cfx.Client.SetNuiFocus(true, true);
44
+ Cfx.Client.SetNuiFocusKeepInput(false);
45
+ }
46
+ }
47
+ this._visible = true;
48
+ this._ticksService.addUnique({
49
+ id: `${Cfx.Client.GetCurrentResourceName()}_UI`,
50
+ function: () => {
51
+ Cfx.Client.DisableControlAction(0, 1, this._visible);
52
+ Cfx.Client.DisableControlAction(0, 2, this._visible);
53
+ Cfx.Client.DisableControlAction(0, 142, this._visible);
54
+ Cfx.Client.DisableControlAction(0, 18, this._visible);
55
+ Cfx.Client.DisableControlAction(0, 322, this._visible);
56
+ Cfx.Client.DisableControlAction(0, 106, this._visible);
57
+ if (!this._visible) {
58
+ this._ticksService.remove(`${Cfx.Client.GetCurrentResourceName()}_UI`);
59
+ Cfx.Client.SetNuiFocus(false, false);
60
+ }
61
+ }
62
+ });
63
+ }
64
+ hide() {
65
+ this.cooldownTimestamp = Date.now() + (1000 * 3);
66
+ Cfx.Client.LeaveCursorMode();
67
+ this._visible = false;
68
+ Cfx.Client.SendNuiMessage(JSON.stringify({
69
+ type: 'dismiss'
70
+ }));
71
+ }
72
+ onForceShowUI(data) {
73
+ this.show(false, false);
74
+ this._onShow$.next(data);
75
+ }
76
+ onForceHideUI(data) {
77
+ this.hide();
78
+ this._onHide$.next(data);
79
+ }
80
+ dismiss() {
81
+ this.hide();
82
+ Cfx.TriggerServerEvent(`${Cfx.Client.GetCurrentResourceName()}:on-force-hidden`);
83
+ Cfx.emit(`${Cfx.Client.GetCurrentResourceName()}:on-force-hidden`);
84
+ }
85
+ isOnCooldown() {
86
+ return Date.now() < this.cooldownTimestamp;
87
+ }
88
+ };
89
+ exports.ClientUIService = ClientUIService;
90
+ __decorate([
91
+ (0, fivem_framework_common_1.EventListener)({ eventName: `${Cfx.Client.GetCurrentResourceName()}:force-showui` }),
92
+ __metadata("design:type", Function),
93
+ __metadata("design:paramtypes", [Object]),
94
+ __metadata("design:returntype", void 0)
95
+ ], ClientUIService.prototype, "onForceShowUI", null);
96
+ __decorate([
97
+ (0, fivem_framework_common_1.EventListener)({ eventName: `${Cfx.Client.GetCurrentResourceName()}:force-hideui` }),
98
+ __metadata("design:type", Function),
99
+ __metadata("design:paramtypes", [Object]),
100
+ __metadata("design:returntype", void 0)
101
+ ], ClientUIService.prototype, "onForceHideUI", null);
102
+ __decorate([
103
+ (0, fivem_framework_common_1.UIListener)({ eventName: 'dismiss' }),
104
+ __metadata("design:type", Function),
105
+ __metadata("design:paramtypes", []),
106
+ __metadata("design:returntype", void 0)
107
+ ], ClientUIService.prototype, "dismiss", null);
108
+ exports.ClientUIService = ClientUIService = __decorate([
109
+ (0, injection_js_1.Injectable)(),
110
+ __param(0, (0, injection_js_1.Inject)(client_ticks_service_1.ClientTicksService)),
111
+ __metadata("design:paramtypes", [client_ticks_service_1.ClientTicksService])
112
+ ], ClientUIService);
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ClientVehiclesService = void 0;
13
+ const injection_js_1 = require("injection-js");
14
+ const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
15
+ let ClientVehiclesService = class ClientVehiclesService {
16
+ get vehicles() {
17
+ return this._vehicles;
18
+ }
19
+ // TODO: Use $onInit
20
+ constructor() {
21
+ this._vehicles = [];
22
+ Cfx.Client.onNet('onResourceStop', (resourceName) => {
23
+ if (resourceName === Cfx.Client.GetCurrentResourceName()) {
24
+ this._vehicles.forEach((vehicle) => {
25
+ this.remove(vehicle);
26
+ });
27
+ this._vehicles = [];
28
+ }
29
+ });
30
+ }
31
+ /** Wrapper of FiveM's native CreateVehicle - includes requesting the model */
32
+ async createAsync(modelHash, x, y, z, heading, isNetwork, netMissionEntity, putPlayerInVehicle = false) {
33
+ let attempts = 0;
34
+ Cfx.Client.RequestModel(modelHash);
35
+ while (!Cfx.Client.HasModelLoaded(modelHash)) {
36
+ if (attempts > 10) {
37
+ return 0;
38
+ }
39
+ await (0, fivem_framework_common_1.Delay)(100);
40
+ attempts++;
41
+ }
42
+ const createdVehicle = Cfx.Client.CreateVehicle(modelHash, x, y, z, heading, isNetwork, netMissionEntity);
43
+ if (createdVehicle) {
44
+ if (netMissionEntity) {
45
+ this._vehicles.push(createdVehicle);
46
+ }
47
+ if (putPlayerInVehicle) {
48
+ Cfx.Client.TaskWarpPedIntoVehicle(Cfx.Client.GetPlayerPed(-1), createdVehicle, -1);
49
+ }
50
+ }
51
+ return createdVehicle;
52
+ }
53
+ remove(vehicle) {
54
+ if (Cfx.Client.DoesEntityExist(vehicle)) {
55
+ Cfx.Client.DeleteEntity(vehicle);
56
+ }
57
+ if (this._vehicles.indexOf(vehicle) > -1) {
58
+ this._vehicles.splice(this._vehicles.indexOf(vehicle), 1);
59
+ }
60
+ }
61
+ };
62
+ exports.ClientVehiclesService = ClientVehiclesService;
63
+ exports.ClientVehiclesService = ClientVehiclesService = __decorate([
64
+ (0, injection_js_1.Injectable)(),
65
+ __metadata("design:paramtypes", [])
66
+ ], ClientVehiclesService);
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ClientWaypointsService = void 0;
16
+ const injection_js_1 = require("injection-js");
17
+ const client_blips_service_1 = require("./client-blips.service");
18
+ const color_mappings_1 = require("../constants/color.mappings");
19
+ const client_checkpoints_service_1 = require("./client-checkpoints.service");
20
+ let ClientWaypointsService = class ClientWaypointsService {
21
+ get waypoints() {
22
+ return this._waypoints;
23
+ }
24
+ constructor(_blipsService, _checkpointsService) {
25
+ this._blipsService = _blipsService;
26
+ this._checkpointsService = _checkpointsService;
27
+ this._waypoints = [];
28
+ }
29
+ /** Defines a custom, irreplaceable waypoint */
30
+ createWaypoint(pos, title, color, id, routeColor, diameter = 3.0) {
31
+ const currentResource = Cfx.Client.GetCurrentResourceName().replace('-', ' ');
32
+ const defaultTitle = `${currentResource.slice(0, 1).toUpperCase()}${currentResource.slice(1)}`;
33
+ const _waypoint = this._blipsService.create({
34
+ id: id || 1,
35
+ color: color || 69,
36
+ title: title || defaultTitle,
37
+ pos,
38
+ longRange: true
39
+ });
40
+ this._checkpointsService.create(2, pos[0], pos[1], pos[2], null, null, null, diameter, color_mappings_1.COLOR_MAPPINGS[color !== null && color !== void 0 ? color : 0][0], color_mappings_1.COLOR_MAPPINGS[color !== null && color !== void 0 ? color : 0][1], color_mappings_1.COLOR_MAPPINGS[color !== null && color !== void 0 ? color : 0][2], 255, 0);
41
+ if (routeColor !== -1) {
42
+ Cfx.Client.SetBlipRoute(_waypoint, true);
43
+ if (routeColor) {
44
+ Cfx.Client.SetBlipRouteColour(_waypoint, routeColor);
45
+ }
46
+ }
47
+ this._waypoints.push(_waypoint);
48
+ return _waypoint;
49
+ }
50
+ clearWaypoints() {
51
+ this._waypoints.forEach((waypoint) => {
52
+ this.clearWaypoint(waypoint, true);
53
+ });
54
+ this._waypoints = [];
55
+ }
56
+ clearWaypoint(waypoint, ignoreSplice = false) {
57
+ this._checkpointsService.clearByPosition(Cfx.Client.GetBlipCoords(waypoint));
58
+ Cfx.Client.SetBlipRoute(waypoint, false);
59
+ Cfx.Client.RemoveBlip(waypoint);
60
+ if (!ignoreSplice) {
61
+ this._waypoints.splice(this._waypoints.indexOf(waypoint), 1);
62
+ }
63
+ }
64
+ };
65
+ exports.ClientWaypointsService = ClientWaypointsService;
66
+ exports.ClientWaypointsService = ClientWaypointsService = __decorate([
67
+ (0, injection_js_1.Injectable)(),
68
+ __param(0, (0, injection_js_1.Inject)(client_blips_service_1.ClientBlipsService)),
69
+ __param(1, (0, injection_js_1.Inject)(client_checkpoints_service_1.ClientCheckpointsService)),
70
+ __metadata("design:paramtypes", [client_blips_service_1.ClientBlipsService,
71
+ client_checkpoints_service_1.ClientCheckpointsService])
72
+ ], ClientWaypointsService);
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client-action-points.service"), exports);
18
+ __exportStar(require("./client-blips.service"), exports);
19
+ __exportStar(require("./client-checkpoints.service"), exports);
20
+ __exportStar(require("./client-hud.service"), exports);
21
+ __exportStar(require("./client-markers.service"), exports);
22
+ __exportStar(require("./client-peds.service"), exports);
23
+ __exportStar(require("./client-session.service"), exports);
24
+ __exportStar(require("./client-ticks.service"), exports);
25
+ __exportStar(require("./client-translate.service"), exports);
26
+ __exportStar(require("./client-vehicles.service"), exports);
27
+ __exportStar(require("./client-ui.service"), exports);
28
+ __exportStar(require("./client-waypoints.service"), exports);
@@ -0,0 +1,176 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ // TODO: Remove
11
+ import { ClientEntities } from './client-entities';
12
+ import { Delay, calculateDistance, Command, Controller, EventListener, EVENT_DIRECTIONS } from '@armoury/fivem-framework-common';
13
+ let ClientActionPoints = class ClientActionPoints extends ClientEntities {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.chunkRadius = 75;
17
+ this._actionPoints = {};
18
+ this._cachedPlayerPosition = [NaN, NaN];
19
+ this._cachedPlayerRoundedPosition = [NaN, NaN];
20
+ this._cachedIsPlayerInAnyVehicle = false;
21
+ }
22
+ get actionPoints() {
23
+ return this._actionPoints;
24
+ }
25
+ get cachedPlayerPosition() {
26
+ return this._cachedPlayerPosition;
27
+ }
28
+ createMarkers(markers) {
29
+ super.createMarkers(markers);
30
+ this.createActionPoints(...markers.map((marker) => ({
31
+ id: `${Cfx.Client.GetCurrentResourceName()}_marker_${marker.pos[0]}_${marker.pos[1]}`,
32
+ pos: marker.pos,
33
+ range: marker.renderDistance,
34
+ action: async () => {
35
+ var _a, _b, _c, _d, _e, _f, _g;
36
+ if (marker.textureDict && !Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
37
+ Cfx.Client.RequestStreamedTextureDict(marker.textureDict, true);
38
+ while (!Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
39
+ await Delay(100);
40
+ }
41
+ }
42
+ Cfx.Client.DrawMarker(marker.marker, marker.pos[0], marker.pos[1], marker.pos[2], 0.0, 0.0, 0.0, ((_a = marker.rotation) === null || _a === void 0 ? void 0 : _a[0]) || 0.0, ((_b = marker.rotation) === null || _b === void 0 ? void 0 : _b[1]) || 0.0, ((_c = marker.rotation) === null || _c === void 0 ? void 0 : _c[2]) || 0.0, marker.scale, marker.scale, marker.scale, marker.rgba[0], marker.rgba[1], marker.rgba[2], marker.rgba[3], false, true, 2, false, (marker.textureDict || null), (marker.textureName || null), false);
43
+ if (marker.underlyingCircle) {
44
+ Cfx.Client.DrawMarker(marker.underlyingCircle.marker, marker.pos[0], marker.pos[1], marker.pos[2] - 0.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, marker.underlyingCircle.scale, marker.underlyingCircle.scale, marker.underlyingCircle.scale, ((_d = marker.underlyingCircle.rgba) === null || _d === void 0 ? void 0 : _d[0]) || marker.rgba[0], ((_e = marker.underlyingCircle.rgba) === null || _e === void 0 ? void 0 : _e[1]) || marker.rgba[1], ((_f = marker.underlyingCircle.rgba) === null || _f === void 0 ? void 0 : _f[2]) || marker.rgba[2], ((_g = marker.underlyingCircle.rgba) === null || _g === void 0 ? void 0 : _g[3]) || marker.rgba[3], false, true, 2, false, null, null, false);
45
+ }
46
+ }
47
+ })));
48
+ }
49
+ clearMarkers() {
50
+ this.markers.forEach((_marker) => {
51
+ this.clearActionPoint(`${Cfx.Client.GetCurrentResourceName()}_marker_${_marker.pos[0]}_${_marker.pos[1]}`);
52
+ });
53
+ super.clearMarkers();
54
+ }
55
+ /** Creates one or multiple Action Points. Action points DO NOT include markers and/or blips.
56
+ * They only contain the logic executed when a position is met.
57
+ */
58
+ createActionPoints(...actionPoints) {
59
+ actionPoints.forEach((actionPoint) => {
60
+ this.createActionPoint(actionPoint);
61
+ });
62
+ }
63
+ createActionPoint(actionPoint) {
64
+ const nearestX = this.roundToNearest(actionPoint.pos[0], this.chunkRadius);
65
+ const nearestY = this.roundToNearest(actionPoint.pos[1], this.chunkRadius);
66
+ if (!this._actionPoints[nearestX]) {
67
+ this._actionPoints[nearestX] = {};
68
+ }
69
+ if (!this.actionPoints[nearestX][nearestY]) {
70
+ this._actionPoints[nearestX][nearestY] = [];
71
+ }
72
+ this._actionPoints[nearestX][nearestY].push(actionPoint);
73
+ }
74
+ clearActionPoint(id) {
75
+ Object.keys(this._actionPoints).forEach((posXAsStr) => {
76
+ const posX = Number(posXAsStr);
77
+ Object.keys(this._actionPoints[posX]).forEach((posYAsStr) => {
78
+ const posY = Number(posYAsStr);
79
+ this._actionPoints[posX][posY] =
80
+ this._actionPoints[posX][posY].filter((_actionPoint) => _actionPoint.id != id);
81
+ });
82
+ });
83
+ }
84
+ clearActionPoints() {
85
+ this._actionPoints = {};
86
+ this.removeFromTick(`${Cfx.Client.GetCurrentResourceName()}_actionpoints`);
87
+ }
88
+ actionPointExistsAtPosition(posX, posY, posZ) {
89
+ const roundedPosX = this.roundToNearest(posX, this.chunkRadius);
90
+ const roundedPosY = this.roundToNearest(posY, this.chunkRadius);
91
+ if (!this.actionPoints[roundedPosX] || !this.actionPoints[roundedPosX][roundedPosY]) {
92
+ return false;
93
+ }
94
+ if (this.actionPoints[roundedPosX][roundedPosY].find((actionPoint) => actionPoint.pos[0] == posX
95
+ && actionPoint.pos[1] == posY
96
+ && actionPoint.pos[2] == posZ)) {
97
+ return true;
98
+ }
99
+ return false;
100
+ }
101
+ removeActionPoint(actionPoint) {
102
+ var _a, _b;
103
+ if ((_b = (_a = this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)]) === null || _a === void 0 ? void 0 : _a[this.roundToNearest(actionPoint.pos[1], this.chunkRadius)]) === null || _b === void 0 ? void 0 : _b.length) {
104
+ this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)] =
105
+ this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)].filter((_actionPoint) => _actionPoint.id != actionPoint.id);
106
+ }
107
+ }
108
+ onThreadTriggered(optimizationType) {
109
+ var _a, _b;
110
+ if (optimizationType === 'chunk-checker') {
111
+ this._cachedPlayerPosition = Cfx.Client.GetEntityCoords(Cfx.Client.PlayerPedId(), true);
112
+ const [nearestX, nearestY] = [this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius), this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)];
113
+ if (this._cachedPlayerRoundedPosition[0] == nearestX && this._cachedPlayerRoundedPosition[1] == nearestY) {
114
+ return;
115
+ }
116
+ this._cachedPlayerRoundedPosition = [nearestX, nearestY];
117
+ this._cachedIsPlayerInAnyVehicle = Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false);
118
+ if ((_b = (_a = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _a === void 0 ? void 0 : _a[this._cachedPlayerRoundedPosition[1]]) === null || _b === void 0 ? void 0 : _b.length) {
119
+ this.addToTickUnique({
120
+ id: `${Cfx.Client.GetCurrentResourceName()}_actionpoints`,
121
+ function: (() => {
122
+ var _a, _b, _c, _d;
123
+ for (let i = 0; i < ((_b = (_a = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _a === void 0 ? void 0 : _a[this._cachedPlayerRoundedPosition[1]]) === null || _b === void 0 ? void 0 : _b.length); i++) {
124
+ const _actionPoint = (_c = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _c === void 0 ? void 0 : _c[this._cachedPlayerRoundedPosition[1]][i];
125
+ if (calculateDistance([_actionPoint.pos[0], _actionPoint.pos[1], _actionPoint.pos[2], this._cachedPlayerPosition[0], this._cachedPlayerPosition[1], _actionPoint.pos[2]]) <= (_actionPoint.range || 1.0) + (this._cachedIsPlayerInAnyVehicle && !_actionPoint.onfootOnly ? 5 : 0)) {
126
+ const actionPassed = (!_actionPoint.onceIf || _actionPoint.onceIf()) && (!_actionPoint.onfootOnly || !Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false)) && (!_actionPoint.inVehicleOnly || Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false));
127
+ if (actionPassed) {
128
+ _actionPoint.action();
129
+ }
130
+ if ((_actionPoint.once || _actionPoint.onceIf) && actionPassed) {
131
+ (_d = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _d === void 0 ? void 0 : _d[this._cachedPlayerRoundedPosition[1]].splice(i, 1);
132
+ i--;
133
+ }
134
+ }
135
+ }
136
+ })
137
+ });
138
+ }
139
+ else {
140
+ this.removeFromTick(`${Cfx.Client.GetCurrentResourceName()}_actionpoints`);
141
+ }
142
+ }
143
+ }
144
+ debug_ActionPoints() {
145
+ var _a, _b;
146
+ let totalActionPoints = 0;
147
+ const currentAreaActionPoints = ((_b = (_a = this.actionPoints[this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius)]) === null || _a === void 0 ? void 0 : _a[this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)]) === null || _b === void 0 ? void 0 : _b.length) || 0;
148
+ Object.keys(this.actionPoints).forEach((posXAsStr) => {
149
+ const posX = Number(posXAsStr);
150
+ Object.keys(this.actionPoints[posX]).forEach((posYAsStr) => {
151
+ const posY = Number(posYAsStr);
152
+ totalActionPoints += this.actionPoints[posX][posY].length;
153
+ });
154
+ });
155
+ console.log(`Total action points: ${totalActionPoints}. Action points in this area: ${currentAreaActionPoints}`);
156
+ }
157
+ roundToNearest(num, multiple) {
158
+ return Math.round(num / multiple) * multiple;
159
+ }
160
+ };
161
+ __decorate([
162
+ EventListener({ eventName: 'armoury:thread-triggerer', direction: EVENT_DIRECTIONS.CLIENT_TO_CLIENT }),
163
+ __metadata("design:type", Function),
164
+ __metadata("design:paramtypes", [String]),
165
+ __metadata("design:returntype", void 0)
166
+ ], ClientActionPoints.prototype, "onThreadTriggered", null);
167
+ __decorate([
168
+ Command({ suffix: `_${Cfx.Client.GetCurrentResourceName()}` }),
169
+ __metadata("design:type", Function),
170
+ __metadata("design:paramtypes", []),
171
+ __metadata("design:returntype", void 0)
172
+ ], ClientActionPoints.prototype, "debug_ActionPoints", null);
173
+ ClientActionPoints = __decorate([
174
+ Controller()
175
+ ], ClientActionPoints);
176
+ export { ClientActionPoints };