@open-core/framework 1.0.1-beta.1
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.
- package/LICENSE +373 -0
- package/README.md +350 -0
- package/dist/client/client-bootstrap.d.ts +1 -0
- package/dist/client/client-bootstrap.js +53 -0
- package/dist/client/client-container.d.ts +2 -0
- package/dist/client/client-container.js +6 -0
- package/dist/client/client-core.d.ts +18 -0
- package/dist/client/client-core.js +52 -0
- package/dist/client/decorators/controller.d.ts +3 -0
- package/dist/client/decorators/controller.js +14 -0
- package/dist/client/decorators/export.d.ts +7 -0
- package/dist/client/decorators/export.js +15 -0
- package/dist/client/decorators/gameEvent.d.ts +47 -0
- package/dist/client/decorators/gameEvent.js +54 -0
- package/dist/client/decorators/index.d.ts +10 -0
- package/dist/client/decorators/index.js +26 -0
- package/dist/client/decorators/interval.d.ts +7 -0
- package/dist/client/decorators/interval.js +15 -0
- package/dist/client/decorators/key.d.ts +2 -0
- package/dist/client/decorators/key.js +10 -0
- package/dist/client/decorators/localEvent.d.ts +7 -0
- package/dist/client/decorators/localEvent.js +15 -0
- package/dist/client/decorators/nui.d.ts +1 -0
- package/dist/client/decorators/nui.js +9 -0
- package/dist/client/decorators/onNet.d.ts +1 -0
- package/dist/client/decorators/onNet.js +9 -0
- package/dist/client/decorators/resourceLifecycle.d.ts +11 -0
- package/dist/client/decorators/resourceLifecycle.js +24 -0
- package/dist/client/decorators/tick.d.ts +1 -0
- package/dist/client/decorators/tick.js +9 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +22 -0
- package/dist/client/loaders/exports.loader.d.ts +1 -0
- package/dist/client/loaders/exports.loader.js +13 -0
- package/dist/client/player/player.d.ts +262 -0
- package/dist/client/player/player.js +480 -0
- package/dist/client/player/player.loader.d.ts +1 -0
- package/dist/client/player/player.loader.js +22 -0
- package/dist/client/services/core/index.d.ts +1 -0
- package/dist/client/services/core/index.js +17 -0
- package/dist/client/services/core/spawn.service.d.ts +20 -0
- package/dist/client/services/core/spawn.service.js +143 -0
- package/dist/client/services/index.d.ts +4 -0
- package/dist/client/services/index.js +24 -0
- package/dist/client/services/streaming/index.d.ts +1 -0
- package/dist/client/services/streaming/index.js +17 -0
- package/dist/client/services/streaming/streaming.service.d.ts +165 -0
- package/dist/client/services/streaming/streaming.service.js +341 -0
- package/dist/client/services/ui/index.d.ts +3 -0
- package/dist/client/services/ui/index.js +19 -0
- package/dist/client/services/ui/notification.service.d.ts +76 -0
- package/dist/client/services/ui/notification.service.js +111 -0
- package/dist/client/services/ui/progress.service.d.ts +82 -0
- package/dist/client/services/ui/progress.service.js +210 -0
- package/dist/client/services/ui/textui.service.d.ts +82 -0
- package/dist/client/services/ui/textui.service.js +156 -0
- package/dist/client/services/world/blip.service.d.ts +112 -0
- package/dist/client/services/world/blip.service.js +215 -0
- package/dist/client/services/world/index.d.ts +4 -0
- package/dist/client/services/world/index.js +20 -0
- package/dist/client/services/world/marker.service.d.ts +94 -0
- package/dist/client/services/world/marker.service.js +153 -0
- package/dist/client/services/world/ped.service.d.ts +182 -0
- package/dist/client/services/world/ped.service.js +302 -0
- package/dist/client/services/world/vehicle.service.d.ts +168 -0
- package/dist/client/services/world/vehicle.service.js +296 -0
- package/dist/client/system/metadata-client.keys.d.ts +13 -0
- package/dist/client/system/metadata-client.keys.js +16 -0
- package/dist/client/system/processors/export.processor.d.ts +7 -0
- package/dist/client/system/processors/export.processor.js +39 -0
- package/dist/client/system/processors/gameEvent.processor.d.ts +10 -0
- package/dist/client/system/processors/gameEvent.processor.js +58 -0
- package/dist/client/system/processors/interval.processor.d.ts +7 -0
- package/dist/client/system/processors/interval.processor.js +43 -0
- package/dist/client/system/processors/key.processor.d.ts +8 -0
- package/dist/client/system/processors/key.processor.js +27 -0
- package/dist/client/system/processors/localEvent.processor.d.ts +7 -0
- package/dist/client/system/processors/localEvent.processor.js +38 -0
- package/dist/client/system/processors/netEvent.processor.d.ts +7 -0
- package/dist/client/system/processors/netEvent.processor.js +38 -0
- package/dist/client/system/processors/nui.processor.d.ts +7 -0
- package/dist/client/system/processors/nui.processor.js +40 -0
- package/dist/client/system/processors/resourceLifecycle.processor.d.ts +9 -0
- package/dist/client/system/processors/resourceLifecycle.processor.js +69 -0
- package/dist/client/system/processors/tick.processor.d.ts +5 -0
- package/dist/client/system/processors/tick.processor.js +37 -0
- package/dist/client/system/processors.register.d.ts +1 -0
- package/dist/client/system/processors.register.js +27 -0
- package/dist/client/types/game-events.d.ts +126 -0
- package/dist/client/types/game-events.js +83 -0
- package/dist/client/types/index.d.ts +1 -0
- package/dist/client/types/index.js +17 -0
- package/dist/client/ui-bridge.d.ts +116 -0
- package/dist/client/ui-bridge.js +201 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +46 -0
- package/dist/server/bootstrap.d.ts +16 -0
- package/dist/server/bootstrap.js +57 -0
- package/dist/server/bus/core-event-bus.d.ts +6 -0
- package/dist/server/bus/core-event-bus.js +31 -0
- package/dist/server/configs/api.config.d.ts +71 -0
- package/dist/server/configs/api.config.js +81 -0
- package/dist/server/configs/config.base.d.ts +63 -0
- package/dist/server/configs/config.base.js +64 -0
- package/dist/server/configs/index.d.ts +2 -0
- package/dist/server/configs/index.js +18 -0
- package/dist/server/container.d.ts +2 -0
- package/dist/server/container.js +6 -0
- package/dist/server/controllers/chat.controller.d.ts +10 -0
- package/dist/server/controllers/chat.controller.js +50 -0
- package/dist/server/controllers/command.controller.d.ts +7 -0
- package/dist/server/controllers/command.controller.js +47 -0
- package/dist/server/core.d.ts +1 -0
- package/dist/server/core.js +7 -0
- package/dist/server/database/adapters/oxmysql.adapter.d.ts +89 -0
- package/dist/server/database/adapters/oxmysql.adapter.js +149 -0
- package/dist/server/database/database.contract.d.ts +128 -0
- package/dist/server/database/database.contract.js +29 -0
- package/dist/server/database/database.service.d.ts +216 -0
- package/dist/server/database/database.service.js +301 -0
- package/dist/server/database/index.d.ts +53 -0
- package/dist/server/database/index.js +70 -0
- package/dist/server/database/types.d.ts +67 -0
- package/dist/server/database/types.js +7 -0
- package/dist/server/database.d.ts +7 -0
- package/dist/server/database.js +23 -0
- package/dist/server/decorators/bind.d.ts +2 -0
- package/dist/server/decorators/bind.js +15 -0
- package/dist/server/decorators/command.d.ts +19 -0
- package/dist/server/decorators/command.js +18 -0
- package/dist/server/decorators/controller.d.ts +3 -0
- package/dist/server/decorators/controller.js +14 -0
- package/dist/server/decorators/coreEvent.d.ts +2 -0
- package/dist/server/decorators/coreEvent.js +9 -0
- package/dist/server/decorators/export.d.ts +1 -0
- package/dist/server/decorators/export.js +9 -0
- package/dist/server/decorators/guard.d.ts +5 -0
- package/dist/server/decorators/guard.js +39 -0
- package/dist/server/decorators/index.d.ts +10 -0
- package/dist/server/decorators/index.js +26 -0
- package/dist/server/decorators/netEvent.d.ts +36 -0
- package/dist/server/decorators/netEvent.js +40 -0
- package/dist/server/decorators/onTick.d.ts +1 -0
- package/dist/server/decorators/onTick.js +9 -0
- package/dist/server/decorators/public.d.ts +16 -0
- package/dist/server/decorators/public.js +25 -0
- package/dist/server/decorators/requiresState.d.ts +55 -0
- package/dist/server/decorators/requiresState.js +62 -0
- package/dist/server/decorators/throttle.d.ts +9 -0
- package/dist/server/decorators/throttle.js +36 -0
- package/dist/server/decorators/utils.d.ts +7 -0
- package/dist/server/decorators/utils.js +13 -0
- package/dist/server/entities/index.d.ts +1 -0
- package/dist/server/entities/index.js +17 -0
- package/dist/server/entities/player.d.ts +157 -0
- package/dist/server/entities/player.js +217 -0
- package/dist/server/error-handler.d.ts +2 -0
- package/dist/server/error-handler.js +43 -0
- package/dist/server/index.d.ts +10 -0
- package/dist/server/index.js +29 -0
- package/dist/server/loaders/exports.loader.d.ts +0 -0
- package/dist/server/loaders/exports.loader.js +23 -0
- package/dist/server/loaders/playerSession.loader.d.ts +1 -0
- package/dist/server/loaders/playerSession.loader.js +42 -0
- package/dist/server/services/access-control.service.d.ts +56 -0
- package/dist/server/services/access-control.service.js +99 -0
- package/dist/server/services/chat.service.d.ts +7 -0
- package/dist/server/services/chat.service.js +31 -0
- package/dist/server/services/command.service.d.ts +15 -0
- package/dist/server/services/command.service.js +74 -0
- package/dist/server/services/config.service.d.ts +75 -0
- package/dist/server/services/config.service.js +116 -0
- package/dist/server/services/default/default-security.handler.d.ts +6 -0
- package/dist/server/services/default/default-security.handler.js +26 -0
- package/dist/server/services/http/http.service.d.ts +50 -0
- package/dist/server/services/http/http.service.js +126 -0
- package/dist/server/services/index.d.ts +10 -0
- package/dist/server/services/index.js +26 -0
- package/dist/server/services/parallel/index.d.ts +49 -0
- package/dist/server/services/parallel/index.js +67 -0
- package/dist/server/services/parallel/parallel-compute.service.d.ts +132 -0
- package/dist/server/services/parallel/parallel-compute.service.js +449 -0
- package/dist/server/services/parallel/types.d.ts +188 -0
- package/dist/server/services/parallel/types.js +7 -0
- package/dist/server/services/parallel/worker-pool.d.ts +83 -0
- package/dist/server/services/parallel/worker-pool.js +350 -0
- package/dist/server/services/parallel/worker.d.ts +19 -0
- package/dist/server/services/parallel/worker.js +49 -0
- package/dist/server/services/persistence.service.d.ts +59 -0
- package/dist/server/services/persistence.service.js +166 -0
- package/dist/server/services/player.service.d.ts +96 -0
- package/dist/server/services/player.service.js +132 -0
- package/dist/server/services/rate-limiter.service.d.ts +5 -0
- package/dist/server/services/rate-limiter.service.js +39 -0
- package/dist/server/services/registers.d.ts +1 -0
- package/dist/server/services/registers.js +18 -0
- package/dist/server/setup.d.ts +9 -0
- package/dist/server/setup.js +28 -0
- package/dist/server/system/metadata-server.keys.d.ts +9 -0
- package/dist/server/system/metadata-server.keys.js +12 -0
- package/dist/server/system/processors/command.processor.d.ts +9 -0
- package/dist/server/system/processors/command.processor.js +31 -0
- package/dist/server/system/processors/coreEvent.processor.d.ts +7 -0
- package/dist/server/system/processors/coreEvent.processor.js +38 -0
- package/dist/server/system/processors/export.processor.d.ts +7 -0
- package/dist/server/system/processors/export.processor.js +26 -0
- package/dist/server/system/processors/netEvent.processor.d.ts +11 -0
- package/dist/server/system/processors/netEvent.processor.js +100 -0
- package/dist/server/system/processors/tick.processor.d.ts +5 -0
- package/dist/server/system/processors/tick.processor.js +36 -0
- package/dist/server/system/processors.register.d.ts +1 -0
- package/dist/server/system/processors.register.js +21 -0
- package/dist/server/templates/admin/admin.controller-template.d.ts +10 -0
- package/dist/server/templates/admin/admin.controller-template.js +2 -0
- package/dist/server/templates/auth/auth-provider.contract.d.ts +58 -0
- package/dist/server/templates/auth/auth-provider.contract.js +23 -0
- package/dist/server/templates/index.d.ts +8 -0
- package/dist/server/templates/index.js +21 -0
- package/dist/server/templates/persistence/index.d.ts +30 -0
- package/dist/server/templates/persistence/index.js +34 -0
- package/dist/server/templates/persistence/player-persistence.contract.d.ts +86 -0
- package/dist/server/templates/persistence/player-persistence.contract.js +52 -0
- package/dist/server/templates/repository/index.d.ts +57 -0
- package/dist/server/templates/repository/index.js +61 -0
- package/dist/server/templates/repository/repository.contract.d.ts +224 -0
- package/dist/server/templates/repository/repository.contract.js +342 -0
- package/dist/server/templates/repository/repository.types.d.ts +51 -0
- package/dist/server/templates/repository/repository.types.js +7 -0
- package/dist/server/templates/security/permission.types.d.ts +32 -0
- package/dist/server/templates/security/permission.types.js +2 -0
- package/dist/server/templates/security/principal-provider.contract.d.ts +43 -0
- package/dist/server/templates/security/principal-provider.contract.js +19 -0
- package/dist/server/templates/security/security-handler.contract.d.ts +5 -0
- package/dist/server/templates/security/security-handler.contract.js +6 -0
- package/dist/server/types/core-events.d.ts +17 -0
- package/dist/server/types/core-events.js +2 -0
- package/dist/server/types/security.types.d.ts +7 -0
- package/dist/server/types/security.types.js +2 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +17 -0
- package/dist/shared/logger/core-logger.d.ts +35 -0
- package/dist/shared/logger/core-logger.js +52 -0
- package/dist/shared/logger/index.d.ts +11 -0
- package/dist/shared/logger/index.js +26 -0
- package/dist/shared/logger/logger.config.d.ts +47 -0
- package/dist/shared/logger/logger.config.js +33 -0
- package/dist/shared/logger/logger.service.d.ts +161 -0
- package/dist/shared/logger/logger.service.js +279 -0
- package/dist/shared/logger/logger.types.d.ts +85 -0
- package/dist/shared/logger/logger.types.js +74 -0
- package/dist/shared/logger/transports/buffered.transport.d.ts +88 -0
- package/dist/shared/logger/transports/buffered.transport.js +174 -0
- package/dist/shared/logger/transports/console.transport.d.ts +37 -0
- package/dist/shared/logger/transports/console.transport.js +134 -0
- package/dist/shared/logger/transports/index.d.ts +3 -0
- package/dist/shared/logger/transports/index.js +19 -0
- package/dist/shared/logger/transports/transport.interface.d.ts +40 -0
- package/dist/shared/logger/transports/transport.interface.js +2 -0
- package/dist/system/class-constructor.d.ts +1 -0
- package/dist/system/class-constructor.js +2 -0
- package/dist/system/decorator-processor.d.ts +4 -0
- package/dist/system/decorator-processor.js +2 -0
- package/dist/system/metadata.scanner.d.ts +7 -0
- package/dist/system/metadata.scanner.js +45 -0
- package/dist/utils/errors.d.ts +14 -0
- package/dist/utils/errors.js +25 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/result.d.ts +12 -0
- package/dist/utils/result.js +10 -0
- package/dist/utils/rgb.d.ts +5 -0
- package/dist/utils/rgb.js +2 -0
- package/dist/utils/vector3.d.ts +13 -0
- package/dist/utils/vector3.js +27 -0
- package/package.json +70 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Vector3 } from '../../../utils';
|
|
2
|
+
export interface BlipOptions {
|
|
3
|
+
/** Blip sprite ID (icon) */
|
|
4
|
+
sprite?: number;
|
|
5
|
+
/** Blip color ID */
|
|
6
|
+
color?: number;
|
|
7
|
+
/** Blip scale */
|
|
8
|
+
scale?: number;
|
|
9
|
+
/** Short range blip (only visible nearby) */
|
|
10
|
+
shortRange?: boolean;
|
|
11
|
+
/** Blip label/name */
|
|
12
|
+
label?: string;
|
|
13
|
+
/** Display category (affects visibility on map) */
|
|
14
|
+
display?: number;
|
|
15
|
+
/** Blip category */
|
|
16
|
+
category?: number;
|
|
17
|
+
/** Flash the blip */
|
|
18
|
+
flash?: boolean;
|
|
19
|
+
/** Blip alpha (0-255) */
|
|
20
|
+
alpha?: number;
|
|
21
|
+
/** Route to this blip */
|
|
22
|
+
route?: boolean;
|
|
23
|
+
/** Route color */
|
|
24
|
+
routeColor?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ManagedBlip {
|
|
27
|
+
id: string;
|
|
28
|
+
handle: number;
|
|
29
|
+
position: Vector3;
|
|
30
|
+
options: BlipOptions;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Service for creating and managing map blips.
|
|
34
|
+
*/
|
|
35
|
+
export declare class BlipService {
|
|
36
|
+
private blips;
|
|
37
|
+
private idCounter;
|
|
38
|
+
/**
|
|
39
|
+
* Create a blip at a world position.
|
|
40
|
+
*
|
|
41
|
+
* @param position - World position
|
|
42
|
+
* @param options - Blip options
|
|
43
|
+
* @returns The blip ID
|
|
44
|
+
*/
|
|
45
|
+
create(position: Vector3, options?: BlipOptions): string;
|
|
46
|
+
/**
|
|
47
|
+
* Create a blip attached to an entity.
|
|
48
|
+
*
|
|
49
|
+
* @param entity - Entity handle
|
|
50
|
+
* @param options - Blip options
|
|
51
|
+
* @returns The blip ID
|
|
52
|
+
*/
|
|
53
|
+
createForEntity(entity: number, options?: BlipOptions): string;
|
|
54
|
+
/**
|
|
55
|
+
* Create a blip for a radius/area.
|
|
56
|
+
*
|
|
57
|
+
* @param position - Center position
|
|
58
|
+
* @param radius - Radius of the area
|
|
59
|
+
* @param options - Blip options
|
|
60
|
+
* @returns The blip ID
|
|
61
|
+
*/
|
|
62
|
+
createForRadius(position: Vector3, radius: number, options?: BlipOptions): string;
|
|
63
|
+
/**
|
|
64
|
+
* Remove a blip by ID.
|
|
65
|
+
*
|
|
66
|
+
* @param id - The blip ID
|
|
67
|
+
*/
|
|
68
|
+
remove(id: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Remove all managed blips.
|
|
71
|
+
*/
|
|
72
|
+
removeAll(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Update blip options.
|
|
75
|
+
*
|
|
76
|
+
* @param id - The blip ID
|
|
77
|
+
* @param options - New options to apply
|
|
78
|
+
*/
|
|
79
|
+
update(id: string, options: Partial<BlipOptions>): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Set blip position.
|
|
82
|
+
*
|
|
83
|
+
* @param id - The blip ID
|
|
84
|
+
* @param position - New position
|
|
85
|
+
*/
|
|
86
|
+
setPosition(id: string, position: Vector3): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Set whether a route should be drawn to the blip.
|
|
89
|
+
*
|
|
90
|
+
* @param id - The blip ID
|
|
91
|
+
* @param enabled - Whether to show the route
|
|
92
|
+
* @param color - Optional route color
|
|
93
|
+
*/
|
|
94
|
+
setRoute(id: string, enabled: boolean, color?: number): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Get blip by ID.
|
|
97
|
+
*/
|
|
98
|
+
get(id: string): ManagedBlip | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Get all managed blips.
|
|
101
|
+
*/
|
|
102
|
+
getAll(): ManagedBlip[];
|
|
103
|
+
/**
|
|
104
|
+
* Get the native blip handle by ID.
|
|
105
|
+
*/
|
|
106
|
+
getHandle(id: string): number | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Check if a blip still exists in the game world.
|
|
109
|
+
*/
|
|
110
|
+
exists(id: string): boolean;
|
|
111
|
+
private applyOptions;
|
|
112
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
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.BlipService = void 0;
|
|
10
|
+
const tsyringe_1 = require("tsyringe");
|
|
11
|
+
const DEFAULT_OPTIONS = {
|
|
12
|
+
sprite: 1,
|
|
13
|
+
color: 1,
|
|
14
|
+
scale: 1.0,
|
|
15
|
+
shortRange: true,
|
|
16
|
+
display: 4,
|
|
17
|
+
category: 0,
|
|
18
|
+
flash: false,
|
|
19
|
+
alpha: 255,
|
|
20
|
+
route: false,
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Service for creating and managing map blips.
|
|
24
|
+
*/
|
|
25
|
+
let BlipService = class BlipService {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.blips = new Map();
|
|
28
|
+
this.idCounter = 0;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a blip at a world position.
|
|
32
|
+
*
|
|
33
|
+
* @param position - World position
|
|
34
|
+
* @param options - Blip options
|
|
35
|
+
* @returns The blip ID
|
|
36
|
+
*/
|
|
37
|
+
create(position, options = {}) {
|
|
38
|
+
const id = `blip_${++this.idCounter}`;
|
|
39
|
+
const opts = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
40
|
+
const handle = AddBlipForCoord(position.x, position.y, position.z);
|
|
41
|
+
this.applyOptions(handle, opts);
|
|
42
|
+
this.blips.set(id, { id, handle, position, options: opts });
|
|
43
|
+
return id;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create a blip attached to an entity.
|
|
47
|
+
*
|
|
48
|
+
* @param entity - Entity handle
|
|
49
|
+
* @param options - Blip options
|
|
50
|
+
* @returns The blip ID
|
|
51
|
+
*/
|
|
52
|
+
createForEntity(entity, options = {}) {
|
|
53
|
+
const id = `blip_${++this.idCounter}`;
|
|
54
|
+
const opts = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
55
|
+
const handle = AddBlipForEntity(entity);
|
|
56
|
+
this.applyOptions(handle, opts);
|
|
57
|
+
const [x, y, z] = GetEntityCoords(entity, true);
|
|
58
|
+
this.blips.set(id, { id, handle, position: { x, y, z }, options: opts });
|
|
59
|
+
return id;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a blip for a radius/area.
|
|
63
|
+
*
|
|
64
|
+
* @param position - Center position
|
|
65
|
+
* @param radius - Radius of the area
|
|
66
|
+
* @param options - Blip options
|
|
67
|
+
* @returns The blip ID
|
|
68
|
+
*/
|
|
69
|
+
createForRadius(position, radius, options = {}) {
|
|
70
|
+
const id = `blip_${++this.idCounter}`;
|
|
71
|
+
const opts = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
72
|
+
const handle = AddBlipForRadius(position.x, position.y, position.z, radius);
|
|
73
|
+
this.applyOptions(handle, opts);
|
|
74
|
+
this.blips.set(id, { id, handle, position, options: opts });
|
|
75
|
+
return id;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Remove a blip by ID.
|
|
79
|
+
*
|
|
80
|
+
* @param id - The blip ID
|
|
81
|
+
*/
|
|
82
|
+
remove(id) {
|
|
83
|
+
const blip = this.blips.get(id);
|
|
84
|
+
if (!blip)
|
|
85
|
+
return false;
|
|
86
|
+
if (DoesBlipExist(blip.handle)) {
|
|
87
|
+
RemoveBlip(blip.handle);
|
|
88
|
+
}
|
|
89
|
+
this.blips.delete(id);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Remove all managed blips.
|
|
94
|
+
*/
|
|
95
|
+
removeAll() {
|
|
96
|
+
for (const blip of this.blips.values()) {
|
|
97
|
+
if (DoesBlipExist(blip.handle)) {
|
|
98
|
+
RemoveBlip(blip.handle);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this.blips.clear();
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Update blip options.
|
|
105
|
+
*
|
|
106
|
+
* @param id - The blip ID
|
|
107
|
+
* @param options - New options to apply
|
|
108
|
+
*/
|
|
109
|
+
update(id, options) {
|
|
110
|
+
const blip = this.blips.get(id);
|
|
111
|
+
if (!blip || !DoesBlipExist(blip.handle))
|
|
112
|
+
return false;
|
|
113
|
+
blip.options = Object.assign(Object.assign({}, blip.options), options);
|
|
114
|
+
this.applyOptions(blip.handle, blip.options);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Set blip position.
|
|
119
|
+
*
|
|
120
|
+
* @param id - The blip ID
|
|
121
|
+
* @param position - New position
|
|
122
|
+
*/
|
|
123
|
+
setPosition(id, position) {
|
|
124
|
+
const blip = this.blips.get(id);
|
|
125
|
+
if (!blip || !DoesBlipExist(blip.handle))
|
|
126
|
+
return false;
|
|
127
|
+
SetBlipCoords(blip.handle, position.x, position.y, position.z);
|
|
128
|
+
blip.position = position;
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Set whether a route should be drawn to the blip.
|
|
133
|
+
*
|
|
134
|
+
* @param id - The blip ID
|
|
135
|
+
* @param enabled - Whether to show the route
|
|
136
|
+
* @param color - Optional route color
|
|
137
|
+
*/
|
|
138
|
+
setRoute(id, enabled, color) {
|
|
139
|
+
const blip = this.blips.get(id);
|
|
140
|
+
if (!blip || !DoesBlipExist(blip.handle))
|
|
141
|
+
return false;
|
|
142
|
+
SetBlipRoute(blip.handle, enabled);
|
|
143
|
+
if (color !== undefined) {
|
|
144
|
+
SetBlipRouteColour(blip.handle, color);
|
|
145
|
+
}
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get blip by ID.
|
|
150
|
+
*/
|
|
151
|
+
get(id) {
|
|
152
|
+
return this.blips.get(id);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get all managed blips.
|
|
156
|
+
*/
|
|
157
|
+
getAll() {
|
|
158
|
+
return Array.from(this.blips.values());
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get the native blip handle by ID.
|
|
162
|
+
*/
|
|
163
|
+
getHandle(id) {
|
|
164
|
+
var _a;
|
|
165
|
+
return (_a = this.blips.get(id)) === null || _a === void 0 ? void 0 : _a.handle;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Check if a blip still exists in the game world.
|
|
169
|
+
*/
|
|
170
|
+
exists(id) {
|
|
171
|
+
const blip = this.blips.get(id);
|
|
172
|
+
return blip ? DoesBlipExist(blip.handle) : false;
|
|
173
|
+
}
|
|
174
|
+
applyOptions(handle, options) {
|
|
175
|
+
if (options.sprite !== undefined) {
|
|
176
|
+
SetBlipSprite(handle, options.sprite);
|
|
177
|
+
}
|
|
178
|
+
if (options.color !== undefined) {
|
|
179
|
+
SetBlipColour(handle, options.color);
|
|
180
|
+
}
|
|
181
|
+
if (options.scale !== undefined) {
|
|
182
|
+
SetBlipScale(handle, options.scale);
|
|
183
|
+
}
|
|
184
|
+
if (options.shortRange !== undefined) {
|
|
185
|
+
SetBlipAsShortRange(handle, options.shortRange);
|
|
186
|
+
}
|
|
187
|
+
if (options.label) {
|
|
188
|
+
BeginTextCommandSetBlipName('STRING');
|
|
189
|
+
AddTextComponentString(options.label);
|
|
190
|
+
EndTextCommandSetBlipName(handle);
|
|
191
|
+
}
|
|
192
|
+
if (options.display !== undefined) {
|
|
193
|
+
SetBlipDisplay(handle, options.display);
|
|
194
|
+
}
|
|
195
|
+
if (options.category !== undefined) {
|
|
196
|
+
SetBlipCategory(handle, options.category);
|
|
197
|
+
}
|
|
198
|
+
if (options.flash !== undefined) {
|
|
199
|
+
SetBlipFlashes(handle, options.flash);
|
|
200
|
+
}
|
|
201
|
+
if (options.alpha !== undefined) {
|
|
202
|
+
SetBlipAlpha(handle, options.alpha);
|
|
203
|
+
}
|
|
204
|
+
if (options.route !== undefined) {
|
|
205
|
+
SetBlipRoute(handle, options.route);
|
|
206
|
+
if (options.routeColor !== undefined) {
|
|
207
|
+
SetBlipRouteColour(handle, options.routeColor);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
exports.BlipService = BlipService;
|
|
213
|
+
exports.BlipService = BlipService = __decorate([
|
|
214
|
+
(0, tsyringe_1.injectable)()
|
|
215
|
+
], BlipService);
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./marker.service"), exports);
|
|
18
|
+
__exportStar(require("./blip.service"), exports);
|
|
19
|
+
__exportStar(require("./vehicle.service"), exports);
|
|
20
|
+
__exportStar(require("./ped.service"), exports);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Vector3 } from '../../../utils';
|
|
2
|
+
export interface MarkerOptions {
|
|
3
|
+
/** Marker type (0-43) */
|
|
4
|
+
type?: number;
|
|
5
|
+
/** Scale of the marker */
|
|
6
|
+
scale?: Vector3;
|
|
7
|
+
/** Rotation of the marker */
|
|
8
|
+
rotation?: Vector3;
|
|
9
|
+
/** Color (RGBA) */
|
|
10
|
+
color?: {
|
|
11
|
+
r: number;
|
|
12
|
+
g: number;
|
|
13
|
+
b: number;
|
|
14
|
+
a: number;
|
|
15
|
+
};
|
|
16
|
+
/** Whether the marker should bob up and down */
|
|
17
|
+
bobUpAndDown?: boolean;
|
|
18
|
+
/** Whether the marker should face the camera */
|
|
19
|
+
faceCamera?: boolean;
|
|
20
|
+
/** Whether the marker should rotate */
|
|
21
|
+
rotate?: boolean;
|
|
22
|
+
/** Draw on entities */
|
|
23
|
+
drawOnEnts?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface ManagedMarker {
|
|
26
|
+
id: string;
|
|
27
|
+
position: Vector3;
|
|
28
|
+
options: Required<MarkerOptions>;
|
|
29
|
+
visible: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Service for managing and rendering markers in the game world.
|
|
33
|
+
* Handles automatic rendering via tick.
|
|
34
|
+
*/
|
|
35
|
+
export declare class MarkerService {
|
|
36
|
+
private markers;
|
|
37
|
+
private tickHandle;
|
|
38
|
+
private idCounter;
|
|
39
|
+
/**
|
|
40
|
+
* Create a new managed marker.
|
|
41
|
+
*
|
|
42
|
+
* @param position - World position for the marker
|
|
43
|
+
* @param options - Marker appearance options
|
|
44
|
+
* @returns The marker ID
|
|
45
|
+
*/
|
|
46
|
+
create(position: Vector3, options?: MarkerOptions): string;
|
|
47
|
+
/**
|
|
48
|
+
* Remove a marker by ID.
|
|
49
|
+
*
|
|
50
|
+
* @param id - The marker ID to remove
|
|
51
|
+
*/
|
|
52
|
+
remove(id: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Remove all markers.
|
|
55
|
+
*/
|
|
56
|
+
removeAll(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Update a marker's position.
|
|
59
|
+
*
|
|
60
|
+
* @param id - The marker ID
|
|
61
|
+
* @param position - New position
|
|
62
|
+
*/
|
|
63
|
+
setPosition(id: string, position: Vector3): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Update marker options.
|
|
66
|
+
*
|
|
67
|
+
* @param id - The marker ID
|
|
68
|
+
* @param options - Options to update
|
|
69
|
+
*/
|
|
70
|
+
setOptions(id: string, options: Partial<MarkerOptions>): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Set marker visibility.
|
|
73
|
+
*
|
|
74
|
+
* @param id - The marker ID
|
|
75
|
+
* @param visible - Whether the marker should be visible
|
|
76
|
+
*/
|
|
77
|
+
setVisible(id: string, visible: boolean): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Get a marker by ID.
|
|
80
|
+
*/
|
|
81
|
+
get(id: string): ManagedMarker | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Get all managed markers.
|
|
84
|
+
*/
|
|
85
|
+
getAll(): ManagedMarker[];
|
|
86
|
+
/**
|
|
87
|
+
* Draw a marker immediately (one frame only).
|
|
88
|
+
* For persistent markers, use create() instead.
|
|
89
|
+
*/
|
|
90
|
+
drawOnce(position: Vector3, options?: MarkerOptions): void;
|
|
91
|
+
private ensureTickRunning;
|
|
92
|
+
private stopTick;
|
|
93
|
+
private checkTickNeeded;
|
|
94
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
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.MarkerService = void 0;
|
|
10
|
+
const tsyringe_1 = require("tsyringe");
|
|
11
|
+
const DEFAULT_OPTIONS = {
|
|
12
|
+
type: 1,
|
|
13
|
+
scale: { x: 1.0, y: 1.0, z: 1.0 },
|
|
14
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
15
|
+
color: { r: 255, g: 0, b: 0, a: 200 },
|
|
16
|
+
bobUpAndDown: false,
|
|
17
|
+
faceCamera: false,
|
|
18
|
+
rotate: false,
|
|
19
|
+
drawOnEnts: false,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Service for managing and rendering markers in the game world.
|
|
23
|
+
* Handles automatic rendering via tick.
|
|
24
|
+
*/
|
|
25
|
+
let MarkerService = class MarkerService {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.markers = new Map();
|
|
28
|
+
this.tickHandle = null;
|
|
29
|
+
this.idCounter = 0;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a new managed marker.
|
|
33
|
+
*
|
|
34
|
+
* @param position - World position for the marker
|
|
35
|
+
* @param options - Marker appearance options
|
|
36
|
+
* @returns The marker ID
|
|
37
|
+
*/
|
|
38
|
+
create(position, options = {}) {
|
|
39
|
+
const id = `marker_${++this.idCounter}`;
|
|
40
|
+
const marker = {
|
|
41
|
+
id,
|
|
42
|
+
position,
|
|
43
|
+
options: Object.assign(Object.assign({}, DEFAULT_OPTIONS), options),
|
|
44
|
+
visible: true,
|
|
45
|
+
};
|
|
46
|
+
this.markers.set(id, marker);
|
|
47
|
+
this.ensureTickRunning();
|
|
48
|
+
return id;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Remove a marker by ID.
|
|
52
|
+
*
|
|
53
|
+
* @param id - The marker ID to remove
|
|
54
|
+
*/
|
|
55
|
+
remove(id) {
|
|
56
|
+
const deleted = this.markers.delete(id);
|
|
57
|
+
this.checkTickNeeded();
|
|
58
|
+
return deleted;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Remove all markers.
|
|
62
|
+
*/
|
|
63
|
+
removeAll() {
|
|
64
|
+
this.markers.clear();
|
|
65
|
+
this.stopTick();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Update a marker's position.
|
|
69
|
+
*
|
|
70
|
+
* @param id - The marker ID
|
|
71
|
+
* @param position - New position
|
|
72
|
+
*/
|
|
73
|
+
setPosition(id, position) {
|
|
74
|
+
const marker = this.markers.get(id);
|
|
75
|
+
if (!marker)
|
|
76
|
+
return false;
|
|
77
|
+
marker.position = position;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Update marker options.
|
|
82
|
+
*
|
|
83
|
+
* @param id - The marker ID
|
|
84
|
+
* @param options - Options to update
|
|
85
|
+
*/
|
|
86
|
+
setOptions(id, options) {
|
|
87
|
+
const marker = this.markers.get(id);
|
|
88
|
+
if (!marker)
|
|
89
|
+
return false;
|
|
90
|
+
marker.options = Object.assign(Object.assign({}, marker.options), options);
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Set marker visibility.
|
|
95
|
+
*
|
|
96
|
+
* @param id - The marker ID
|
|
97
|
+
* @param visible - Whether the marker should be visible
|
|
98
|
+
*/
|
|
99
|
+
setVisible(id, visible) {
|
|
100
|
+
const marker = this.markers.get(id);
|
|
101
|
+
if (!marker)
|
|
102
|
+
return false;
|
|
103
|
+
marker.visible = visible;
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get a marker by ID.
|
|
108
|
+
*/
|
|
109
|
+
get(id) {
|
|
110
|
+
return this.markers.get(id);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get all managed markers.
|
|
114
|
+
*/
|
|
115
|
+
getAll() {
|
|
116
|
+
return Array.from(this.markers.values());
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Draw a marker immediately (one frame only).
|
|
120
|
+
* For persistent markers, use create() instead.
|
|
121
|
+
*/
|
|
122
|
+
drawOnce(position, options = {}) {
|
|
123
|
+
const opts = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
124
|
+
DrawMarker(opts.type, position.x, position.y, position.z, 0, 0, 0, opts.rotation.x, opts.rotation.y, opts.rotation.z, opts.scale.x, opts.scale.y, opts.scale.z, opts.color.r, opts.color.g, opts.color.b, opts.color.a, opts.bobUpAndDown, opts.faceCamera, 2, opts.rotate, null, null, opts.drawOnEnts);
|
|
125
|
+
}
|
|
126
|
+
ensureTickRunning() {
|
|
127
|
+
if (this.tickHandle !== null)
|
|
128
|
+
return;
|
|
129
|
+
this.tickHandle = setTick(() => {
|
|
130
|
+
for (const marker of this.markers.values()) {
|
|
131
|
+
if (!marker.visible)
|
|
132
|
+
continue;
|
|
133
|
+
const { position, options } = marker;
|
|
134
|
+
DrawMarker(options.type, position.x, position.y, position.z, 0, 0, 0, options.rotation.x, options.rotation.y, options.rotation.z, options.scale.x, options.scale.y, options.scale.z, options.color.r, options.color.g, options.color.b, options.color.a, options.bobUpAndDown, options.faceCamera, 2, options.rotate, null, null, options.drawOnEnts);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
stopTick() {
|
|
139
|
+
if (this.tickHandle !== null) {
|
|
140
|
+
clearTick(this.tickHandle);
|
|
141
|
+
this.tickHandle = null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
checkTickNeeded() {
|
|
145
|
+
if (this.markers.size === 0) {
|
|
146
|
+
this.stopTick();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
exports.MarkerService = MarkerService;
|
|
151
|
+
exports.MarkerService = MarkerService = __decorate([
|
|
152
|
+
(0, tsyringe_1.injectable)()
|
|
153
|
+
], MarkerService);
|