@hytopia.com/server-protocol 1.3.35 → 1.3.36
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 +1 -0
- package/packets/outbound/Lights.ts +12 -0
- package/packets/outbound/index.ts +1 -0
- package/schemas/Light.ts +38 -0
- package/schemas/Lights.ts +10 -0
- package/schemas/index.ts +2 -0
package/package.json
CHANGED
package/packets/PacketCore.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
+
import type { IPacket } from '../PacketCore';
|
|
3
|
+
import { lightsSchema } from '../../schemas/Lights';
|
|
4
|
+
import type { LightsSchema } from '../../schemas/Lights';
|
|
5
|
+
import type { WorldTick } from '../PacketCore';
|
|
6
|
+
|
|
7
|
+
export type LightsPacket = IPacket<typeof PacketId.LIGHTS, LightsSchema> & [WorldTick];
|
|
8
|
+
|
|
9
|
+
export const lightsPacketDefinition = definePacket(
|
|
10
|
+
PacketId.LIGHTS,
|
|
11
|
+
lightsSchema,
|
|
12
|
+
);
|
package/schemas/Light.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { vectorSchema } from './Vector';
|
|
2
|
+
import { rgbColorSchema } from './RgbColor';
|
|
3
|
+
import type { JSONSchemaType } from 'ajv';
|
|
4
|
+
import type { RgbColorSchema } from './RgbColor';
|
|
5
|
+
import type { VectorSchema } from './Vector';
|
|
6
|
+
|
|
7
|
+
export type LightSchema = {
|
|
8
|
+
i: number; // light id
|
|
9
|
+
a?: number; // if spotlight, angle in radians
|
|
10
|
+
e?: number; // entity attachment, follows entity id
|
|
11
|
+
c?: RgbColorSchema; // light color
|
|
12
|
+
d?: number; // maximum distance of the light
|
|
13
|
+
n?: number; // light intensity
|
|
14
|
+
o?: VectorSchema; // offset
|
|
15
|
+
p?: VectorSchema; // spatial position of the light
|
|
16
|
+
te?: number; // if spotlight, tracked entity id
|
|
17
|
+
tp?: VectorSchema; // if spotlight, tracked position
|
|
18
|
+
t?: string; // light template id
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const lightSchema: JSONSchemaType<LightSchema> = {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
i: { type: 'number' },
|
|
25
|
+
a: { type: 'number', nullable: true },
|
|
26
|
+
e: { type: 'number', nullable: true },
|
|
27
|
+
c: { ...rgbColorSchema, nullable: true },
|
|
28
|
+
d: { type: 'number', nullable: true },
|
|
29
|
+
n: { type: 'number', nullable: true },
|
|
30
|
+
o: { ...vectorSchema, nullable: true },
|
|
31
|
+
p: { ...vectorSchema, nullable: true },
|
|
32
|
+
te: { type: 'number', nullable: true },
|
|
33
|
+
tp: { ...vectorSchema, nullable: true },
|
|
34
|
+
t: { type: 'string', nullable: true },
|
|
35
|
+
},
|
|
36
|
+
required: ['i'],
|
|
37
|
+
additionalProperties: false,
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { lightSchema } from './Light';
|
|
2
|
+
import type { JSONSchemaType } from 'ajv';
|
|
3
|
+
import type { LightSchema } from './Light';
|
|
4
|
+
|
|
5
|
+
export type LightsSchema = LightSchema[];
|
|
6
|
+
|
|
7
|
+
export const lightsSchema: JSONSchemaType<LightsSchema> = {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: { ...lightSchema },
|
|
10
|
+
}
|
package/schemas/index.ts
CHANGED
|
@@ -14,6 +14,8 @@ export * from './Entity';
|
|
|
14
14
|
export * from './Entities';
|
|
15
15
|
export * from './HexColor';
|
|
16
16
|
export * from './Input';
|
|
17
|
+
export * from './Light';
|
|
18
|
+
export * from './Lights';
|
|
17
19
|
export * from './PhysicsDebugRaycast';
|
|
18
20
|
export * from './PhysicsDebugRaycasts';
|
|
19
21
|
export * from './PhysicsDebugRender';
|