Entity and block sounds !
This commit is contained in:
+7
-1
@@ -5,7 +5,7 @@
|
||||
// sounds.json, see docs/modding/resources/sounds.md. this decides what plays, an output (client/audio_output.ts in the
|
||||
// browser) plays it
|
||||
import { EverythingRegistry } from "@/common/everything_registry.ts";
|
||||
import { sound_range, sound_to_play, type SoundCategory, type SoundJson } from "@/common/mod_data.ts";
|
||||
import { sound_of, sound_range, sound_to_play, type SoundCategory, type SoundJson } from "@/common/mod_data.ts";
|
||||
import type { ClientPlayOptions, PlayingSound } from "@/common/mod_api/client.ts";
|
||||
import type { Position } from "@/common/mod_api/shared.ts";
|
||||
|
||||
@@ -172,6 +172,12 @@ export class Sounds {
|
||||
return playing;
|
||||
}
|
||||
|
||||
// the sound a block's or entity's "sounds" prefix has for kind, when it has one, see BLOCK_SOUNDS and ENTITY_SOUNDS
|
||||
play_of(prefix: string | undefined, kind: string, options: ClientPlayOptions) {
|
||||
const sound = sound_of(prefix, kind);
|
||||
if (sound) this.play(sound, options);
|
||||
}
|
||||
|
||||
// before each frame: the player hears from listener, sounds following an entity go where it's drawn
|
||||
frame(listener: Listener, entity_position: (id: string) => Position | undefined, volumes: Volumes) {
|
||||
this.#listener = { x: listener.x, y: listener.y, z: listener.z };
|
||||
|
||||
Reference in New Issue
Block a user