@hytopia.com/server-protocol 1.4.12 → 1.4.14
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/package.json
CHANGED
package/packets/PacketCore.ts
CHANGED
|
@@ -86,12 +86,16 @@ export function createPacket<TId extends PacketId, TSchema>(
|
|
|
86
86
|
packetDef: IPacketDefinition<TId, TSchema>,
|
|
87
87
|
data: TSchema,
|
|
88
88
|
worldTick?: WorldTick,
|
|
89
|
+
reusablePacket?: IPacket<TId, TSchema>,
|
|
89
90
|
): IPacket<TId, TSchema> {
|
|
90
91
|
if (!packetDef.validate(data)) {
|
|
91
92
|
throw new Error(`Invalid payload for packet with id ${packetDef.id}. Error: ${Ajv.instance.errorsText(packetDef.validate.errors)}`);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
const packet: IPacket<TId, TSchema> = [
|
|
95
|
+
const packet: IPacket<TId, TSchema> = reusablePacket ?? [] as unknown as IPacket<TId, TSchema>;
|
|
96
|
+
|
|
97
|
+
packet[0] = packetDef.id;
|
|
98
|
+
packet[1] = data;
|
|
95
99
|
|
|
96
100
|
if (typeof worldTick === 'number') {
|
|
97
101
|
packet.push(worldTick);
|
|
@@ -28,8 +28,10 @@ export type ParticleEmitterSchema = {
|
|
|
28
28
|
r?: number; // rate, in particles per second
|
|
29
29
|
rv?: number; // rate variance, in particles per second
|
|
30
30
|
rm?: boolean; // remove/removed
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
se?: number; // size end, in world units
|
|
32
|
+
sev?: number; // size end variance, in world units
|
|
33
|
+
ss?: number; // size start, in world units
|
|
34
|
+
ssv?: number; // size start variance, in world units
|
|
33
35
|
t?: boolean; // transparent
|
|
34
36
|
tu?: string; // texture uri
|
|
35
37
|
v?: VectorSchema; // velocity per axis as vector3
|
|
@@ -62,8 +64,10 @@ export const particleEmitterSchema: JSONSchemaType<ParticleEmitterSchema> = {
|
|
|
62
64
|
r: { type: 'number', nullable: true },
|
|
63
65
|
rv: { type: 'number', nullable: true },
|
|
64
66
|
rm: { type: 'boolean', nullable: true },
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
se: { type: 'number', nullable: true },
|
|
68
|
+
sev: { type: 'number', nullable: true },
|
|
69
|
+
ss: { type: 'number', nullable: true },
|
|
70
|
+
ssv: { type: 'number', nullable: true },
|
|
67
71
|
t: { type: 'boolean', nullable: true },
|
|
68
72
|
tu: { type: 'string', nullable: true },
|
|
69
73
|
v: { ...vectorSchema, nullable: true },
|