mwg API
    Preparing search index...

    Class Level

    Index
    height: number
    rooms: Roguelike.Rect[] = []

    rooms the generator carved, for placing stairs, monsters and treasure

    shape: LevelShape
    terrain: Uint8Array

    terrain id per cell, indexing into kinds

    viewDistance?: number

    default sight radius for observers that do not provide one explicitly

    width: number
    • The same neighbourhood as neighbors, but calling visit(nx, ny) per cell instead of building an array of them - the flood fills in Pathfinder call this per popped cell, where the array plus one object per neighbour was the hottest GC churn in the module (tens of thousands of short-lived objects per map). Anything that keeps a neighbour past the call still wants neighbors; this is for visit-and-forget loops.

      Parameters

      • x: number
      • y: number
      • topology: 4 | 8

        ignored on a hex Level - it only has the one neighbourhood shape

      • visit: (nx: number, ny: number) => void

      Returns void

    • True only for cells with a full ring of neighbours.

      Anything that inspects a cell's surroundings should use this rather than inside, because a cell on the very edge has no neighbour on one side and every such check then needs its own bounds test. Generators keep the border solid for the same reason.

      Parameters

      • x: number
      • y: number

      Returns boolean

    • The cells adjacent to (x, y) - six of them on a hex Level, four or eight on a square one, regardless of which. This is the seam that lets Pathfinder and FieldOfView work over either shape unchanged: they walk neighbours, and only this method knows what a neighbour is.

      Parameters

      • x: number
      • y: number
      • topology: 4 | 8 = 8

        ignored on a hex Level - it only has the one neighbourhood shape

      Returns { x: number; y: number }[]

    • every passable cell, as indices: the pool to place things in

      Returns number[]

    • Parameters

      • x: number
      • y: number
      • kind: number

      Returns void

    • Returns {
          height: number;
          rooms: Roguelike.Rect[];
          shape: LevelShape;
          terrain: number[];
          viewDistance?: number;
          width: number;
      }

    • Rebuilds a level from save data - the kinds table is supplied fresh (it holds a game's own terrain meanings, the same way QuestLog takes its definitions fresh), so only the terrain ids and rooms are ever save data.

      Parameters

      • kinds: TerrainKind[]
      • data: {
            height: number;
            rooms: Roguelike.Rect[];
            shape: LevelShape;
            terrain: number[];
            viewDistance?: number;
            width: number;
        }

      Returns Level