载入中...
搜索中...
未找到
eve::hexmap::HexVisibility类 参考

Fog-of-war bookkeeping: how many viewers currently see each cell. 更多...

#include <HexVisibility.h>

Public 成员函数

 HexVisibility ()=default
 Hex visibility.
 
void reset (std::int32_t cellCount)
 Sizes the counter array for cellCount cells and zeroes it.
 
std::int32_t cellCount () const noexcept
 Number of tracked cells.
 
bool isVisible (std::int32_t cellIndex) const noexcept
 Whether any viewer currently sees the cell.
 
std::int32_t visibility (std::int32_t cellIndex) const noexcept
 Number of viewers currently covering the cell.
 
std::int32_t visibleCellCount () const noexcept
 Number of cells with at least one viewer.
 
Result< void > increase (HexMap &map, HexSearchContext &scratch, HexCoordinates from, std::int32_t range)
 Adds one viewer at from.
 
Result< void > decrease (HexMap &map, HexSearchContext &scratch, HexCoordinates from, std::int32_t range)
 Removes one viewer at from.
 
void clear (HexMap &map) noexcept
 Drops every viewer, leaving the map's explored flags untouched.
 

详细描述

Fog-of-war bookkeeping: how many viewers currently see each cell.

Visibility is a counter, not a flag, because several actors overlap: a cell stops being visible only when the last viewer that covered it stops looking. The first time a cell becomes visible it is also marked explored, which is a one-way latch: explored cells stay explored after the viewer leaves and only the visibility counter drops.

Invariant: counts_[i] == 0 for every cell that no viewer covers, and counts_[i] > 0 exactly for the cells isVisible(i) reports.

Ownership and lifetime: owns one counter per cell; reset re-sizes it and clear zeroes it. It does not own the map it annotates.

Thread affinity: main thread only; no locking.

在文件 HexVisibility.h 第 32 行定义.

构造及析构函数说明

◆ HexVisibility()

eve::hexmap::HexVisibility::HexVisibility ( )
default

Hex visibility.

成员函数说明

◆ cellCount()

std::int32_t eve::hexmap::HexVisibility::cellCount ( ) const
inlinenoexcept

Number of tracked cells.

在文件 HexVisibility.h 第 46 行定义.

被这些函数引用 eve::hexmap::buildFogMesh() , 以及 reset().

◆ clear()

void eve::hexmap::HexVisibility::clear ( HexMap &  map)
noexcept

Drops every viewer, leaving the map's explored flags untouched.

Cells that lose their last viewer change the fog overlay, so their chunks are marked dirty in map, exactly as decrease does. Leaving that to the caller meant dropping the viewers could leave stale fog geometry on screen until an unrelated edit happened to dirty the same chunk.

参数
mapThe annotated map whose fog geometry is dirtied. @cost Proportional to the number of visible cells, not to the whole map.

在文件 HexVisibility.cpp 第 102 行定义.

引用了 index.

被这些函数引用 eve::hexmap::HexUnitRegistry::refreshVisibility() , 以及 eve::hexmap::HexUnitRegistry::restore().

◆ decrease()

Result< void > eve::hexmap::HexVisibility::decrease ( HexMap &  map,
HexSearchContext &  scratch,
HexCoordinates  from,
std::int32_t  range 
)

Removes one viewer at from.

Counters are clamped at zero, so a mismatched decrease cannot make a cell permanently invisible by going negative.

参数
mapMap being annotated.
scratchSearch scratch, resized to map.cellCount().
fromViewing cell.
rangeVision radius in cells.
返回
Success, or InvalidArgument when from is outside the grid. @cost Proportional to the visible region.

在文件 HexVisibility.cpp 第 76 行定义.

引用了 cells, eve::hexmap::HexMap::chunkIndexOf(), eve::hexmap::collectVisibleCells(), eve::hexmap::HexMap::coordinatesAt(), from, index, eve::hexmap::HexMap::markChunkDirtyAndNeighbors(), eve::Result< T >::ok(), range, eve::Result< T >::success() , 以及 valid.

被这些函数引用 eve::hexmap::HexUnitRegistry::advance(), eve::hexmap::HexUnitRegistry::beginTravel() , 以及 eve::hexmap::HexUnitRegistry::removeUnit().

◆ increase()

Result< void > eve::hexmap::HexVisibility::increase ( HexMap &  map,
HexSearchContext &  scratch,
HexCoordinates  from,
std::int32_t  range 
)

Adds one viewer at from.

参数
mapMap whose explored flags are latched; must contain from.
scratchSearch scratch, resized to map.cellCount().
fromViewing cell.
rangeVision radius in cells.
返回
Success, or InvalidArgument when from is outside the grid. @cost Proportional to the visible region.

在文件 HexVisibility.cpp 第 53 行定义.

引用了 cells, eve::hexmap::HexMap::chunkIndexOf(), eve::hexmap::collectVisibleCells(), eve::hexmap::HexMap::coordinatesAt(), from, index, eve::hexmap::HexMap::markChunkDirtyAndNeighbors(), eve::Result< T >::ok(), range, eve::hexmap::HexMap::setExplored(), eve::Result< T >::success() , 以及 valid.

被这些函数引用 eve::hexmap::HexUnitRegistry::addUnit(), eve::hexmap::HexUnitRegistry::advance(), eve::hexmap::HexUnitRegistry::beginTravel() , 以及 eve::hexmap::HexUnitRegistry::refreshVisibility().

◆ isVisible()

bool eve::hexmap::HexVisibility::isVisible ( std::int32_t  cellIndex) const
noexcept

Whether any viewer currently sees the cell.

在文件 HexVisibility.cpp 第 39 行定义.

被这些函数引用 eve::hexmap::buildFogMesh().

◆ reset()

void eve::hexmap::HexVisibility::reset ( std::int32_t  cellCount)

Sizes the counter array for cellCount cells and zeroes it.

参数
cellCountNumber of cells of the annotated map.
注解
This does not clear the map's explored flags; callers that rebuild a map get a fresh map whose flags are already clear.

在文件 HexVisibility.cpp 第 34 行定义.

引用了 cellCount() , 以及 u.

被这些函数引用 eve::hexmap::HexMapModule::adoptGrid(), eve::hexmap::HexMapModule::applyTerrain() , 以及 eve::hexmap::HexMapModule::newGrid().

◆ visibility()

std::int32_t eve::hexmap::HexVisibility::visibility ( std::int32_t  cellIndex) const
noexcept

Number of viewers currently covering the cell.

在文件 HexVisibility.cpp 第 44 行定义.

◆ visibleCellCount()

std::int32_t eve::hexmap::HexVisibility::visibleCellCount ( ) const
noexcept

Number of cells with at least one viewer.

在文件 HexVisibility.cpp 第 49 行定义.


该类的文档由以下文件生成: