Sounds on the client
This commit is contained in:
@@ -49,6 +49,7 @@ import { biome_season } from "@/common/worldgen/biomes.ts";
|
||||
import { clock, farming_day } from "@/common/time.ts";
|
||||
import type { LootTableJson } from "@/common/loot.ts";
|
||||
import type { ClipJson } from "@/common/mod_data.ts";
|
||||
import { sounds } from "./sounds.ts";
|
||||
|
||||
// each loaded mod's credits file, for the credits screen
|
||||
export const mod_credits: { name: string; version: string; text: string }[] = [];
|
||||
@@ -200,6 +201,7 @@ export async function load_client_mods(listings: ModListing[], mods: Mod[]) {
|
||||
}
|
||||
|
||||
const recipes = register_mod_data(mods.map((mod) => ({ id: mod.manifest.id, data: mod.data })));
|
||||
sounds.set_files(mods.map((mod) => ({ id: mod.manifest.id, sounds: mod.sounds })));
|
||||
recipe_book = recipes;
|
||||
inventory_overlays.length = 0;
|
||||
hud_layers.length = 0;
|
||||
@@ -448,6 +450,13 @@ function client_context(listing: ModListing): ClientContext {
|
||||
return Object.freeze({ id, length: json.length, loop: json.loop });
|
||||
},
|
||||
},
|
||||
sounds: {
|
||||
play(sound, options) {
|
||||
if (!sounds.exists(sound)) throw new Error(`[${mod}] unknown sound ${sound}`);
|
||||
return sounds.play(sound, options);
|
||||
},
|
||||
exists: (sound) => sounds.exists(sound),
|
||||
},
|
||||
log: (...args) => console.log(`[${mod}]`, ...args),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user