@nativewrappers/redm 0.0.158 → 0.0.159
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/net/Net.d.ts +3 -1
- package/common/net/Net.js +11 -2
- package/common/utils/Vector.d.ts +4 -5
- package/common/utils/Vector.js +8 -9
- package/package.json +1 -1
package/common/net/Net.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ export declare class Net {
|
|
|
11
11
|
export declare class NetServer extends Net {
|
|
12
12
|
static emitNet(eventName: string, source: number, ...args: any[]): void;
|
|
13
13
|
static emitProto<T>(source: number, message: MessageTypeEncoder<T>): void;
|
|
14
|
-
static
|
|
14
|
+
static broadcastProto<T>(sources: Iterable<number>, message: MessageTypeEncoder<T>): void;
|
|
15
|
+
static broadcast(sources: Iterable<number>, eventName: string, ...args: any[]): void;
|
|
16
|
+
static broadcastRaw(sources: Iterable<number>, eventName: string, data: Uint8Array): void;
|
|
15
17
|
static emitRawNet(eventName: string, source: number, data: Uint8Array): void;
|
|
16
18
|
}
|
|
17
19
|
export declare class NetClient extends Net {
|
package/common/net/Net.js
CHANGED
|
@@ -33,10 +33,19 @@ class NetServer extends Net {
|
|
|
33
33
|
const encoded = message.encode(message);
|
|
34
34
|
NetServer.emitRawNet(message.name, source, encoded);
|
|
35
35
|
}
|
|
36
|
-
static
|
|
36
|
+
static broadcastProto(sources, message) {
|
|
37
37
|
const encoded = message.encode(message);
|
|
38
|
+
NetServer.broadcastRaw(sources, message.name, encoded);
|
|
39
|
+
}
|
|
40
|
+
static broadcast(sources, eventName, ...args) {
|
|
41
|
+
const packed = msgpack_pack(...args);
|
|
42
|
+
for (const source of sources) {
|
|
43
|
+
TriggerClientEventInternal(eventName, source, packed, packed.length);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
static broadcastRaw(sources, eventName, data) {
|
|
38
47
|
for (const source of sources) {
|
|
39
|
-
NetServer.emitRawNet(
|
|
48
|
+
NetServer.emitRawNet(eventName, source, data);
|
|
40
49
|
}
|
|
41
50
|
}
|
|
42
51
|
static emitRawNet(eventName, source, data) {
|
package/common/utils/Vector.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { MsgpackBuffer } from "../types";
|
|
2
2
|
import { ClassTypes } from "./ClassTypes";
|
|
3
|
-
declare const size: unique symbol;
|
|
4
3
|
/**
|
|
5
4
|
* Represents a 2-dimensional vector.
|
|
6
5
|
*/
|
|
@@ -211,7 +210,7 @@ declare abstract class Vector {
|
|
|
211
210
|
*/
|
|
212
211
|
static Length<T extends VectorType, U extends VectorLike>(this: T, obj: U): number;
|
|
213
212
|
type: unknown;
|
|
214
|
-
|
|
213
|
+
vec_size: number;
|
|
215
214
|
x: number;
|
|
216
215
|
y: number;
|
|
217
216
|
z: number | undefined;
|
|
@@ -314,7 +313,7 @@ declare abstract class Vector {
|
|
|
314
313
|
*/
|
|
315
314
|
export declare class Vector2 extends Vector {
|
|
316
315
|
readonly type = ClassTypes.Vector2;
|
|
317
|
-
readonly
|
|
316
|
+
readonly vec_size: number;
|
|
318
317
|
static readonly Zero: Vector2;
|
|
319
318
|
/**
|
|
320
319
|
* Constructs a new 2D vector.
|
|
@@ -335,7 +334,7 @@ export declare class Vector2 extends Vector {
|
|
|
335
334
|
*/
|
|
336
335
|
export declare class Vector3 extends Vector implements Vec3 {
|
|
337
336
|
readonly type = ClassTypes.Vector3;
|
|
338
|
-
readonly
|
|
337
|
+
readonly vec_size: number;
|
|
339
338
|
z: number;
|
|
340
339
|
static readonly Zero: Vector3;
|
|
341
340
|
static readonly UnitX: Vector3;
|
|
@@ -384,7 +383,7 @@ export declare class Vector3 extends Vector implements Vec3 {
|
|
|
384
383
|
*/
|
|
385
384
|
export declare class Vector4 extends Vector {
|
|
386
385
|
readonly type = ClassTypes.Vector4;
|
|
387
|
-
readonly
|
|
386
|
+
readonly vec_size: number;
|
|
388
387
|
z: number;
|
|
389
388
|
w: number;
|
|
390
389
|
static readonly Zero: Vector4;
|
package/common/utils/Vector.js
CHANGED
|
@@ -4,15 +4,14 @@ import { ClassTypes } from "./ClassTypes";
|
|
|
4
4
|
const EXT_VECTOR2 = 20;
|
|
5
5
|
const EXT_VECTOR3 = 21;
|
|
6
6
|
const EXT_VECTOR4 = 22;
|
|
7
|
-
const size = Symbol("size");
|
|
8
7
|
class Vector {
|
|
9
8
|
static {
|
|
10
9
|
__name(this, "Vector");
|
|
11
10
|
}
|
|
12
11
|
static create(x, y = x, z, w) {
|
|
13
12
|
if (typeof x === "object") ({ x, y, z, w } = x);
|
|
14
|
-
const
|
|
15
|
-
switch (
|
|
13
|
+
const size = this instanceof Vector && this.size || [x, y, z, w].filter((arg) => arg !== void 0).length;
|
|
14
|
+
switch (size) {
|
|
16
15
|
case 1:
|
|
17
16
|
case 2:
|
|
18
17
|
return new Vector2(x, y);
|
|
@@ -21,7 +20,7 @@ class Vector {
|
|
|
21
20
|
case 4:
|
|
22
21
|
return new Vector4(x, y, z, w);
|
|
23
22
|
default:
|
|
24
|
-
throw new Error(`Cannot instantiate Vector with size of ${
|
|
23
|
+
throw new Error(`Cannot instantiate Vector with size of ${size}.`);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
@@ -263,7 +262,7 @@ class Vector {
|
|
|
263
262
|
return Math.sqrt(sum);
|
|
264
263
|
}
|
|
265
264
|
type;
|
|
266
|
-
|
|
265
|
+
vec_size = 2;
|
|
267
266
|
x = 0;
|
|
268
267
|
y = 0;
|
|
269
268
|
z;
|
|
@@ -293,7 +292,7 @@ class Vector {
|
|
|
293
292
|
if (this.w !== void 0) yield this.w;
|
|
294
293
|
}
|
|
295
294
|
get size() {
|
|
296
|
-
return this
|
|
295
|
+
return this.vec_size;
|
|
297
296
|
}
|
|
298
297
|
toString() {
|
|
299
298
|
return `vector${this.size}(${this.toArray().join(", ")})`;
|
|
@@ -432,7 +431,7 @@ class Vector2 extends Vector {
|
|
|
432
431
|
// DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
|
|
433
432
|
// TO EXIST, CHANGING IT WILL BREAK STUFF
|
|
434
433
|
type = ClassTypes.Vector2;
|
|
435
|
-
|
|
434
|
+
vec_size = 2;
|
|
436
435
|
static Zero = new Vector2(0, 0);
|
|
437
436
|
/**
|
|
438
437
|
* Constructs a new 2D vector.
|
|
@@ -460,7 +459,7 @@ class Vector3 extends Vector {
|
|
|
460
459
|
// DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
|
|
461
460
|
// TO EXIST, CHANGING IT WILL BREAK STUFF
|
|
462
461
|
type = ClassTypes.Vector3;
|
|
463
|
-
|
|
462
|
+
vec_size = 3;
|
|
464
463
|
z = 0;
|
|
465
464
|
static Zero = new Vector3(0, 0, 0);
|
|
466
465
|
static UnitX = new Vector3(1, 0, 0);
|
|
@@ -523,7 +522,7 @@ class Vector4 extends Vector {
|
|
|
523
522
|
// DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
|
|
524
523
|
// TO EXIST, CHANGING IT WILL BREAK STUFF
|
|
525
524
|
type = ClassTypes.Vector4;
|
|
526
|
-
|
|
525
|
+
vec_size = 4;
|
|
527
526
|
z = 0;
|
|
528
527
|
w = 0;
|
|
529
528
|
static Zero = new Vector4(0, 0, 0, 0);
|