Jester and coilhead sounds
This commit is contained in:
@@ -36,6 +36,8 @@ import { RecipeBook } from "@/common/mod_loader.ts";
|
||||
import type { EntityJson } from "@/common/mod_data.ts";
|
||||
import { mod_entity_factory } from "@/server/game/entity/mod_entity.ts";
|
||||
import type { Mob } from "@/server/game/entity/mob.ts";
|
||||
import type { SoundFile, SoundOutput, Voice, VoiceSettings, Volumes } from "@/client/sounds.ts";
|
||||
import type { Position } from "@/common/mod_api/shared.ts";
|
||||
|
||||
// the repo's own mods/, read once: reading and checking every mod's files is most of starting a game in a test. only
|
||||
// mods/ is kept, since tests change the temporary folders they make between games
|
||||
@@ -482,3 +484,40 @@ export async function errors_during(fn: () => unknown): Promise<string[]> {
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
// a client's sound output that only keeps what it was told, see client/sounds.ts
|
||||
export class ListVoice implements Voice {
|
||||
ended = false;
|
||||
stopped = false;
|
||||
constructor(readonly file: SoundFile, public settings: VoiceSettings) {}
|
||||
move(at: Position) {
|
||||
this.settings = { ...this.settings, at };
|
||||
}
|
||||
set(volume: number, pitch: number, range: number) {
|
||||
this.settings = { ...this.settings, volume, pitch, range };
|
||||
}
|
||||
stop() {
|
||||
this.stopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
export class ListOutput implements SoundOutput {
|
||||
// false like a browser before the player's first click
|
||||
ready = true;
|
||||
voices: ListVoice[] = [];
|
||||
start(file: SoundFile, settings: VoiceSettings) {
|
||||
if (!this.ready) return undefined;
|
||||
const voice = new ListVoice(file, settings);
|
||||
this.voices.push(voice);
|
||||
return voice;
|
||||
}
|
||||
listen() {}
|
||||
set_volumes() {}
|
||||
// the ones still going
|
||||
get playing() {
|
||||
return this.voices.filter((voice) => !voice.stopped && !voice.ended);
|
||||
}
|
||||
}
|
||||
|
||||
// every sound category at full volume
|
||||
export const VOLUMES: Volumes = { master: 1, music: 1, ambient: 1, blocks: 1, entities: 1, players: 1, ui: 1 };
|
||||
|
||||
Reference in New Issue
Block a user