@open-core/framework 1.0.5-beta.2 → 1.0.5
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/dist/adapters/contracts/IEngineEvents.d.ts +3 -3
- package/dist/adapters/contracts/IExports.d.ts +2 -2
- package/dist/adapters/contracts/client/IClientLocalPlayerBridge.d.ts +21 -0
- package/dist/adapters/contracts/client/IClientLocalPlayerBridge.js +6 -0
- package/dist/adapters/contracts/client/IClientRuntimeBridge.d.ts +5 -5
- package/dist/adapters/contracts/client/camera/IClientCameraPort.d.ts +107 -0
- package/dist/adapters/contracts/client/camera/IClientCameraPort.js +8 -0
- package/dist/adapters/contracts/client/camera/index.d.ts +1 -0
- package/dist/adapters/contracts/client/camera/index.js +1 -0
- package/dist/adapters/contracts/client/index.d.ts +4 -0
- package/dist/adapters/contracts/client/index.js +4 -0
- package/dist/adapters/contracts/client/ped/IClientPedPort.d.ts +62 -0
- package/dist/adapters/contracts/client/ped/IClientPedPort.js +5 -0
- package/dist/adapters/contracts/client/ped/index.d.ts +1 -0
- package/dist/adapters/contracts/client/ped/index.js +1 -0
- package/dist/adapters/contracts/client/progress/IClientProgressPort.d.ts +53 -0
- package/dist/adapters/contracts/client/progress/IClientProgressPort.js +8 -0
- package/dist/adapters/contracts/client/progress/index.d.ts +1 -0
- package/dist/adapters/contracts/client/progress/index.js +1 -0
- package/dist/adapters/contracts/client/spawn/IClientSpawnBridge.d.ts +5 -6
- package/dist/adapters/contracts/client/spawn/IClientSpawnBridge.js +5 -1
- package/dist/adapters/contracts/client/spawn/IClientSpawnPort.d.ts +19 -0
- package/dist/adapters/contracts/client/spawn/IClientSpawnPort.js +2 -0
- package/dist/adapters/contracts/client/spawn/index.d.ts +2 -0
- package/dist/adapters/contracts/client/spawn/index.js +2 -0
- package/dist/adapters/contracts/client/spawn/types.d.ts +3 -0
- package/dist/adapters/contracts/client/ui/webview/IClientWebViewBridge.d.ts +1 -0
- package/dist/adapters/contracts/client/ui/webview/types.d.ts +2 -0
- package/dist/adapters/contracts/client/vehicle/IClientVehiclePort.d.ts +166 -0
- package/dist/adapters/contracts/client/vehicle/IClientVehiclePort.js +8 -0
- package/dist/adapters/contracts/client/vehicle/index.d.ts +1 -0
- package/dist/adapters/contracts/client/vehicle/index.js +1 -0
- package/dist/adapters/contracts/transport/events.api.d.ts +3 -3
- package/dist/adapters/contracts/transport/rpc.api.d.ts +3 -3
- package/dist/adapters/node/transport/node.events.d.ts +4 -4
- package/dist/adapters/node/transport/node.rpc.d.ts +3 -3
- package/dist/adapters/node/transport/node.rpc.js +1 -1
- package/dist/contracts.d.ts +1 -0
- package/dist/contracts.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/kernel/logger/client-log-console.js +8 -8
- package/dist/kernel/logger/index.d.ts +1 -1
- package/dist/kernel/logger/index.js +1 -1
- package/dist/kernel/logger/logger.types.d.ts +1 -0
- package/dist/kernel/logger/logger.types.js +35 -0
- package/dist/kernel/logger/transports/buffered.transport.js +4 -4
- package/dist/kernel/logger/transports/console.transport.js +2 -2
- package/dist/kernel/logger/transports/simple-console.transport.js +2 -2
- package/dist/runtime/client/adapter/index.d.ts +5 -0
- package/dist/runtime/client/adapter/index.js +5 -0
- package/dist/runtime/client/adapter/node-camera-port.d.ts +19 -0
- package/dist/runtime/client/adapter/node-camera-port.js +31 -0
- package/dist/runtime/client/adapter/node-client-adapter.js +15 -1
- package/dist/runtime/client/adapter/node-local-player-bridge.d.ts +3 -0
- package/dist/runtime/client/adapter/node-local-player-bridge.js +9 -0
- package/dist/runtime/client/adapter/node-log-console.js +8 -8
- package/dist/runtime/client/adapter/node-ped-port.d.ts +20 -0
- package/dist/runtime/client/adapter/node-ped-port.js +38 -0
- package/dist/runtime/client/adapter/node-progress-port.d.ts +8 -0
- package/dist/runtime/client/adapter/node-progress-port.js +27 -0
- package/dist/runtime/client/adapter/node-runtime-bridge.d.ts +2 -4
- package/dist/runtime/client/adapter/node-spawn-bridge.d.ts +5 -5
- package/dist/runtime/client/adapter/node-spawn-bridge.js +8 -4
- package/dist/runtime/client/adapter/node-vehicle-port.d.ts +31 -0
- package/dist/runtime/client/adapter/node-vehicle-port.js +73 -0
- package/dist/runtime/client/adapter/node-webview-bridge.d.ts +1 -0
- package/dist/runtime/client/adapter/node-webview-bridge.js +2 -0
- package/dist/runtime/client/controllers/appearance.controller.d.ts +3 -3
- package/dist/runtime/client/controllers/appearance.controller.js +11 -10
- package/dist/runtime/client/controllers/spawner.controller.js +4 -3
- package/dist/runtime/client/services/camera.d.ts +4 -26
- package/dist/runtime/client/services/camera.js +21 -27
- package/dist/runtime/client/services/notification.service.d.ts +3 -3
- package/dist/runtime/client/services/notification.service.js +7 -7
- package/dist/runtime/client/services/ped.service.d.ts +6 -21
- package/dist/runtime/client/services/ped.service.js +31 -78
- package/dist/runtime/client/services/progress.service.d.ts +4 -50
- package/dist/runtime/client/services/progress.service.js +11 -143
- package/dist/runtime/client/services/session-bridge.service.js +3 -2
- package/dist/runtime/client/services/spawn.service.d.ts +3 -5
- package/dist/runtime/client/services/spawn.service.js +12 -17
- package/dist/runtime/client/services/vehicle-client.service.d.ts +3 -3
- package/dist/runtime/client/services/vehicle-client.service.js +43 -143
- package/dist/runtime/client/services/vehicle.service.d.ts +4 -41
- package/dist/runtime/client/services/vehicle.service.js +24 -130
- package/dist/runtime/client/webview-bridge.d.ts +3 -0
- package/dist/runtime/client/webview-bridge.js +6 -0
- package/dist/runtime/client/webview.service.d.ts +1 -0
- package/dist/runtime/client/webview.service.js +5 -0
- package/dist/runtime/server/adapter/node-player-appearance-lifecycle-server.js +3 -2
- package/dist/runtime/server/adapter/node-player-lifecycle-server.js +4 -3
- package/dist/runtime/server/adapter/node-vehicle-lifecycle-server.js +2 -1
- package/dist/runtime/server/apis/chat.api.js +6 -5
- package/dist/runtime/server/apis/npcs.api.js +2 -1
- package/dist/runtime/server/apis/parallel-compute.api.js +1 -0
- package/dist/runtime/server/apis/vehicle-modification.api.js +6 -4
- package/dist/runtime/server/apis/vehicles.api.js +7 -4
- package/dist/runtime/server/bootstrap.js +13 -12
- package/dist/runtime/server/controllers/command-export.controller.js +4 -2
- package/dist/runtime/server/controllers/remote-command-execution.controller.js +2 -1
- package/dist/runtime/server/controllers/vehicle.controller.js +6 -5
- package/dist/runtime/server/decorators/command.d.ts +2 -0
- package/dist/runtime/server/decorators/command.js +3 -1
- package/dist/runtime/server/entities/npc.d.ts +1 -1
- package/dist/runtime/server/entities/player.d.ts +1 -1
- package/dist/runtime/server/entities/player.js +10 -3
- package/dist/runtime/server/helpers/command-validation.helper.js +20 -7
- package/dist/runtime/server/helpers/function-helper.d.ts +1 -0
- package/dist/runtime/server/helpers/function-helper.js +15 -8
- package/dist/runtime/server/implementations/local/channel.local.d.ts +1 -1
- package/dist/runtime/server/implementations/local/channel.local.js +3 -2
- package/dist/runtime/server/ports/channel.api-port.d.ts +1 -1
- package/dist/runtime/server/services/parallel/worker-pool.d.ts +1 -1
- package/dist/runtime/server/services/parallel/worker-pool.js +38 -6
- package/dist/runtime/server/services/parallel/worker.js +1 -0
- package/dist/runtime/server/system/schema-generator.d.ts +1 -1
- package/dist/runtime/server/system/schema-generator.js +6 -3
- package/dist/runtime/shared/helpers/process-tuple-schema.js +3 -0
- package/dist/runtime/shared/types/system-types.d.ts +55 -0
- package/dist/runtime/shared/types/system-types.js +54 -0
- package/package.json +21 -11
|
@@ -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 {
|
|
14
|
+
import { IClientPedPort, } from '../../../adapters/contracts/client/ped/IClientPedPort';
|
|
15
|
+
import { IClientLocalPlayerBridge } from '../adapter/local-player-bridge';
|
|
15
16
|
let PedService = class PedService {
|
|
16
|
-
|
|
17
|
+
pedsPort;
|
|
18
|
+
localPlayer;
|
|
17
19
|
peds = new Map();
|
|
18
20
|
idCounter = 0;
|
|
19
|
-
constructor(
|
|
20
|
-
this.
|
|
21
|
+
constructor(pedsPort, localPlayer) {
|
|
22
|
+
this.pedsPort = pedsPort;
|
|
23
|
+
this.localPlayer = localPlayer;
|
|
21
24
|
}
|
|
22
25
|
async spawn(options) {
|
|
23
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
89
|
-
return;
|
|
90
|
-
this.platform.clearPedTasks(handle);
|
|
60
|
+
this.pedsPort.stopAnimation(handle);
|
|
91
61
|
}
|
|
92
62
|
stopAnimationImmediately(handle) {
|
|
93
|
-
|
|
94
|
-
return;
|
|
95
|
-
this.platform.clearPedTasksImmediately(handle);
|
|
63
|
+
this.pedsPort.stopAnimationImmediately(handle);
|
|
96
64
|
}
|
|
97
65
|
freeze(handle, freeze) {
|
|
98
|
-
|
|
99
|
-
return;
|
|
100
|
-
this.platform.freezeEntityPosition(handle, freeze);
|
|
66
|
+
this.pedsPort.freeze(handle, freeze);
|
|
101
67
|
}
|
|
102
68
|
setInvincible(handle, invincible) {
|
|
103
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
119
|
-
const handle = this.
|
|
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.
|
|
87
|
+
return this.pedsPort.getNearby(position, radius, excludePlayer ? this.localPlayer.getHandle() : undefined);
|
|
128
88
|
}
|
|
129
89
|
lookAtEntity(handle, entity, duration = -1) {
|
|
130
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
109
|
+
return ped ? this.pedsPort.exists(ped.handle) : false;
|
|
159
110
|
}
|
|
160
111
|
};
|
|
161
112
|
PedService = __decorate([
|
|
162
113
|
injectable(),
|
|
163
|
-
__param(0, inject(
|
|
164
|
-
|
|
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 {
|
|
2
|
-
|
|
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
|
|
41
|
-
|
|
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 {
|
|
15
|
-
import { IClientRuntimeBridge } from '../adapter/runtime-bridge';
|
|
14
|
+
import { IClientProgressPort, } from '../../../adapters/contracts/client/progress/IClientProgressPort';
|
|
16
15
|
let ProgressService = class ProgressService {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
|
|
45
|
-
return;
|
|
46
|
-
this.cleanup(false);
|
|
24
|
+
this.progressPort.cancel();
|
|
47
25
|
}
|
|
48
26
|
isActive() {
|
|
49
|
-
return this.
|
|
27
|
+
return this.progressPort.isActive();
|
|
50
28
|
}
|
|
51
29
|
getProgress() {
|
|
52
|
-
return this.
|
|
30
|
+
return this.progressPort.getProgress();
|
|
53
31
|
}
|
|
54
32
|
getState() {
|
|
55
|
-
return this.
|
|
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(
|
|
169
|
-
|
|
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(
|
|
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(
|
|
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
|
}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { PlayerAppearance } from '../../../kernel';
|
|
2
2
|
import { Vector3 } from '../../../kernel/utils/vector3';
|
|
3
|
-
import { IClientPlatformBridge } from '../adapter/platform-bridge';
|
|
4
3
|
import { AppearanceService } from './appearance.service';
|
|
5
|
-
import {
|
|
4
|
+
import { IClientSpawnPort } from '../../../adapters/contracts/client/spawn/IClientSpawnPort';
|
|
6
5
|
interface SpawnOptions {
|
|
7
6
|
appearance?: PlayerAppearance;
|
|
8
7
|
}
|
|
9
8
|
export declare class SpawnService {
|
|
10
9
|
private readonly appearanceService;
|
|
11
|
-
private readonly
|
|
12
|
-
private readonly platform;
|
|
10
|
+
private readonly spawnPort;
|
|
13
11
|
private spawned;
|
|
14
12
|
private spawning;
|
|
15
|
-
constructor(appearanceService: AppearanceService,
|
|
13
|
+
constructor(appearanceService: AppearanceService, spawnPort: IClientSpawnPort);
|
|
16
14
|
init(): Promise<void>;
|
|
17
15
|
spawn(position: Vector3, model: string, heading?: number, options?: SpawnOptions): Promise<void>;
|
|
18
16
|
teleportTo(position: Vector3, heading?: number): Promise<void>;
|
|
@@ -12,19 +12,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
import { inject, injectable } from 'tsyringe';
|
|
14
14
|
import { loggers } from '../../../kernel';
|
|
15
|
-
import { IClientPlatformBridge } from '../adapter/platform-bridge';
|
|
16
15
|
import { AppearanceService } from './appearance.service';
|
|
17
|
-
import {
|
|
16
|
+
import { IClientSpawnPort } from '../../../adapters/contracts/client/spawn/IClientSpawnPort';
|
|
18
17
|
let SpawnService = class SpawnService {
|
|
19
18
|
appearanceService;
|
|
20
|
-
|
|
21
|
-
platform;
|
|
19
|
+
spawnPort;
|
|
22
20
|
spawned = false;
|
|
23
21
|
spawning = false;
|
|
24
|
-
constructor(appearanceService,
|
|
22
|
+
constructor(appearanceService, spawnPort) {
|
|
25
23
|
this.appearanceService = appearanceService;
|
|
26
|
-
this.
|
|
27
|
-
this.platform = platform;
|
|
24
|
+
this.spawnPort = spawnPort;
|
|
28
25
|
}
|
|
29
26
|
async init() {
|
|
30
27
|
loggers.spawn.debug('SpawnService initialized');
|
|
@@ -37,10 +34,10 @@ let SpawnService = class SpawnService {
|
|
|
37
34
|
this.spawning = true;
|
|
38
35
|
try {
|
|
39
36
|
loggers.spawn.debug('Waiting for spawn bridge readiness');
|
|
40
|
-
await this.
|
|
37
|
+
await this.spawnPort.waitUntilReady();
|
|
41
38
|
loggers.spawn.debug('Spawn bridge ready, executing spawn', { position, model, heading });
|
|
42
|
-
await this.
|
|
43
|
-
const ped =
|
|
39
|
+
const outcome = await this.spawnPort.spawn({ position, model, heading });
|
|
40
|
+
const ped = outcome.localPlayerHandle ?? 0;
|
|
44
41
|
if (ped !== 0) {
|
|
45
42
|
if (options?.appearance) {
|
|
46
43
|
loggers.spawn.debug('Applying post-spawn appearance', { ped });
|
|
@@ -67,11 +64,11 @@ let SpawnService = class SpawnService {
|
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
66
|
async teleportTo(position, heading) {
|
|
70
|
-
await this.
|
|
67
|
+
await this.spawnPort.teleport({ position, heading });
|
|
71
68
|
}
|
|
72
69
|
async respawn(position, heading = 0.0) {
|
|
73
|
-
await this.
|
|
74
|
-
await this.
|
|
70
|
+
await this.spawnPort.waitUntilReady();
|
|
71
|
+
await this.spawnPort.respawn({ position, heading });
|
|
75
72
|
this.spawned = true;
|
|
76
73
|
loggers.spawn.info('Player respawned', {
|
|
77
74
|
position: { x: position.x, y: position.y, z: position.z },
|
|
@@ -89,10 +86,8 @@ let SpawnService = class SpawnService {
|
|
|
89
86
|
};
|
|
90
87
|
SpawnService = __decorate([
|
|
91
88
|
injectable(),
|
|
92
|
-
__param(1, inject(
|
|
93
|
-
__param(2, inject(IClientPlatformBridge)),
|
|
89
|
+
__param(1, inject(IClientSpawnPort)),
|
|
94
90
|
__metadata("design:paramtypes", [AppearanceService,
|
|
95
|
-
|
|
96
|
-
IClientPlatformBridge])
|
|
91
|
+
IClientSpawnPort])
|
|
97
92
|
], SpawnService);
|
|
98
93
|
export { SpawnService };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { IClientVehiclePort } from '../../../adapters/contracts/client/vehicle/IClientVehiclePort';
|
|
1
2
|
import { EventsAPI } from '../../../adapters/contracts/transport/events.api';
|
|
2
3
|
import { Vector3 } from '../../../kernel/utils/vector3';
|
|
3
|
-
import { IClientPlatformBridge } from '../adapter/platform-bridge';
|
|
4
4
|
import { IClientRuntimeBridge } from '../adapter/runtime-bridge';
|
|
5
5
|
import { SerializedVehicleData, VehicleCreateOptions, VehicleSpawnResult } from '../../server/types/vehicle.types';
|
|
6
6
|
export declare class VehicleClientService {
|
|
7
7
|
private readonly events;
|
|
8
|
-
private readonly
|
|
8
|
+
private readonly vehicles;
|
|
9
9
|
private readonly runtime;
|
|
10
10
|
private pendingCreations;
|
|
11
11
|
private pendingDeletes;
|
|
@@ -13,7 +13,7 @@ export declare class VehicleClientService {
|
|
|
13
13
|
private pendingData;
|
|
14
14
|
private pendingPlayerVehicles;
|
|
15
15
|
private requestIdCounter;
|
|
16
|
-
constructor(events: EventsAPI<'client'>,
|
|
16
|
+
constructor(events: EventsAPI<'client'>, vehicles: IClientVehiclePort, runtime: IClientRuntimeBridge);
|
|
17
17
|
createVehicle(options: Omit<VehicleCreateOptions, 'ownership'>): Promise<VehicleSpawnResult>;
|
|
18
18
|
deleteVehicle(networkId: number): Promise<boolean>;
|
|
19
19
|
repairVehicle(networkId: number): Promise<boolean>;
|