Asset dump

This commit is contained in:
2026-11-16 23:21:15 -03:00
parent 7369bf2e5f
commit 94b0e3789c
427 changed files with 43094 additions and 0 deletions
+60
View File
@@ -10,6 +10,66 @@ const FACING_STEPS = [[0, -1], [1, 0], [0, 1], [-1, 0]];
export function shared(ctx: SharedContext) {
register_door(ctx);
register_facility_door(ctx);
register_half(ctx);
register_connects(ctx);
register_random_look(ctx);
}
// slabs and the like: in the top half (half 1) when placed against the underside of a block or the upper half of a
// side, in the bottom half otherwise
function register_half(ctx: SharedContext) {
ctx.components.register_block("dangerous_business:half", {
state_for_placement(placement) {
if (placement.face === "top" || placement.face === "bottom") {
return { half: placement.face === "bottom" ? 1 : 0 };
}
return { half: placement.hit[1] > 0.5 ? 1 : 0 };
},
});
}
// sets its north, east, south and west states (and top, with "up") to 1 where the same block is beside it, so it can
// hide its edges there, like floor grates joining into one floor
function register_connects(ctx: SharedContext) {
const sides = (id: string | undefined, x: number, y: number, z: number, up: boolean) => {
const same = (dx: number, dy: number, dz: number) => ctx.world.get_block(x + dx, y + dy, z + dz) === id ? 1 : 0;
const states: Record<string, number> = {
north: same(0, 0, -1),
east: same(1, 0, 0),
south: same(0, 0, 1),
west: same(-1, 0, 0),
};
if (up) states.top = same(0, 1, 0);
return states;
};
ctx.components.register_block<{ up?: boolean }>("dangerous_business:connects", {
// the block being placed is the item's
state_for_placement: (placement, params) =>
sides(placement.item, placement.x, placement.y, placement.z, params.up ?? false),
on_neighbor_change(block, params) {
const id = ctx.world.get_block(block.x, block.y, block.z);
for (const [state, value] of Object.entries(sides(id, block.x, block.y, block.z, params.up ?? false))) {
ctx.world.set_state(block.x, block.y, block.z, state, value);
}
},
});
}
// picks some of its states when placed, from where it is, so the client and the server pick the same: a puddle's
// shape and turn, a bookshelf's books. "states" is how many values each can have
function register_random_look(ctx: SharedContext) {
ctx.components.register_block<{ states: Record<string, number> }>("dangerous_business:random_look", {
state_for_placement(placement, params) {
let seed = Math.imul(placement.x, 73856093) ^ Math.imul(placement.y, 19349663) ^
Math.imul(placement.z, 83492791);
const states: Record<string, number> = {};
for (const [state, count] of Object.entries(params.states)) {
seed = Math.imul(seed ^ (seed >>> 15), 2246822519) >>> 0;
states[state] = seed % count;
}
return states;
},
});
}
// a door is two blocks, its lower half (half 0) and its upper half (half 1), with the same states. it faces the way the