Fill on serverworld and clear out tiles on new day
This commit is contained in:
@@ -51,6 +51,8 @@ export interface PlacedTile {
|
||||
// where the schematic's lowest corner goes, before it's turned around it
|
||||
position: Position;
|
||||
rotation: 0 | 90 | 180 | 270;
|
||||
// the blocks it takes up once it's turned, its outer walls too
|
||||
box: Box;
|
||||
}
|
||||
|
||||
// a doorway in the world, once. connected when it has a tile on both sides, otherwise it leads nowhere and gets
|
||||
@@ -131,7 +133,7 @@ export function plan_interior(rng: { next(): number }, types: TileType[], config
|
||||
}
|
||||
|
||||
// the blocks a placed tile takes up, both corners in it
|
||||
interface Box {
|
||||
export interface Box {
|
||||
min: [number, number, number];
|
||||
max: [number, number, number];
|
||||
}
|
||||
@@ -148,8 +150,9 @@ function try_plan(rng: { next(): number }, types: TileType[], config: InteriorPl
|
||||
const used = new Set<string>();
|
||||
|
||||
const add = (type: TileType, position: Position, quarters: number) => {
|
||||
tiles.push({ tile: type.id, position, rotation: quarters * 90 as PlacedTile["rotation"] });
|
||||
boxes.push(tile_box(type, position, quarters));
|
||||
const box = tile_box(type, position, quarters);
|
||||
tiles.push({ tile: type.id, position, rotation: quarters * 90 as PlacedTile["rotation"], box });
|
||||
boxes.push(box);
|
||||
if (type.one_time) used.add(type.id);
|
||||
// a marker of this tile where it is in the world
|
||||
const placed_marker = (marker: Marker) => {
|
||||
|
||||
@@ -147,8 +147,13 @@ let interior_tiles: PlacedTile[] = [];
|
||||
// the vents placed in the interior, for monsters to come out of
|
||||
let interior_vents: Marker[] = [];
|
||||
|
||||
// takes away the last interior, so the next one goes in where there's nothing. the surface is placed over itself
|
||||
function clear_map(ctx: ServerContext) {
|
||||
// theres no need to clear the surface but we do need to clear each tile
|
||||
for (const { box: { min: [x0, y0, z0], max: [x1, y1, z1] } } of interior_tiles) {
|
||||
ctx.world.fill({ x: x0, y: y0, z: z0 }, { x: x1, y: y1, z: z1 }, "cubi:air");
|
||||
}
|
||||
interior_tiles = [];
|
||||
interior_vents = [];
|
||||
}
|
||||
|
||||
function place_surface(ctx: ServerContext) {
|
||||
|
||||
Reference in New Issue
Block a user