@nativewrappers/redm 0.0.147 → 0.0.156
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/common/decors/Proto.d.ts +1 -5
- package/common/decors/Proto.js +1 -1
- package/common/utils/randomInt.d.ts +1 -0
- package/common/utils/randomInt.js +6 -1
- package/entities/Pickup.d.ts +1 -0
- package/entities/Pickup.js +3 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/world/getGamePool.d.ts +16 -0
- package/world/getGamePool.js +32 -0
package/common/decors/Proto.d.ts
CHANGED
|
@@ -7,16 +7,12 @@ export type MessageTypeEncoder<T> = {
|
|
|
7
7
|
name: string;
|
|
8
8
|
};
|
|
9
9
|
type ProtoCallback<Message> = (message: Message) => Promise<void> | void;
|
|
10
|
-
type NetProtoCallback<Message> = (
|
|
10
|
+
type NetProtoCallback<Message> = (message: Message, source: number) => Promise<void> | void;
|
|
11
11
|
/**
|
|
12
12
|
* PMA uses ts-proto to define our types, you can see that here: https://github.com/stephenh/ts-proto
|
|
13
13
|
* You will have to modify the generator to add `name` or just use {@param eventName}
|
|
14
14
|
*
|
|
15
|
-
* We use this:
|
|
16
|
-
* content = content.replace(/export const (\w+)[^=]*= \{/g, 'export const $1 = {\n name: "$1" as const,');
|
|
17
|
-
*
|
|
18
15
|
* This makes it very nice to handle events since we only have to give it the Protobuf Object
|
|
19
|
-
*
|
|
20
16
|
*/
|
|
21
17
|
export declare function OnProto<T>(messageType: MessageTypeDecoder<T>, eventName?: string): (originalMethod: ProtoCallback<T>, context: ClassMethodDecoratorContext) => void;
|
|
22
18
|
/**
|
package/common/decors/Proto.js
CHANGED
|
@@ -35,7 +35,7 @@ function OnProtoNet(messageType, eventName) {
|
|
|
35
35
|
Net.onRawNet(event, async (data, source) => {
|
|
36
36
|
try {
|
|
37
37
|
const message = messageType.decode(data);
|
|
38
|
-
return await originalMethod.call(this, parseSource(source)
|
|
38
|
+
return await originalMethod.call(this, message, parseSource(source));
|
|
39
39
|
} catch (e) {
|
|
40
40
|
globalThis.printError?.("proto event", e);
|
|
41
41
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
function
|
|
3
|
+
function randomFloat(min, max) {
|
|
4
4
|
return Math.random() * (max - min) + min;
|
|
5
5
|
}
|
|
6
|
+
__name(randomFloat, "randomFloat");
|
|
7
|
+
function randomInt(min, max) {
|
|
8
|
+
return Math.floor(randomFloat(min, max));
|
|
9
|
+
}
|
|
6
10
|
__name(randomInt, "randomInt");
|
|
7
11
|
export {
|
|
12
|
+
randomFloat,
|
|
8
13
|
randomInt
|
|
9
14
|
};
|
package/entities/Pickup.d.ts
CHANGED
package/entities/Pickup.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./world/createDraftVehicle";
|
|
|
15
15
|
export * from "./world/createPed";
|
|
16
16
|
export * from "./world/createProp";
|
|
17
17
|
export * from "./world/createVehicle";
|
|
18
|
+
export * from "./world/getGamePool";
|
|
18
19
|
export * from "./utils/Animations";
|
|
19
20
|
export * from "./utils/Native";
|
|
20
21
|
export * from "./types/Throwable";
|
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./world/createDraftVehicle";
|
|
|
15
15
|
export * from "./world/createPed";
|
|
16
16
|
export * from "./world/createProp";
|
|
17
17
|
export * from "./world/createVehicle";
|
|
18
|
+
export * from "./world/getGamePool";
|
|
18
19
|
export * from "./utils/Animations";
|
|
19
20
|
export * from "./utils/Native";
|
|
20
21
|
export * from "./types/Throwable";
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Ped } from "../entities/Ped";
|
|
2
|
+
import { Pickup } from "../entities/Pickup";
|
|
3
|
+
import { Prop } from "../entities/Prop";
|
|
4
|
+
import { Vehicle } from "../entities/Vehicle";
|
|
5
|
+
declare const constructorMap: {
|
|
6
|
+
CObject: typeof Prop;
|
|
7
|
+
CPed: typeof Ped;
|
|
8
|
+
CVehicle: typeof Vehicle;
|
|
9
|
+
CPickup: typeof Pickup;
|
|
10
|
+
CNetObject: typeof Prop;
|
|
11
|
+
};
|
|
12
|
+
type PoolTypeMap = {
|
|
13
|
+
[K in keyof typeof constructorMap]: InstanceType<(typeof constructorMap)[K]>;
|
|
14
|
+
};
|
|
15
|
+
export declare function getGamePool<T extends keyof typeof constructorMap>(type: T, networkOnly?: boolean): PoolTypeMap[T][];
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { Ped } from "../entities/Ped";
|
|
4
|
+
import { Pickup } from "../entities/Pickup";
|
|
5
|
+
import { Prop } from "../entities/Prop";
|
|
6
|
+
import { Vehicle } from "../entities/Vehicle";
|
|
7
|
+
const constructorMap = {
|
|
8
|
+
CObject: Prop,
|
|
9
|
+
CPed: Ped,
|
|
10
|
+
CVehicle: Vehicle,
|
|
11
|
+
CPickup: Pickup,
|
|
12
|
+
CNetObject: Prop
|
|
13
|
+
};
|
|
14
|
+
function getGamePool(type, networkOnly = false) {
|
|
15
|
+
const pool = GetGamePool(type);
|
|
16
|
+
const entityConstructor = constructorMap[type];
|
|
17
|
+
let poolMap = pool.map((v) => {
|
|
18
|
+
const p = new entityConstructor(v);
|
|
19
|
+
if (networkOnly && !p.IsNetworked) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return p;
|
|
23
|
+
});
|
|
24
|
+
if (networkOnly) {
|
|
25
|
+
poolMap = poolMap.filter((v) => v !== null);
|
|
26
|
+
}
|
|
27
|
+
return poolMap;
|
|
28
|
+
}
|
|
29
|
+
__name(getGamePool, "getGamePool");
|
|
30
|
+
export {
|
|
31
|
+
getGamePool
|
|
32
|
+
};
|