Options
All
  • Public
  • Public/Protected
  • All
Menu

A manager used for storing objects of type T as "cells" and providing methods to manipulate them.

Type parameters

  • T

Hierarchy

  • Map3D

Index

Properties

Private cellGrids

cellGrids: Map<T, IGrid> = new Map()

Stores grid locations of all cells, indexed by cell. This can be used to retrieve the location of any cell in the map.

Note: Methods returning grids from this data should always return shallow copies.

Private cellMap

cellMap: Map<string, Set<T>> = new Map()

Stores the cells indexed by grid location. Use Map3D.gridToHash to generate the hash string used for indexing.

Note: Methods returning sets from this data should always return shallow copies.

Static Directions

Directions: Record<Direction, IGridDirection> = {east: { x: 1, y: 0, z: 0, direction: Direction.East },west: { x: -1, y: 0, z: 0, direction: Direction.West },south: { y: 1, x: 0, z: 0, direction: Direction.South },north: { y: -1, x: 0, z: 0, direction: Direction.North },} as const

A constant containing objects that represent the four cardinal directions.

Note: This can be used when creating Hop components.

Methods

addCellToGrid

  • addCellToGrid(cell: T, grid: IGrid): Set<T>
  • Adds a cell to the specified grid location, and returns a Set containing the cells at that location.

    Parameters

    • cell: T

      The map cell to be added.

    • grid: IGrid

      The grid location to add the cell to.

    Returns Set<T>

    • A Set containing the cells at the input grid location.

getCellGrid

  • getCellGrid(cell: T): IGrid | undefined
  • Returns the grid location of a cell in the map.

    Parameters

    • cell: T

      The map cell to obtain the grid from.

    Returns IGrid | undefined

    • The grid location of the input cell.

getCellsAtGrid

  • getCellsAtGrid(grid: IGrid): Set<T>
  • Gets the cells at a specified grid location.

    Parameters

    • grid: IGrid

      The grid location to retrieve cells from.

    Returns Set<T>

    • A Set containing the cells at the input grid location.

moveCellToGrid

  • moveCellToGrid(cell: T, grid: IGrid): Set<T>
  • Moves a cell to the specified grid location, and returns a Set containing the cells at that location.

    Parameters

    • cell: T

      The map cell to be moved.

    • grid: IGrid

      The grid location to move the cell to.

    Returns Set<T>

    • A Set containing the cells at the input grid location.

removeCellFromGrid

  • removeCellFromGrid(cell: T, grid: IGrid): Set<T>
  • Removes a cell from the specified grid location, and returns a Set containing the cells at that location.

    Parameters

    • cell: T

      The map cell to be removed.

    • grid: IGrid

      The grid location to remove the cell from.

    Returns Set<T>

    • A Set containing the cells at the input grid location.

Static addGrids

Static gridToHash

  • gridToHash(__namedParameters: { x: number; y: number; z: number }): string
  • Returns the string representation (hash) of a grid.

    Note: This hash is used to index the cellMap of Map3D.

    Parameters

    • __namedParameters: { x: number; y: number; z: number }

      The grid object to convert into a hash.

      • x: number
      • y: number
      • z: number

    Returns string

    • Grid coordinates in string format.

Generated using TypeDoc