@nativewrappers/common 0.0.131 → 0.0.132
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/index.d.ts +1 -52
- package/index.js +1 -52
- package/package.json +1 -1
- package/common-game/CommonGameConstants.d.ts +0 -7
- package/common-game/CommonGameConstants.js +0 -24
- package/common-game/CommonModel.d.ts +0 -99
- package/common-game/CommonModel.js +0 -172
- package/common-game/CommonTasks.d.ts +0 -44
- package/common-game/CommonTasks.js +0 -233
- package/common-game/cfx/StateBagChangeHandler.d.ts +0 -1
- package/common-game/cfx/StateBagChangeHandler.js +0 -0
- package/common-game/cfx/cfx.d.ts +0 -6
- package/common-game/cfx/cfx.js +0 -4
- package/common-game/common/Command.d.ts +0 -77
- package/common-game/common/Command.js +0 -152
- package/common-game/common/Convar.d.ts +0 -13
- package/common-game/common/Convar.js +0 -58
- package/common-game/common/GlobalData.d.ts +0 -12
- package/common-game/common/GlobalData.js +0 -20
- package/common-game/common/Kvp.d.ts +0 -69
- package/common-game/common/Kvp.js +0 -137
- package/common-game/common/Resource.d.ts +0 -14
- package/common-game/common/Resource.js +0 -54
- package/common-game/common/decors/ConVar.d.ts +0 -14
- package/common-game/common/decors/ConVar.js +0 -70
- package/common-game/common/decors/Events.d.ts +0 -66
- package/common-game/common/decors/Events.js +0 -163
- package/common-game/common/decors/Exports.d.ts +0 -1
- package/common-game/common/decors/Exports.js +0 -53
- package/common-game/common/decors/Permissions.d.ts +0 -3
- package/common-game/common/decors/Permissions.js +0 -49
- package/common-game/common/decors/Resources.d.ts +0 -8
- package/common-game/common/decors/Resources.js +0 -94
- package/common-game/common/decors/Ticks.d.ts +0 -9
- package/common-game/common/decors/Ticks.js +0 -32
- package/common-game/common/net/NetworkedMap.d.ts +0 -28
- package/common-game/common/net/NetworkedMap.js +0 -262
- package/common-game/common/types.d.ts +0 -5
- package/common-game/common/types.js +0 -0
- package/common-game/common/utils/ClassTypes.d.ts +0 -11
- package/common-game/common/utils/ClassTypes.js +0 -15
- package/common-game/common/utils/Color.d.ts +0 -14
- package/common-game/common/utils/Color.js +0 -33
- package/common-game/common/utils/Delay.d.ts +0 -1
- package/common-game/common/utils/Delay.js +0 -6
- package/common-game/common/utils/Maths.d.ts +0 -4
- package/common-game/common/utils/Maths.js +0 -18
- package/common-game/common/utils/Point.d.ts +0 -9
- package/common-game/common/utils/Point.js +0 -36
- package/common-game/common/utils/PointF.d.ts +0 -7
- package/common-game/common/utils/PointF.js +0 -18
- package/common-game/common/utils/Quaternion.d.ts +0 -10
- package/common-game/common/utils/Quaternion.js +0 -33
- package/common-game/common/utils/Vector.d.ts +0 -429
- package/common-game/common/utils/Vector.js +0 -589
- package/common-game/common/utils/cleanPlayerName.d.ts +0 -6
- package/common-game/common/utils/cleanPlayerName.js +0 -17
- package/common-game/common/utils/enumValues.d.ts +0 -12
- package/common-game/common/utils/enumValues.js +0 -20
- package/common-game/common/utils/getStringFromUInt8Array.d.ts +0 -8
- package/common-game/common/utils/getStringFromUInt8Array.js +0 -6
- package/common-game/common/utils/getUInt32FromUint8Array.d.ts +0 -8
- package/common-game/common/utils/getUInt32FromUint8Array.js +0 -6
- package/common-game/common/utils/randomInt.d.ts +0 -1
- package/common-game/common/utils/randomInt.js +0 -9
- package/common-game/definitions/index.d.js +0 -0
- package/common-game/definitions/redm.d.js +0 -0
- package/common-game/entities/CommonBaseEntity.d.ts +0 -116
- package/common-game/entities/CommonBaseEntity.js +0 -266
- package/common-game/entities/CommonBaseEntityBone.d.ts +0 -11
- package/common-game/entities/CommonBaseEntityBone.js +0 -32
- package/common-game/entities/CommonBaseEntityBoneCollection.d.ts +0 -9
- package/common-game/entities/CommonBaseEntityBoneCollection.js +0 -17
- package/common-game/entities/CommonEntityBone.d.ts +0 -5
- package/common-game/entities/CommonEntityBone.js +0 -14
- package/common-game/entities/CommonEntityBoneCollection.d.ts +0 -9
- package/common-game/entities/CommonEntityBoneCollection.js +0 -24
- package/common-game/entities/CommonEntityType.d.ts +0 -4
- package/common-game/entities/CommonEntityType.js +0 -0
- package/common-game/entities/CommonPed.d.ts +0 -16
- package/common-game/entities/CommonPed.js +0 -52
- package/common-game/entities/CommonPedBone.d.ts +0 -6
- package/common-game/entities/CommonPedBone.js +0 -17
- package/common-game/entities/CommonPedBoneCollection.d.ts +0 -10
- package/common-game/entities/CommonPedBoneCollection.js +0 -31
- package/common-game/entities/CommonPlayer.d.ts +0 -61
- package/common-game/entities/CommonPlayer.js +0 -156
- package/common-game/entities/CommonProp.d.ts +0 -15
- package/common-game/entities/CommonProp.js +0 -43
- package/common-game/entities/CommonVehicle.d.ts +0 -11
- package/common-game/entities/CommonVehicle.js +0 -36
- package/common-game/entities/GetEntityClassIdFromHandle.d.ts +0 -2
- package/common-game/entities/GetEntityClassIdFromHandle.js +0 -23
- package/common-game/entities/IHandle.d.ts +0 -6
- package/common-game/entities/IHandle.js +0 -20
- package/common-game/enums/VehicleSeat.d.ts +0 -13
- package/common-game/enums/VehicleSeat.js +0 -17
- package/common-game/index.d.ts +0 -50
- package/common-game/index.js +0 -50
- package/common-game/interfaces/Dimension.d.ts +0 -5
- package/common-game/interfaces/Dimension.js +0 -0
- package/common-game/utils/Animations.d.ts +0 -19
- package/common-game/utils/Animations.js +0 -43
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { Event } from "./Events";
|
|
4
|
-
class ResourceWrapper {
|
|
5
|
-
static {
|
|
6
|
-
__name(this, "ResourceWrapper");
|
|
7
|
-
}
|
|
8
|
-
#on_resource_start = /* @__PURE__ */ new Map();
|
|
9
|
-
#on_resource_stop = /* @__PURE__ */ new Map();
|
|
10
|
-
#add_or_init(resource_fn_map, resource_name, fn) {
|
|
11
|
-
const fn_array = resource_fn_map.get(resource_name);
|
|
12
|
-
if (fn_array) {
|
|
13
|
-
fn_array.push(fn);
|
|
14
|
-
} else {
|
|
15
|
-
resource_fn_map.set(resource_name, [fn]);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Adds a function to get called whenever a resource is started
|
|
20
|
-
* @param resource_name The resource name to add to the start listener.
|
|
21
|
-
* @param fn The function to call
|
|
22
|
-
*/
|
|
23
|
-
add_to_resource_start(resource_name, fn) {
|
|
24
|
-
this.#add_or_init(this.#on_resource_start, resource_name, fn);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Adds a function to get called whenever a resource is stopped
|
|
28
|
-
* @param resource_name The resource name to add to the stop listener.
|
|
29
|
-
* @param fn The function to call
|
|
30
|
-
*/
|
|
31
|
-
add_to_resource_stop(resource_name, fn) {
|
|
32
|
-
this.#add_or_init(this.#on_resource_stop, resource_name, fn);
|
|
33
|
-
}
|
|
34
|
-
#call_for_resource(resource_fn_map, resource_name) {
|
|
35
|
-
const functions = resource_fn_map.get(resource_name);
|
|
36
|
-
if (functions) {
|
|
37
|
-
for (const fn of functions) {
|
|
38
|
-
fn();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
@Event("onResourceStart")
|
|
43
|
-
on_resource_start(resource_name) {
|
|
44
|
-
this.#call_for_resource(this.#on_resource_start, resource_name);
|
|
45
|
-
}
|
|
46
|
-
@Event("onResourceStop")
|
|
47
|
-
on_resource_stop(resource_name) {
|
|
48
|
-
this.#call_for_resource(this.#on_resource_stop, resource_name);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (!globalThis.RESOURCE_WRAPPER) {
|
|
52
|
-
globalThis.RESOURCE_WRAPPER = new ResourceWrapper();
|
|
53
|
-
}
|
|
54
|
-
const RESOURCE_WRAPPER = globalThis.RESOURCE_WRAPPER;
|
|
55
|
-
const onResourceStart = /* @__PURE__ */ __name((resource, originalMethod) => {
|
|
56
|
-
if (GetResourceState(resource) === "started") {
|
|
57
|
-
setImmediate(() => originalMethod.call());
|
|
58
|
-
}
|
|
59
|
-
RESOURCE_WRAPPER.add_to_resource_start(resource, originalMethod);
|
|
60
|
-
}, "onResourceStart");
|
|
61
|
-
function OnResourceStart(resource = GetCurrentResourceName()) {
|
|
62
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
63
|
-
if (context.private) {
|
|
64
|
-
throw new Error("OnResourceStart does not work on private types, please mark the field as public");
|
|
65
|
-
}
|
|
66
|
-
if (context.static) {
|
|
67
|
-
onResourceStart(resource, originalMethod);
|
|
68
|
-
} else {
|
|
69
|
-
context.addInitializer(function() {
|
|
70
|
-
onResourceStart(resource, originalMethod.bind(this));
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}, "actualDecorator");
|
|
74
|
-
}
|
|
75
|
-
__name(OnResourceStart, "OnResourceStart");
|
|
76
|
-
function OnResourceStop(resource = GetCurrentResourceName()) {
|
|
77
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
78
|
-
if (context.private) {
|
|
79
|
-
throw new Error("OnResourceStop does not work on private types, please mark the field as public");
|
|
80
|
-
}
|
|
81
|
-
if (context.static) {
|
|
82
|
-
RESOURCE_WRAPPER.add_to_resource_stop(resource, originalMethod);
|
|
83
|
-
} else {
|
|
84
|
-
context.addInitializer(function() {
|
|
85
|
-
RESOURCE_WRAPPER.add_to_resource_stop(resource, originalMethod.bind(this));
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}, "actualDecorator");
|
|
89
|
-
}
|
|
90
|
-
__name(OnResourceStop, "OnResourceStop");
|
|
91
|
-
export {
|
|
92
|
-
OnResourceStart,
|
|
93
|
-
OnResourceStop
|
|
94
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets called per server/client tick, this is asyncronous though, if you await
|
|
3
|
-
* in it, it will not be called until whatever was being awaited resolves.
|
|
4
|
-
*/
|
|
5
|
-
export declare function SetTick(): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
6
|
-
/**
|
|
7
|
-
* Gets called on the frame after the class is initialized.
|
|
8
|
-
*/
|
|
9
|
-
export declare function SetImmediate(): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
function SetTick() {
|
|
4
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
5
|
-
if (context.private) {
|
|
6
|
-
throw new Error("SetTick does not work on private types, please mark the field as public");
|
|
7
|
-
}
|
|
8
|
-
context.addInitializer(function() {
|
|
9
|
-
setTick(async () => {
|
|
10
|
-
await originalMethod.call(this);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
}, "actualDecorator");
|
|
14
|
-
}
|
|
15
|
-
__name(SetTick, "SetTick");
|
|
16
|
-
function SetImmediate() {
|
|
17
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
18
|
-
if (context.private) {
|
|
19
|
-
throw new Error("SetTick does not work on private types, please mark the field as public");
|
|
20
|
-
}
|
|
21
|
-
context.addInitializer(function() {
|
|
22
|
-
setImmediate(async () => {
|
|
23
|
-
await originalMethod.call(this);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
}, "actualDecorator");
|
|
27
|
-
}
|
|
28
|
-
__name(SetImmediate, "SetImmediate");
|
|
29
|
-
export {
|
|
30
|
-
SetImmediate,
|
|
31
|
-
SetTick
|
|
32
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
type ChangeListener<V> = (value: V) => void;
|
|
2
|
-
/**
|
|
3
|
-
* not ready to be used just thoughts right now
|
|
4
|
-
*/
|
|
5
|
-
export declare class NetworkedMap<K, V> extends Map<K, V> {
|
|
6
|
-
#private;
|
|
7
|
-
constructor(syncName: string, initialValue?: [K, V][]);
|
|
8
|
-
get SyncName(): string;
|
|
9
|
-
private onPlayerDropped;
|
|
10
|
-
resync(source: number): void;
|
|
11
|
-
addSubscriber(source: number): void;
|
|
12
|
-
removeSubscriber(sub: number): boolean;
|
|
13
|
-
hasSubscriber(sub: number): boolean;
|
|
14
|
-
subscriberCount(): number;
|
|
15
|
-
private handleSync;
|
|
16
|
-
listenForChange(key: K, fn: ChangeListener<V>): void;
|
|
17
|
-
set(key: K, value: V): this;
|
|
18
|
-
clear(): void;
|
|
19
|
-
delete(key: K): boolean;
|
|
20
|
-
networkTick(): void;
|
|
21
|
-
[Symbol.dispose](): void;
|
|
22
|
-
/**
|
|
23
|
-
* Unregisters from the tick handler and removes the event listener
|
|
24
|
-
*/
|
|
25
|
-
dispose(): void;
|
|
26
|
-
get [Symbol.toStringTag](): string;
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { GlobalData } from "../GlobalData";
|
|
4
|
-
class NetworkedMapEventManager {
|
|
5
|
-
static {
|
|
6
|
-
__name(this, "NetworkedMapEventManager");
|
|
7
|
-
}
|
|
8
|
-
#syncedCalls = /* @__PURE__ */ new Map();
|
|
9
|
-
constructor() {
|
|
10
|
-
$SERVER: if (GlobalData.IS_SERVER) {
|
|
11
|
-
on("playerDropped", () => {
|
|
12
|
-
const src = source;
|
|
13
|
-
for (const [_k, map] of this.#syncedCalls) {
|
|
14
|
-
map.removeSubscriber(src);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
$CLIENT: {
|
|
20
|
-
RegisterResourceAsEventHandler(`${GlobalData.CurrentResource}:syncChanges`);
|
|
21
|
-
addRawEventListener(`${GlobalData.CurrentResource}:syncChanges`, (msgpack_data) => {
|
|
22
|
-
const data = msgpack_unpack(msgpack_data);
|
|
23
|
-
const syncName = data[0];
|
|
24
|
-
const syncData = data[1];
|
|
25
|
-
const map = this.#syncedCalls.get(syncName);
|
|
26
|
-
if (!map) {
|
|
27
|
-
throw new Error(`Tried to sync changes for a networked map but ${syncName} does't exist.`);
|
|
28
|
-
}
|
|
29
|
-
map.handleSync(syncData);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
addNetworkedMap(map) {
|
|
34
|
-
this.#syncedCalls.set(map.SyncName, map);
|
|
35
|
-
}
|
|
36
|
-
removeNetworkedMap(syncName) {
|
|
37
|
-
this.#syncedCalls.delete(syncName);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const netManager = new NetworkedMapEventManager();
|
|
41
|
-
class NetworkedMap extends Map {
|
|
42
|
-
static {
|
|
43
|
-
__name(this, "NetworkedMap");
|
|
44
|
-
}
|
|
45
|
-
#syncName;
|
|
46
|
-
#queuedChanges = [];
|
|
47
|
-
#changeListeners = /* @__PURE__ */ new Map();
|
|
48
|
-
#subscribers = /* @__PURE__ */ new Set();
|
|
49
|
-
constructor(syncName, initialValue) {
|
|
50
|
-
super(initialValue);
|
|
51
|
-
this.#syncName = syncName;
|
|
52
|
-
GlobalData.NetworkedTicks.push(this);
|
|
53
|
-
netManager.addNetworkedMap(this);
|
|
54
|
-
$SERVER: {
|
|
55
|
-
if (!GlobalData.NetworkTick && GlobalData.IS_SERVER) {
|
|
56
|
-
GlobalData.NetworkTick = setTick(() => {
|
|
57
|
-
for (const networkedThis of GlobalData.NetworkedTicks) {
|
|
58
|
-
networkedThis.networkTick();
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
get SyncName() {
|
|
65
|
-
return this.#syncName;
|
|
66
|
-
}
|
|
67
|
-
// handles removing the player from the map whenever they're dropped
|
|
68
|
-
onPlayerDropped() {
|
|
69
|
-
this.removeSubscriber(source);
|
|
70
|
-
}
|
|
71
|
-
/*
|
|
72
|
-
* Resyncs the entire map to the client, useful for if there's a mismatch in the clients map (when multiple players change things, in cases like inventories)
|
|
73
|
-
*/
|
|
74
|
-
resync(source2) {
|
|
75
|
-
if (!this.#subscribers.has(source2)) {
|
|
76
|
-
console.error(`[NetworkedMap:resync] Tried to call resync on a source that wasn't already subscribed`);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const packed_data = msgpack_pack([this.#syncName, [[4 /* Init */, this.size === 0 ? [] : Array.from(this)]]]);
|
|
80
|
-
TriggerClientEventInternal(
|
|
81
|
-
`${GlobalData.CurrentResource}:syncChanges`,
|
|
82
|
-
source2,
|
|
83
|
-
packed_data,
|
|
84
|
-
packed_data.length
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
/*
|
|
88
|
-
* Adds a new subscriber to the map, this will automatically call resync on the client.
|
|
89
|
-
*/
|
|
90
|
-
addSubscriber(source2) {
|
|
91
|
-
this.#subscribers.add(source2);
|
|
92
|
-
this.resync(source2);
|
|
93
|
-
}
|
|
94
|
-
removeSubscriber(sub) {
|
|
95
|
-
return this.#subscribers.delete(sub);
|
|
96
|
-
}
|
|
97
|
-
hasSubscriber(sub) {
|
|
98
|
-
return this.#subscribers.has(sub);
|
|
99
|
-
}
|
|
100
|
-
subscriberCount() {
|
|
101
|
-
return this.#subscribers.size;
|
|
102
|
-
}
|
|
103
|
-
handleSync(data) {
|
|
104
|
-
for (const [change_type, key, value, possibly_undefined_subvalue] of data) {
|
|
105
|
-
switch (change_type) {
|
|
106
|
-
case 1 /* Add */: {
|
|
107
|
-
this.set(key, value);
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
case 2 /* Remove */: {
|
|
111
|
-
super.delete(key);
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
case 3 /* Reset */: {
|
|
115
|
-
super.clear();
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
case 4 /* Init */: {
|
|
119
|
-
super.clear();
|
|
120
|
-
const key_value = key;
|
|
121
|
-
for (const [k, v] of key_value) {
|
|
122
|
-
this.set(k, v);
|
|
123
|
-
}
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
case 0 /* SubValueChanged */: {
|
|
127
|
-
const data2 = this.get(key);
|
|
128
|
-
data2[value] = possibly_undefined_subvalue;
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/*
|
|
135
|
-
* Listens for the change on the specified key, it will get the resulting
|
|
136
|
-
* value on the change
|
|
137
|
-
*/
|
|
138
|
-
listenForChange(key, fn) {
|
|
139
|
-
const listener = this.#changeListeners.get(key);
|
|
140
|
-
listener ? listener.push(fn) : this.#changeListeners.set(key, [fn]);
|
|
141
|
-
}
|
|
142
|
-
#triggerEventForSubscribers(data) {
|
|
143
|
-
const packed_data = msgpack_pack([this.#syncName, data]);
|
|
144
|
-
for (const sub of this.#subscribers) {
|
|
145
|
-
TriggerClientEventInternal(
|
|
146
|
-
`${GlobalData.CurrentResource}:syncChanges`,
|
|
147
|
-
sub,
|
|
148
|
-
packed_data,
|
|
149
|
-
packed_data.length
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
#pushChangeForListener(key, value) {
|
|
154
|
-
const listener = this.#changeListeners.get(key);
|
|
155
|
-
if (!listener) return;
|
|
156
|
-
for (const ln of listener) {
|
|
157
|
-
ln(value);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/*
|
|
161
|
-
* Adds {@param value} to the map under {@param key}, {@param value} will automatically be turned into a proxy
|
|
162
|
-
* object and the NetworkedMap will automatically send events on SubValue changes.
|
|
163
|
-
* ```ts
|
|
164
|
-
*
|
|
165
|
-
* const map = new NetworkedMap<number, { name:string , quantity: number, obj: { nested_obj_description: string }}>("someUniqueName");
|
|
166
|
-
*
|
|
167
|
-
* const item = {
|
|
168
|
-
* name: "magic_item",
|
|
169
|
-
* quantity: 1,
|
|
170
|
-
* obj: {
|
|
171
|
-
* something_description: "Will never be updated after init"
|
|
172
|
-
* }
|
|
173
|
-
* }
|
|
174
|
-
*
|
|
175
|
-
* // automatically converts `item` into a proxy object
|
|
176
|
-
* map.set(1, item)
|
|
177
|
-
*
|
|
178
|
-
* // if you immediately change the value this will not be recognized, you have to get the object again from the map
|
|
179
|
-
* item.quantity = 2;
|
|
180
|
-
*
|
|
181
|
-
* // reactive object
|
|
182
|
-
* const proxy_object = map.get(1)!;
|
|
183
|
-
*
|
|
184
|
-
* // sub value change will be sent to the client on the next network tick.
|
|
185
|
-
* proxy_object.quantity = 2;
|
|
186
|
-
*
|
|
187
|
-
* // NOTE: this doesn't work on deeply nested objects, it will only work on anything assigned to the first object
|
|
188
|
-
* // This update will never be sent to the client, similar to how state bags work.
|
|
189
|
-
* proxy_object.obj.nested_obj_description = "Some new value"
|
|
190
|
-
* ```
|
|
191
|
-
* i.e. if you have { name: "magic_item", quantity: 1}
|
|
192
|
-
* if you change the item.quantity field this will automatically be sync'd to the client, is only one depth deep
|
|
193
|
-
* so if you have { obj: { some_quantity: 1 } } setting item.obj.some_quantity will not update the client.
|
|
194
|
-
*/
|
|
195
|
-
set(key, value) {
|
|
196
|
-
let v = value;
|
|
197
|
-
if (value instanceof Object) {
|
|
198
|
-
const curThis = this;
|
|
199
|
-
const objectChangeHandler = {
|
|
200
|
-
get(target, prop, reciever) {
|
|
201
|
-
return Reflect.get(target, prop, reciever);
|
|
202
|
-
},
|
|
203
|
-
set(target, p, newValue, receiver) {
|
|
204
|
-
const success = Reflect.set(target, p, newValue, receiver);
|
|
205
|
-
if (success) {
|
|
206
|
-
curThis.#pushChangeForListener(key, target);
|
|
207
|
-
$SERVER: {
|
|
208
|
-
curThis.#queuedChanges.push([0 /* SubValueChanged */, key, p, newValue]);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return success;
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
v = new Proxy(v, objectChangeHandler);
|
|
215
|
-
}
|
|
216
|
-
super.set(key, v);
|
|
217
|
-
this.#pushChangeForListener(key, v);
|
|
218
|
-
$SERVER: {
|
|
219
|
-
this.#queuedChanges.push([1 /* Add */, key, v]);
|
|
220
|
-
}
|
|
221
|
-
return this;
|
|
222
|
-
}
|
|
223
|
-
/*
|
|
224
|
-
* Resets the map to its default state
|
|
225
|
-
*/
|
|
226
|
-
clear() {
|
|
227
|
-
$CLIENT: if (GlobalData.IS_CLIENT) throw new Error(`Cannot call 'clear' on client`);
|
|
228
|
-
this.#queuedChanges = [];
|
|
229
|
-
this.#queuedChanges.push([3 /* Reset */]);
|
|
230
|
-
super.clear();
|
|
231
|
-
}
|
|
232
|
-
delete(key) {
|
|
233
|
-
$CLIENT: if (GlobalData.IS_CLIENT) throw new Error(`Cannot call 'delete' on client`);
|
|
234
|
-
this.#queuedChanges.push([2 /* Remove */, key]);
|
|
235
|
-
return super.delete(key);
|
|
236
|
-
}
|
|
237
|
-
networkTick() {
|
|
238
|
-
if (this.#queuedChanges.length !== 0) {
|
|
239
|
-
this.#triggerEventForSubscribers(this.#queuedChanges);
|
|
240
|
-
this.#queuedChanges = [];
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
[Symbol.dispose]() {
|
|
244
|
-
this.#subscribers.clear();
|
|
245
|
-
this.#changeListeners.clear();
|
|
246
|
-
this.#queuedChanges = [];
|
|
247
|
-
netManager.removeNetworkedMap(this.#syncName);
|
|
248
|
-
GlobalData.NetworkedTicks.filter((v) => v !== this);
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Unregisters from the tick handler and removes the event listener
|
|
252
|
-
*/
|
|
253
|
-
dispose() {
|
|
254
|
-
this[Symbol.dispose]();
|
|
255
|
-
}
|
|
256
|
-
get [Symbol.toStringTag]() {
|
|
257
|
-
return "NetworkedMap";
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
export {
|
|
261
|
-
NetworkedMap
|
|
262
|
-
};
|
|
File without changes
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var ClassTypes = /* @__PURE__ */ ((ClassTypes2) => {
|
|
2
|
-
ClassTypes2[ClassTypes2["Ped"] = 0] = "Ped";
|
|
3
|
-
ClassTypes2[ClassTypes2["Prop"] = 1] = "Prop";
|
|
4
|
-
ClassTypes2[ClassTypes2["Vehicle"] = 2] = "Vehicle";
|
|
5
|
-
ClassTypes2[ClassTypes2["Entity"] = 3] = "Entity";
|
|
6
|
-
ClassTypes2[ClassTypes2["Player"] = 4] = "Player";
|
|
7
|
-
ClassTypes2[ClassTypes2["Vector2"] = 5] = "Vector2";
|
|
8
|
-
ClassTypes2[ClassTypes2["Vector3"] = 6] = "Vector3";
|
|
9
|
-
ClassTypes2[ClassTypes2["Vector4"] = 7] = "Vector4";
|
|
10
|
-
ClassTypes2[ClassTypes2["Quanterion"] = 8] = "Quanterion";
|
|
11
|
-
return ClassTypes2;
|
|
12
|
-
})(ClassTypes || {});
|
|
13
|
-
export {
|
|
14
|
-
ClassTypes
|
|
15
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare class Color {
|
|
2
|
-
static Transparent: Color;
|
|
3
|
-
static Black: Color;
|
|
4
|
-
static White: Color;
|
|
5
|
-
static WhiteSmoke: Color;
|
|
6
|
-
static fromArgb(a: number, r: number, g: number, b: number): Color;
|
|
7
|
-
static fromRgb(r: number, g: number, b: number): Color;
|
|
8
|
-
static fromArray(primitive: [number, number, number] | number[]): Color;
|
|
9
|
-
a: number;
|
|
10
|
-
r: number;
|
|
11
|
-
g: number;
|
|
12
|
-
b: number;
|
|
13
|
-
constructor(r: number, g: number, b: number, a?: number);
|
|
14
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
class Color {
|
|
4
|
-
static {
|
|
5
|
-
__name(this, "Color");
|
|
6
|
-
}
|
|
7
|
-
static Transparent = new Color(0, 0, 0, 0);
|
|
8
|
-
static Black = new Color(0, 0, 0);
|
|
9
|
-
static White = new Color(255, 255, 255);
|
|
10
|
-
static WhiteSmoke = new Color(245, 245, 245);
|
|
11
|
-
static fromArgb(a, r, g, b) {
|
|
12
|
-
return new Color(r, g, b, a);
|
|
13
|
-
}
|
|
14
|
-
static fromRgb(r, g, b) {
|
|
15
|
-
return new Color(r, g, b);
|
|
16
|
-
}
|
|
17
|
-
static fromArray(primitive) {
|
|
18
|
-
return new Color(primitive[0], primitive[1], primitive[2], 255);
|
|
19
|
-
}
|
|
20
|
-
a;
|
|
21
|
-
r;
|
|
22
|
-
g;
|
|
23
|
-
b;
|
|
24
|
-
constructor(r, g, b, a = 255) {
|
|
25
|
-
this.r = r;
|
|
26
|
-
this.g = g;
|
|
27
|
-
this.b = b;
|
|
28
|
-
this.a = a;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
Color
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Delay: (ms: number) => Promise<void>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
class Maths {
|
|
4
|
-
static {
|
|
5
|
-
__name(this, "Maths");
|
|
6
|
-
}
|
|
7
|
-
static clamp(num, min, max) {
|
|
8
|
-
return num <= min ? min : num >= max ? max : num;
|
|
9
|
-
}
|
|
10
|
-
static getRandomInt(min, max) {
|
|
11
|
-
min = Math.ceil(min);
|
|
12
|
-
max = Math.floor(max);
|
|
13
|
-
return Math.floor(Math.random() * (max - min)) + min;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export {
|
|
17
|
-
Maths
|
|
18
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
class Point {
|
|
4
|
-
static {
|
|
5
|
-
__name(this, "Point");
|
|
6
|
-
}
|
|
7
|
-
static parse(arg) {
|
|
8
|
-
let point = new Point();
|
|
9
|
-
if (arg) {
|
|
10
|
-
if (typeof arg === "object") {
|
|
11
|
-
if (Array.isArray(arg)) {
|
|
12
|
-
if (arg.length === 2) {
|
|
13
|
-
point = new Point(arg[0], arg[1]);
|
|
14
|
-
}
|
|
15
|
-
} else if (arg.X && arg.Y) {
|
|
16
|
-
point = new Point(arg.X, arg.Y);
|
|
17
|
-
}
|
|
18
|
-
} else {
|
|
19
|
-
if (arg.indexOf(",") !== -1) {
|
|
20
|
-
const arr = arg.split(",");
|
|
21
|
-
point = new Point(Number.parseFloat(arr[0]), Number.parseFloat(arr[1]));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return point;
|
|
26
|
-
}
|
|
27
|
-
X;
|
|
28
|
-
Y;
|
|
29
|
-
constructor(x = 0, y = 0) {
|
|
30
|
-
this.X = x;
|
|
31
|
-
this.Y = y;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
Point
|
|
36
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
class PointF {
|
|
4
|
-
constructor(x, y, z) {
|
|
5
|
-
this.x = x;
|
|
6
|
-
this.y = y;
|
|
7
|
-
this.z = z;
|
|
8
|
-
}
|
|
9
|
-
static {
|
|
10
|
-
__name(this, "PointF");
|
|
11
|
-
}
|
|
12
|
-
static empty() {
|
|
13
|
-
return new PointF(0, 0, 0);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export {
|
|
17
|
-
PointF
|
|
18
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { Vector3 } from "./Vector";
|
|
4
|
-
class Quaternion {
|
|
5
|
-
static {
|
|
6
|
-
__name(this, "Quaternion");
|
|
7
|
-
}
|
|
8
|
-
x;
|
|
9
|
-
y;
|
|
10
|
-
z;
|
|
11
|
-
w;
|
|
12
|
-
constructor(valueXOrVector, yOrW, z, w) {
|
|
13
|
-
if (valueXOrVector instanceof Vector3) {
|
|
14
|
-
this.x = valueXOrVector.x;
|
|
15
|
-
this.y = valueXOrVector.y;
|
|
16
|
-
this.z = valueXOrVector.z;
|
|
17
|
-
this.w = yOrW ?? 0;
|
|
18
|
-
} else if (yOrW === void 0) {
|
|
19
|
-
this.x = valueXOrVector;
|
|
20
|
-
this.y = valueXOrVector;
|
|
21
|
-
this.z = valueXOrVector;
|
|
22
|
-
this.w = valueXOrVector;
|
|
23
|
-
} else {
|
|
24
|
-
this.x = valueXOrVector;
|
|
25
|
-
this.y = yOrW;
|
|
26
|
-
this.z = z ?? 0;
|
|
27
|
-
this.w = w ?? 0;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
Quaternion
|
|
33
|
-
};
|