Struct GridCell

Struct Documentation

struct GridCell

Struct for a 2D grid cell.

Members:

  • x: The x coordinate of the cell

  • y: The y coordinate of the cell

Public Functions

inline bool operator<(const GridCell &other) const

Implement < operator for use as key in std::map.

Parameters:

other – The GridCell to compare against

Returns:

Is this less than other?

inline bool operator==(const GridCell &other) const

Implement == to allow comparisons

Parameters:

other – The GridCell to compare against

Returns:

Is this eq to other?

inline bool operator!=(const GridCell &other) const

Implement != to allow comparisons

Parameters:

other – The GridCell to compare against

Returns:

Is this not eq to other?

inline GridCell operator+(const GridCell &other) const

Implement + to make field of view calaculations simpler.

Parameters:

other – The GridCell to add

Returns:

The summed grid cell.

bool outOfBounds(const int &xMin, const int &xMax, const int &yMin, const int &yMax) const

Function to check if a grid cell is out of bounds on a given map. The bounds are defined as [xMin, xMax) and yMin, yMax.

Parameters:
  • xMin – The min x value

  • xMax – The max x value

  • yMin – The min y value

  • yMax – The max y value

Public Members

int x = {}
int y = {}