Jester and coilhead sounds

This commit is contained in:
2026-11-22 07:54:31 -03:00
parent 8e587f6446
commit da44685f54
31 changed files with 249 additions and 62 deletions
+11 -5
View File
@@ -110,13 +110,16 @@ function register_facility_door(ctx: SharedContext) {
});
}
// the door component's params: "pairs_with" is the tag of doors it makes double doors with
// the door component's params: "pairs_with" is the tag of doors it makes double doors with, and the sounds it makes
// opening and closing
export interface DoorParams {
pairs_with: string;
open_sound: string;
close_sound: string;
}
// what set_door_open needs, which shared, server and client phases all have
type DoorContext = Pick<SharedContext, "tags"> & {
// what set_door_open needs, which shared and server phases both have
type DoorContext = Pick<SharedContext, "tags" | "sounds"> & {
world: Pick<SharedContext["world"], "get_block" | "get_state" | "set_state">;
};
@@ -128,11 +131,14 @@ function door_at(ctx: DoorContext, x: number, y: number, z: number, params: Door
}
// opens (open 1) or closes (open 0) the door with a half at x y z: both its halves, and the other door of a double
// door with it when it's open or closed like this one. players do it by clicking, monsters from their goals. returns
// whether it changed
// door with it when it's open or closed like this one, with its sound. players do it by clicking, monsters from their
// goals. returns whether it changed
export function set_door_open(ctx: DoorContext, x: number, y: number, z: number, open: number, params: DoorParams) {
const lower = ctx.world.get_state(x, y, z, "half") ? y - 1 : y;
const state = (name: string, at_x = x, at_z = z) => ctx.world.get_state(at_x, lower, at_z, name);
if (state("open") !== open) {
ctx.sounds.play(open ? params.open_sound : params.close_sound, x + 0.5, lower + 1, z + 0.5);
}
// both halves of the door whose lower half is at x z
const set_halves = (at_x: number, at_z: number) => {
if (ctx.world.get_block(at_x, lower + 1, at_z) === ctx.world.get_block(at_x, lower, at_z)) {