Vents
This commit is contained in:
@@ -2,7 +2,7 @@ import type { ClientContext, Color } from "cubi/client";
|
||||
import type { ServerContext } from "cubi/server";
|
||||
import { DOOR, FACILITY_DOOR } from "./shared.ts";
|
||||
import { Alea } from "@paulaboks/rng";
|
||||
import { MAIN_TILE, type PlacedTile, plan_interior, tile_type, TILES } from "./interior.ts";
|
||||
import { MAIN_TILE, type Marker, type PlacedTile, plan_interior, tile_type, TILES } from "./interior.ts";
|
||||
|
||||
export { shared } from "./shared.ts";
|
||||
|
||||
@@ -129,6 +129,8 @@ function register_commands(ctx: ServerContext) {
|
||||
}
|
||||
|
||||
let interior_tiles: PlacedTile[] = [];
|
||||
// the vents placed in the interior, for monsters to come out of
|
||||
let interior_vents: Marker[] = [];
|
||||
|
||||
function clear_map(ctx: ServerContext) {
|
||||
// theres no need to clear the surface but we do need to clear each tile
|
||||
@@ -147,6 +149,9 @@ const INTERIOR_ORIGIN = { x: 0, y: 60, z: 0 };
|
||||
const DOOR_CHANCE = 0.8;
|
||||
const INTERIOR_DOOR = "dangerous_business:factory_door";
|
||||
const DOORWAY_WALL = "dangerous_business:sheet_wall";
|
||||
// how likely a vent spot is to get a vent, otherwise it's left empty
|
||||
const VENT_CHANCE = 0.65;
|
||||
const VENT = "dangerous_business:vent";
|
||||
|
||||
interface InteriorGenerationConfig {
|
||||
size_multiplier: number;
|
||||
@@ -173,5 +178,14 @@ function generate_interior(ctx: ServerContext, config: InteriorGenerationConfig)
|
||||
ctx.world.set_block(x, y, z, "cubi:air");
|
||||
}
|
||||
}
|
||||
interior_vents = [];
|
||||
for (const { x, y, z, facing } of plan.vent_spots) {
|
||||
if (rng.next() < VENT_CHANCE) {
|
||||
ctx.world.set_block(x, y, z, VENT, { facing });
|
||||
interior_vents.push({ x, y, z, facing });
|
||||
} else {
|
||||
ctx.world.set_block(x, y, z, "cubi:air");
|
||||
}
|
||||
}
|
||||
interior_tiles = plan.tiles;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user