@nativewrappers/common-game 0.0.125 → 0.0.127
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/CommonModel.js +2 -2
- package/CommonTasks.d.ts +1 -1
- package/CommonTasks.js +2 -2
- package/common/Command.d.ts +77 -0
- package/common/Command.js +152 -0
- package/common/Convar.d.ts +13 -0
- package/common/Convar.js +58 -0
- package/common/GlobalData.d.ts +12 -0
- package/common/GlobalData.js +20 -0
- package/common/Kvp.d.ts +69 -0
- package/common/Kvp.js +137 -0
- package/common/Resource.d.ts +14 -0
- package/common/Resource.js +54 -0
- package/common/decors/ConVar.d.ts +14 -0
- package/common/decors/ConVar.js +70 -0
- package/common/decors/Events.d.ts +66 -0
- package/common/decors/Events.js +163 -0
- package/common/decors/Exports.d.ts +1 -0
- package/common/decors/Exports.js +53 -0
- package/common/decors/Permissions.d.ts +3 -0
- package/common/decors/Permissions.js +49 -0
- package/common/decors/Resources.d.ts +8 -0
- package/common/decors/Resources.js +94 -0
- package/common/decors/Ticks.d.ts +9 -0
- package/common/decors/Ticks.js +32 -0
- package/common/net/NetworkedMap.d.ts +28 -0
- package/common/net/NetworkedMap.js +225 -0
- package/common/types.d.ts +5 -0
- package/common/types.js +0 -0
- package/common/utils/ClassTypes.d.ts +11 -0
- package/common/utils/ClassTypes.js +15 -0
- package/common/utils/Color.d.ts +14 -0
- package/common/utils/Color.js +33 -0
- package/common/utils/Delay.d.ts +1 -0
- package/common/utils/Delay.js +6 -0
- package/common/utils/Maths.d.ts +4 -0
- package/common/utils/Maths.js +18 -0
- package/common/utils/Point.d.ts +9 -0
- package/common/utils/Point.js +36 -0
- package/common/utils/PointF.d.ts +7 -0
- package/common/utils/PointF.js +18 -0
- package/common/utils/Quaternion.d.ts +10 -0
- package/common/utils/Quaternion.js +33 -0
- package/common/utils/Vector.d.ts +429 -0
- package/common/utils/Vector.js +589 -0
- package/common/utils/cleanPlayerName.d.ts +6 -0
- package/common/utils/cleanPlayerName.js +17 -0
- package/common/utils/enumValues.d.ts +12 -0
- package/common/utils/enumValues.js +20 -0
- package/common/utils/getStringFromUInt8Array.d.ts +8 -0
- package/common/utils/getStringFromUInt8Array.js +6 -0
- package/common/utils/getUInt32FromUint8Array.d.ts +8 -0
- package/common/utils/getUInt32FromUint8Array.js +6 -0
- package/common/utils/randomInt.d.ts +1 -0
- package/common/utils/randomInt.js +9 -0
- package/entities/CommonBaseEntity.d.ts +3 -3
- package/entities/CommonBaseEntity.js +2 -2
- package/entities/CommonBaseEntityBone.d.ts +1 -1
- package/entities/CommonBaseEntityBone.js +1 -1
- package/entities/CommonPed.d.ts +1 -1
- package/entities/CommonPed.js +1 -1
- package/entities/CommonPlayer.js +1 -1
- package/entities/CommonProp.d.ts +1 -1
- package/entities/CommonProp.js +1 -1
- package/entities/CommonVehicle.d.ts +1 -1
- package/entities/CommonVehicle.js +1 -1
- package/index.d.ts +26 -0
- package/index.js +26 -0
- package/interfaces/Dimension.d.ts +1 -1
- package/package.json +1 -1
- package/utils/Animations.js +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var ConVarType = /* @__PURE__ */ ((ConVarType2) => {
|
|
4
|
+
ConVarType2[ConVarType2["String"] = 0] = "String";
|
|
5
|
+
ConVarType2[ConVarType2["Integer"] = 1] = "Integer";
|
|
6
|
+
ConVarType2[ConVarType2["Float"] = 2] = "Float";
|
|
7
|
+
ConVarType2[ConVarType2["Boolean"] = 3] = "Boolean";
|
|
8
|
+
return ConVarType2;
|
|
9
|
+
})(ConVarType || {});
|
|
10
|
+
const get_convar_fn = /* @__PURE__ */ __name((con_var_type) => {
|
|
11
|
+
switch (con_var_type) {
|
|
12
|
+
case 0 /* String */:
|
|
13
|
+
return GetConvar;
|
|
14
|
+
case 1 /* Integer */:
|
|
15
|
+
return GetConvarInt;
|
|
16
|
+
case 2 /* Float */:
|
|
17
|
+
return GetConvarFloat;
|
|
18
|
+
case 3 /* Boolean */:
|
|
19
|
+
return GetConvarBool;
|
|
20
|
+
// needed so typescript wont complain about "unreachable code" for the error below
|
|
21
|
+
default:
|
|
22
|
+
}
|
|
23
|
+
throw new Error("Got invalid ConVarType");
|
|
24
|
+
}, "get_convar_fn");
|
|
25
|
+
function ConVar(name, is_floating_point, deserialize) {
|
|
26
|
+
return /* @__PURE__ */ __name(function actualDecorator(_initialValue, context, ..._args) {
|
|
27
|
+
if (context.private) {
|
|
28
|
+
throw new Error("ConVar does not work on private types, please mark the field as public");
|
|
29
|
+
}
|
|
30
|
+
context.addInitializer(function() {
|
|
31
|
+
const t = this;
|
|
32
|
+
const default_value = Reflect.get(t, context.name);
|
|
33
|
+
const default_type = typeof default_value;
|
|
34
|
+
let con_var_type = null;
|
|
35
|
+
if (default_type === "number") {
|
|
36
|
+
if (is_floating_point || !Number.isInteger(default_value)) {
|
|
37
|
+
con_var_type = 2 /* Float */;
|
|
38
|
+
} else {
|
|
39
|
+
con_var_type = 1 /* Integer */;
|
|
40
|
+
}
|
|
41
|
+
} else if (default_type === "boolean") {
|
|
42
|
+
con_var_type = 3 /* Boolean */;
|
|
43
|
+
} else if (default_type === "string") {
|
|
44
|
+
con_var_type = 0 /* String */;
|
|
45
|
+
}
|
|
46
|
+
if (!deserialize && con_var_type === null) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Failed to determine what to use to deserialize '${name}' was for var had type '${default_type}' which can't be deserialized without providing your own deserialize function.`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (con_var_type === null) {
|
|
52
|
+
con_var_type = 0 /* String */;
|
|
53
|
+
}
|
|
54
|
+
const con_var_fn = get_convar_fn(con_var_type);
|
|
55
|
+
const get_convar_value = /* @__PURE__ */ __name(() => {
|
|
56
|
+
const data = con_var_fn(name, default_value);
|
|
57
|
+
return deserialize ? deserialize(data) : data;
|
|
58
|
+
}, "get_convar_value");
|
|
59
|
+
Reflect.set(t, context.name, get_convar_value());
|
|
60
|
+
AddConvarChangeListener(name, () => {
|
|
61
|
+
Reflect.set(t, context.name, get_convar_value());
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}, "actualDecorator");
|
|
65
|
+
}
|
|
66
|
+
__name(ConVar, "ConVar");
|
|
67
|
+
export {
|
|
68
|
+
ConVar,
|
|
69
|
+
ConVarType
|
|
70
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disables pretty printing in error messages
|
|
3
|
+
*/
|
|
4
|
+
export declare const DisablePrettyPrint: () => boolean;
|
|
5
|
+
export declare enum Binding {
|
|
6
|
+
/**
|
|
7
|
+
* No one can call this
|
|
8
|
+
*/
|
|
9
|
+
None = 0,
|
|
10
|
+
/**
|
|
11
|
+
* Server only accepts server calls, client only client calls
|
|
12
|
+
*/
|
|
13
|
+
Local = 1,
|
|
14
|
+
/**
|
|
15
|
+
* Server only accepts client calls, client only server calls
|
|
16
|
+
*/
|
|
17
|
+
Remote = 2,
|
|
18
|
+
/**
|
|
19
|
+
* Accept all incoming calls
|
|
20
|
+
* Server only accepts client calls, client only server calls
|
|
21
|
+
*/
|
|
22
|
+
All = 3
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Registers the Event call for {@link eventName} to this method.
|
|
26
|
+
*
|
|
27
|
+
* This has internal pretty-printing to make errors easier to track, if
|
|
28
|
+
* you want to disable this you will need to call {@link DisablePrettyPrint}, or if you're
|
|
29
|
+
* using esbuild you can add `REMOVE_EVENT_LOG` to your drop label {@link https://esbuild.github.io/api/#drop-labels}
|
|
30
|
+
* @param eventName the event to bind to
|
|
31
|
+
*/
|
|
32
|
+
export declare function CfxEvent(eventName: string, binding?: Binding): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Registers the Event call for {@link eventName} to this method.
|
|
35
|
+
*
|
|
36
|
+
* This has internal pretty-printing to make errors easier to track, if
|
|
37
|
+
* you want to disable this you will need to call {@link DisablePrettyPrint}, or if you're
|
|
38
|
+
* using esbuild you can add `REMOVE_EVENT_LOG` to your drop label {@link https://esbuild.github.io/api/#drop-labels}
|
|
39
|
+
*
|
|
40
|
+
* @param eventName the event to bind to
|
|
41
|
+
*/
|
|
42
|
+
export declare function Event(eventName: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Registers the Net Event call for {@link eventName} to this method
|
|
45
|
+
*
|
|
46
|
+
*
|
|
47
|
+
* This has internal pretty-printing to make errors easier to track, if
|
|
48
|
+
* you want to disable this you will need to call {@link DisablePrettyPrint}, or if you're
|
|
49
|
+
* using esbuild you can add `REMOVE_EVENT_LOG` to your drop label {@link https://esbuild.github.io/api/#drop-labels}
|
|
50
|
+
*
|
|
51
|
+
* @param eventName the event to bind this net event to
|
|
52
|
+
* @param remoteOnly if the event should only accept remote calls, if set to true it will ignore any local call via `emit`, defaults to true
|
|
53
|
+
*/
|
|
54
|
+
export declare function NetEvent(eventName: string, remoteOnly?: boolean): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
55
|
+
export type NuiCallback = (data: string) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Registers the NUI Event call for {eventName} to this method, the function signature
|
|
58
|
+
* will always be (data: unknown, cb: (data?: any) => void) => void
|
|
59
|
+
*
|
|
60
|
+
* There's two valid ways to return data into a callback, returning in the method
|
|
61
|
+
* you're currently using will automatically call the callback, or you can manually call the callback yourself
|
|
62
|
+
*
|
|
63
|
+
* @param eventName the event this will listen for
|
|
64
|
+
* @param dontErrorWhenCbIsntInvoked this will just block the event fro merroring when the callback is never invoked.
|
|
65
|
+
*/
|
|
66
|
+
export declare function NuiEvent(eventName: string, dontErrorWhenCbIsntInvoked?: boolean): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { GlobalData } from "../GlobalData";
|
|
4
|
+
const DisablePrettyPrint = /* @__PURE__ */ __name(() => GlobalData.EnablePrettyPrint = false, "DisablePrettyPrint");
|
|
5
|
+
const AsyncFunction = (async () => {
|
|
6
|
+
}).constructor;
|
|
7
|
+
var Binding = /* @__PURE__ */ ((Binding2) => {
|
|
8
|
+
Binding2[Binding2["None"] = 0] = "None";
|
|
9
|
+
Binding2[Binding2["Local"] = 1] = "Local";
|
|
10
|
+
Binding2[Binding2["Remote"] = 2] = "Remote";
|
|
11
|
+
Binding2[Binding2["All"] = 3] = "All";
|
|
12
|
+
return Binding2;
|
|
13
|
+
})(Binding || {});
|
|
14
|
+
function CfxEvent(eventName, binding = 1 /* Local */) {
|
|
15
|
+
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
16
|
+
if (context.private) {
|
|
17
|
+
throw new Error("Event does not work on private methods, please mark the method as public");
|
|
18
|
+
}
|
|
19
|
+
context.addInitializer(function() {
|
|
20
|
+
const fn = (binding & 2 /* Remote */) !== 0 ? onNet : on;
|
|
21
|
+
const _t = this;
|
|
22
|
+
fn(eventName, async (...args) => {
|
|
23
|
+
const src = source;
|
|
24
|
+
if (_t.__permissionMap && binding & 2 /* Remote */) {
|
|
25
|
+
const permissions = _t.__permissionMap.get(context.name);
|
|
26
|
+
if (permissions) {
|
|
27
|
+
let hasPermission = false;
|
|
28
|
+
for (const perm of permissions) {
|
|
29
|
+
if (IsPlayerAceAllowed(src, perm)) {
|
|
30
|
+
hasPermission = true;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!hasPermission) {
|
|
35
|
+
emit("@nativewrappers:no_permission", { eventName, method: context.name });
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
return await originalMethod.call(this, ...args);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
REMOVE_EVENT_LOG: {
|
|
44
|
+
if (!GlobalData.EnablePrettyPrint) return;
|
|
45
|
+
console.error("------- EVENT ERROR --------");
|
|
46
|
+
console.error(`Call to ${eventName} errored`);
|
|
47
|
+
console.error(`Data: ${JSON.stringify(args)}`);
|
|
48
|
+
console.error(`Error: ${e}`);
|
|
49
|
+
console.error("------- END EVENT ERROR --------");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}, "actualDecorator");
|
|
55
|
+
}
|
|
56
|
+
__name(CfxEvent, "CfxEvent");
|
|
57
|
+
function Event(eventName) {
|
|
58
|
+
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
59
|
+
if (context.private) {
|
|
60
|
+
throw new Error("Event does not work on private methods, please mark the method as public");
|
|
61
|
+
}
|
|
62
|
+
context.addInitializer(function() {
|
|
63
|
+
on(eventName, async (...args) => {
|
|
64
|
+
try {
|
|
65
|
+
return await originalMethod.call(this, ...args);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
REMOVE_EVENT_LOG: {
|
|
68
|
+
if (!GlobalData.EnablePrettyPrint) return;
|
|
69
|
+
console.error("------- EVENT ERROR --------");
|
|
70
|
+
console.error(`Call to ${eventName} errored`);
|
|
71
|
+
console.error(`Data: ${JSON.stringify(args)}`);
|
|
72
|
+
console.error(`Error: ${e}`);
|
|
73
|
+
console.error("------- END EVENT ERROR --------");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}, "actualDecorator");
|
|
79
|
+
}
|
|
80
|
+
__name(Event, "Event");
|
|
81
|
+
function NetEvent(eventName, remoteOnly = true) {
|
|
82
|
+
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
83
|
+
if (context.private) {
|
|
84
|
+
throw new Error("NetEvent does not work on private methods, please mark the method as public");
|
|
85
|
+
}
|
|
86
|
+
context.addInitializer(function() {
|
|
87
|
+
const _t = this;
|
|
88
|
+
onNet(eventName, async (...args) => {
|
|
89
|
+
const src = source;
|
|
90
|
+
if (_t.__permissionMap) {
|
|
91
|
+
const permissions = _t.__permissionMap.get(context.name);
|
|
92
|
+
if (permissions) {
|
|
93
|
+
let hasPermission = false;
|
|
94
|
+
for (const perm of permissions) {
|
|
95
|
+
if (IsPlayerAceAllowed(src, perm)) {
|
|
96
|
+
hasPermission = true;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!hasPermission) {
|
|
101
|
+
emit("@nativewrappers:no_permission", { eventName, method: context.name });
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
$CLIENT: {
|
|
108
|
+
if (GlobalData.IS_CLIENT && remoteOnly && source !== 65535) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return await originalMethod.call(this, ...args);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
REMOVE_NET_EVENT_LOG: {
|
|
115
|
+
if (!GlobalData.EnablePrettyPrint) return;
|
|
116
|
+
console.error("------- NET EVENT ERROR --------");
|
|
117
|
+
console.error(`Call to ${eventName} errored`);
|
|
118
|
+
console.error(`Caller: ${src}`);
|
|
119
|
+
console.error(`Data: ${JSON.stringify(args)}`);
|
|
120
|
+
console.error(`Error: ${e}`);
|
|
121
|
+
console.error("------- END NET EVENT ERROR --------");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}, "actualDecorator");
|
|
127
|
+
}
|
|
128
|
+
__name(NetEvent, "NetEvent");
|
|
129
|
+
function NuiEvent(eventName, dontErrorWhenCbIsntInvoked = false) {
|
|
130
|
+
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
131
|
+
if (context.private) {
|
|
132
|
+
throw new Error("NuiEvent does not work on private methods, please mark the method as public");
|
|
133
|
+
}
|
|
134
|
+
context.addInitializer(function() {
|
|
135
|
+
RegisterNuiCallback(eventName, async (data, cb) => {
|
|
136
|
+
let wasInvoked = false;
|
|
137
|
+
const cbWrapper = /* @__PURE__ */ __name((args) => {
|
|
138
|
+
wasInvoked = true;
|
|
139
|
+
cb(args);
|
|
140
|
+
}, "cbWrapper");
|
|
141
|
+
const retData = await originalMethod.call(this, data, cbWrapper);
|
|
142
|
+
if (!wasInvoked && !retData) {
|
|
143
|
+
if (dontErrorWhenCbIsntInvoked) return;
|
|
144
|
+
throw new Error(
|
|
145
|
+
`Error in NuiEvent ${eventName} '@NuiEvent' expects you to return data in your callback, or to return from the function call`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
if (!wasInvoked) {
|
|
149
|
+
cb(retData);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}, "actualDecorator");
|
|
154
|
+
}
|
|
155
|
+
__name(NuiEvent, "NuiEvent");
|
|
156
|
+
export {
|
|
157
|
+
Binding,
|
|
158
|
+
CfxEvent,
|
|
159
|
+
DisablePrettyPrint,
|
|
160
|
+
Event,
|
|
161
|
+
NetEvent,
|
|
162
|
+
NuiEvent
|
|
163
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Exports(exportName: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { GlobalData } from "../GlobalData";
|
|
4
|
+
const AsyncFunction = (async () => {
|
|
5
|
+
}).constructor;
|
|
6
|
+
function Exports(exportName) {
|
|
7
|
+
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
8
|
+
if (context.private) {
|
|
9
|
+
throw new Error("Exports does not work on private methods, please mark the method as public");
|
|
10
|
+
}
|
|
11
|
+
context.addInitializer(function() {
|
|
12
|
+
let exportCb;
|
|
13
|
+
if (originalMethod instanceof AsyncFunction) {
|
|
14
|
+
exportCb = /* @__PURE__ */ __name(async (...args) => {
|
|
15
|
+
try {
|
|
16
|
+
return await originalMethod.call(this, ...args);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
REMOVE_EVENT_LOG: {
|
|
19
|
+
if (!GlobalData.EnablePrettyPrint) return;
|
|
20
|
+
console.error("------- EXPORT ERROR --------");
|
|
21
|
+
console.error(`Call to ${exportName} errored`);
|
|
22
|
+
console.error(`Data: ${JSON.stringify(args)}`);
|
|
23
|
+
console.error(`Error: ${err}`);
|
|
24
|
+
console.error("------- END EXPORT ERROR --------");
|
|
25
|
+
}
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
}, "exportCb");
|
|
29
|
+
} else {
|
|
30
|
+
exportCb = /* @__PURE__ */ __name((...args) => {
|
|
31
|
+
try {
|
|
32
|
+
return originalMethod.call(this, ...args);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
REMOVE_EVENT_LOG: {
|
|
35
|
+
if (!GlobalData.EnablePrettyPrint) return;
|
|
36
|
+
console.error("------- EXPORT ERROR --------");
|
|
37
|
+
console.error(`Call to ${exportName} errored`);
|
|
38
|
+
console.error(`Data: ${JSON.stringify(args)}`);
|
|
39
|
+
console.error(`Error: ${err}`);
|
|
40
|
+
console.error("------- END EXPORT ERROR --------");
|
|
41
|
+
}
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
}, "exportCb");
|
|
45
|
+
}
|
|
46
|
+
exports(exportName, exportCb);
|
|
47
|
+
});
|
|
48
|
+
}, "actualDecorator");
|
|
49
|
+
}
|
|
50
|
+
__name(Exports, "Exports");
|
|
51
|
+
export {
|
|
52
|
+
Exports
|
|
53
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function RestrictToGroupAce(groupAceName: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
2
|
+
export declare function RestrictToJobAce(jobAce: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
3
|
+
export declare function RestrictToAce(aceName: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { GlobalData } from "../GlobalData";
|
|
4
|
+
const addAcePermission = /* @__PURE__ */ __name((aceName, context) => {
|
|
5
|
+
context.addInitializer(function() {
|
|
6
|
+
const _t = this;
|
|
7
|
+
_t.__permissionMap = _t.__permissionMap ?? /* @__PURE__ */ new Map();
|
|
8
|
+
const ace_list = _t.__permissionMap.get(context.name);
|
|
9
|
+
if (ace_list) {
|
|
10
|
+
ace_list.add(aceName);
|
|
11
|
+
} else {
|
|
12
|
+
_t.__permissionMap.set(context.name, /* @__PURE__ */ new Set([aceName]));
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}, "addAcePermission");
|
|
16
|
+
function RestrictToGroupAce(groupAceName) {
|
|
17
|
+
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
18
|
+
if (context.private) {
|
|
19
|
+
throw new Error("Exports does not work on private methods, please mark the method as public");
|
|
20
|
+
}
|
|
21
|
+
const groupAce = `group.${groupAceName}`;
|
|
22
|
+
addAcePermission(groupAce, context);
|
|
23
|
+
}, "actualDecorator");
|
|
24
|
+
}
|
|
25
|
+
__name(RestrictToGroupAce, "RestrictToGroupAce");
|
|
26
|
+
function RestrictToJobAce(jobAce) {
|
|
27
|
+
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
28
|
+
if (context.private) {
|
|
29
|
+
throw new Error("Exports does not work on private methods, please mark the method as public");
|
|
30
|
+
}
|
|
31
|
+
const groupAce = `job.${jobAce}`;
|
|
32
|
+
addAcePermission(groupAce, context);
|
|
33
|
+
}, "actualDecorator");
|
|
34
|
+
}
|
|
35
|
+
__name(RestrictToJobAce, "RestrictToJobAce");
|
|
36
|
+
function RestrictToAce(aceName) {
|
|
37
|
+
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
38
|
+
if (context.private) {
|
|
39
|
+
throw new Error("Exports does not work on private methods, please mark the method as public");
|
|
40
|
+
}
|
|
41
|
+
addAcePermission(aceName, context);
|
|
42
|
+
}, "actualDecorator");
|
|
43
|
+
}
|
|
44
|
+
__name(RestrictToAce, "RestrictToAce");
|
|
45
|
+
export {
|
|
46
|
+
RestrictToAce,
|
|
47
|
+
RestrictToGroupAce,
|
|
48
|
+
RestrictToJobAce
|
|
49
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Called whenever the specified resource is started, this will be called once on once on resource start if the resource is started.
|
|
3
|
+
*/
|
|
4
|
+
export declare function OnResourceStart(resource?: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Called whenever the specified resource is stopped.
|
|
7
|
+
*/
|
|
8
|
+
export declare function OnResourceStop(resource?: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
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 {};
|