Broadcast teleport landing sound to nearby users

This commit is contained in:
Jage9
2026-02-24 20:55:02 -05:00
parent a1132ea22a
commit 297f1c0c1a
9 changed files with 72 additions and 1 deletions

View File

@@ -158,6 +158,13 @@ export function createOnMessageHandler(deps: MessageHandlerDeps): (message: Inco
break;
}
case 'teleport_complete': {
if (deps.getAudioLayers().world) {
deps.playRemoteSpatialStepOrTeleport(deps.TELEPORT_SOUND_URL, message.x, message.y);
}
break;
}
case 'update_nickname': {
const peer = deps.state.peers.get(message.id);
if (peer) {

View File

@@ -103,6 +103,13 @@ export const updatePositionSchema = z.object({
y: z.number().int(),
});
export const teleportCompleteSchema = z.object({
type: z.literal('teleport_complete'),
id: z.string(),
x: z.number().int(),
y: z.number().int(),
});
export const updateNicknameSchema = z.object({
type: z.literal('update_nickname'),
id: z.string(),
@@ -199,6 +206,7 @@ export const incomingMessageSchema = z.discriminatedUnion('type', [
welcomeMessageSchema,
signalMessageSchema,
updatePositionSchema,
teleportCompleteSchema,
updateNicknameSchema,
userLeftSchema,
chatMessageSchema,
@@ -217,6 +225,7 @@ export type IncomingMessage = z.infer<typeof incomingMessageSchema>;
export type OutgoingMessage =
| { type: 'signal'; targetId: string; sdp?: RTCSessionDescriptionInit; ice?: RTCIceCandidateInit }
| { type: 'update_position'; x: number; y: number }
| { type: 'teleport_complete' }
| { type: 'update_nickname'; nickname: string }
| { type: 'chat_message'; message: string }
| { type: 'ping'; clientSentAt: number }