10#ifndef TILEAREA_ORTHOGONAL_H
11#define TILEAREA_ORTHOGONAL_H
75 return TileAddXY(this->tile, this->w / 2, this->h / 2);
133 }
else if (--this->y > 0) {
156 inline std::default_sentinel_t
end()
const
158 return std::default_sentinel_t();
Iterator to iterate over a tile area (rectangle) of the map.
TileIndex operator*() const
Get the current tile.
void pointer
pointer iterator trait
iterator(const OrthogonalTileArea &ta)
Construct the iterator.
std::ptrdiff_t difference_type
difference_type iterator trait
bool operator==(const iterator &) const =default
Compare with other iterator.
int y
The current 'y' position in the rectangle.
void reference
reference iterator trait
TileIndex tile
The current tile.
std::forward_iterator_tag iterator_category
iterator_category iterator trait
int x
The current 'x' position in the rectangle.
int w
The width of the iterated area.
TileIndex value_type
value_type iterator trait
iterator & operator++()
Increment the iterator and set it to the next position.
bool operator==(const std::default_sentinel_t &) const
Compare with end sentinel.
Represents the covered area of e.g.
void ClampToMap()
Clamp the tile area to map borders.
void Add(const OrthogonalTileArea &area)
Add another tile area to this tile area.
bool Contains(TileIndex tile) const
Does this tile area contain a tile?
uint16_t w
The width of the area.
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
bool Intersects(const OrthogonalTileArea &ta) const
Does this tile area intersect with another?
std::default_sentinel_t end() const
Returns an iterator to the end of the tile area.
void Clear()
Clears the 'tile area', i.e.
TileIndex tile
The base tile of the area.
TileIndex GetCentreTile() const
Get the centre tile.
bool IsEmpty() const
Test if this tile area is empty.
uint16_t h
The height of the area.
OrthogonalTileArea(TileIndex tile=INVALID_TILE, uint16_t w=0, uint16_t h=0)
Construct this tile area with some set values.
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
iterator begin() const
Returns an iterator to the start of the tile area.
Functions related to maps.
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.