@hytopia.com/server-protocol 1.2.3 → 1.2.5
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 +1 -1
- package/packets/PacketCore.ts +7 -6
- package/packets/outbound/Audios.ts +12 -0
- package/packets/outbound/index.ts +1 -0
- package/schemas/Audio.ts +26 -0
- package/schemas/Audios.ts +10 -0
- package/schemas/PhysicsDebugRaycast.ts +3 -1
- package/schemas/index.ts +2 -0
package/package.json
CHANGED
package/packets/PacketCore.ts
CHANGED
|
@@ -26,12 +26,13 @@ export enum PacketId {
|
|
|
26
26
|
|
|
27
27
|
// Standard Outbound Packet Types: 32 - 127 range
|
|
28
28
|
SYNC_RESPONSE = 32,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
AUDIOS = 33,
|
|
30
|
+
BLOCKS = 34,
|
|
31
|
+
BLOCK_TYPES = 35,
|
|
32
|
+
CHAT_MESSAGES = 36,
|
|
33
|
+
CHUNKS = 37,
|
|
34
|
+
ENTITIES = 38,
|
|
35
|
+
WORLD = 39,
|
|
35
36
|
|
|
36
37
|
// Debug Inbound Packet Types: 128 - 191 range
|
|
37
38
|
DEBUG_CONFIG = 128,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
+
import type { IPacket } from '../PacketCore';
|
|
3
|
+
import { audiosSchema } from '../../schemas/Audios';
|
|
4
|
+
import type { AudiosSchema } from '../../schemas/Audios';
|
|
5
|
+
import type { WorldTick } from '../PacketCore';
|
|
6
|
+
|
|
7
|
+
export type AudiosPacket = IPacket<typeof PacketId.AUDIOS, AudiosSchema> & [WorldTick];
|
|
8
|
+
|
|
9
|
+
export const audiosPacketDefinition = definePacket(
|
|
10
|
+
PacketId.AUDIOS,
|
|
11
|
+
audiosSchema,
|
|
12
|
+
);
|
package/schemas/Audio.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { vectorSchema } from './Vector';
|
|
2
|
+
import type { JSONSchemaType } from 'ajv';
|
|
3
|
+
import type { VectorSchema } from './Vector';
|
|
4
|
+
|
|
5
|
+
export type AudioSchema = {
|
|
6
|
+
a: string; // audio uri
|
|
7
|
+
c?: VectorSchema; // coordinate of spatial audio origin
|
|
8
|
+
l?: boolean; // loop
|
|
9
|
+
o?: boolean; // one shot
|
|
10
|
+
s?: boolean; // stop
|
|
11
|
+
v?: number; // volume
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const audioSchema: JSONSchemaType<AudioSchema> = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
a: { type: 'string' },
|
|
18
|
+
c: { ...vectorSchema, nullable: true },
|
|
19
|
+
l: { type: 'boolean', nullable: true },
|
|
20
|
+
o: { type: 'boolean', nullable: true },
|
|
21
|
+
s: { type: 'boolean', nullable: true },
|
|
22
|
+
v: { type: 'number', nullable: true },
|
|
23
|
+
},
|
|
24
|
+
required: [ 'a' ],
|
|
25
|
+
additionalProperties: false,
|
|
26
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { audioSchema } from './Audio';
|
|
2
|
+
import type { JSONSchemaType } from 'ajv';
|
|
3
|
+
import type { AudioSchema } from './Audio';
|
|
4
|
+
|
|
5
|
+
export type AudiosSchema = AudioSchema[];
|
|
6
|
+
|
|
7
|
+
export const audiosSchema: JSONSchemaType<AudiosSchema> = {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: { ...audioSchema },
|
|
10
|
+
}
|
|
@@ -6,6 +6,7 @@ export type PhysicsDebugRaycastSchema = {
|
|
|
6
6
|
o: VectorSchema; // rapier raycast origin
|
|
7
7
|
d: VectorSchema; // rapier raycast direction
|
|
8
8
|
l: number; // rapier raycast length
|
|
9
|
+
h: boolean; // rapier raycast hit
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export const physicsDebugRaycastSchema: JSONSchemaType<PhysicsDebugRaycastSchema> = {
|
|
@@ -14,7 +15,8 @@ export const physicsDebugRaycastSchema: JSONSchemaType<PhysicsDebugRaycastSchema
|
|
|
14
15
|
o: { ...vectorSchema },
|
|
15
16
|
d: { ...vectorSchema },
|
|
16
17
|
l: { type: 'number' },
|
|
18
|
+
h: { type: 'boolean' },
|
|
17
19
|
},
|
|
18
|
-
required: [ 'o', 'd', 'l' ],
|
|
20
|
+
required: [ 'o', 'd', 'l', 'h' ],
|
|
19
21
|
additionalProperties: false,
|
|
20
22
|
}
|