UNPKG

malwoden

Version:

![alt text](./coverage/badge-lines.svg) ![alt text](./coverage/badge-statements.svg) ![alt text](./coverage/badge-functions.svg) ![alt text](./coverage/badge-branches.svg)

87 lines (86 loc) 2.83 kB
import { IRNG } from "../rand"; import { Vector2 } from "../struct"; import { Rect } from "../struct/rect"; import { Builder } from "./builder"; interface BSPDungeonOptions<T> { width: number; height: number; wallTile: T; floorTile: T; rng?: IRNG; } interface BSPDungeonNodeOptions { v1: Vector2; v2: Vector2; rng: IRNG; } export declare class BSPDungeonNode extends Rect { private childA?; private childB?; private rng; private leafMinWidth; private leafMinHeight; constructor({ v1, v2, rng }: BSPDungeonNodeOptions); connectChildren(): void; private getRandomSplitDir; split(): void; getChildren(): BSPDungeonNode[]; isLeafNode(): boolean; splitVertical(): void; splitHorizontal(): void; } /** * DungeonGenerator creates a number of rooms, and then works to connect * them. */ export declare class BSPDungeonBuilder<T> extends Builder<T> { private rng; private hallways; private root; private rooms; private wallTile; private floorTile; constructor(config: BSPDungeonOptions<T>); getLeafNodes(): BSPDungeonNode[]; /** * Splits the dungeon n times. A count of 1 would divide the dungeon in two, * count of 2 divides it in 4, etc. * @param count - number */ splitByCount(count: number): void; /** * Creates rooms given the current BSP Tree. Use the 'split' method first to generate areas, then * call createRooms to generate rooms within those areas * * @param options - Options to create the rooms * @param options.minWidth - The minimum width of a generated room. * @param options.minHeight - The minimum height of a generated room. * @param options.maxWidth - The maximum width of a generated room. Will never be wider than the BSP area. * @param options.maxHeight - The maximum height of a generated room. Will never be taller than the BSP area. * @param options.padding - Can pad the area to ensure rooms aren't against the boundaries. Default 0. */ createRooms(options: { minWidth: number; minHeight: number; maxWidth?: number; maxHeight?: number; padding?: number; }): void; private carveRoom; /** * Gets all rooms created. These will each belong to a leaf node of the BSP Tree. * @returns Rect[] - A list of all rooms */ getRooms(): Rect[]; /** * Creates simple right angle hallways between existing rooms. * @returns BSPDungeon - Can be used for method chaining. */ createSimpleHallways(): void; /** * Returns a list of all hallways * @returns Vector2[][] - The hallways */ getHallways(): Vector2[][]; } export {};