Documentation ¶
Index ¶
- type Algorithm
- type Cell
- type Light
- type Map
- type MapBBQ
- type MapBase
- func (fovMap *MapBase) BlocksLight(x, y int) bool
- func (fovMap *MapBase) BlocksMovement(x, y int) bool
- func (fovMap *MapBase) CheckBounds(x, y int) error
- func (fovMap *MapBase) Clear(fovCell Cell)
- func (fovMap *MapBase) CostAt(x, y int) (cost uint32)
- func (fovMap *MapBase) Height() int
- func (fovMap *MapBase) Lighting(x, y int) Light
- func (fovMap *MapBase) Reset()
- func (fovMap *MapBase) Resize(width, height int)
- func (fovMap *MapBase) SetBlocksLight(x, y int, blocks bool) error
- func (fovMap *MapBase) SetBlocksMovement(x, y int, blocks bool) error
- func (fovMap *MapBase) SetCell(x, y int, fovCell Cell) error
- func (fovMap *MapBase) SetLighting(x, y int, light Light) error
- func (fovMap *MapBase) SetVisible(x, y int, visible bool) error
- func (fovMap *MapBase) ToString(showVisible, showBlocksLight, showBlocksMovement, showLight bool) string
- func (fovMap *MapBase) Visible(x, y int) bool
- func (fovMap *MapBase) Width() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cell ¶
type Cell struct { Lighting Light Visible bool // Whether this cell is within the FoV. BlocksLight bool BlocksMovement bool }
Cell is the state for a given position in an FoVMap.
type Map ¶
type Map interface { Width() int Height() int CostAt(x, y int) uint32 Resize(width, height int) Clear(fovCell Cell) Reset() Recompute(cX, cY int, radius int, light Light) Compute(cX, cY int, radius int, light Light) SetCell(x, y int, fovCell Cell) error BlocksMovement(x, y int) bool SetBlocksMovement(x, y int, blocks bool) error BlocksLight(x, y int) bool SetBlocksLight(x, y int, blocks bool) error Visible(x, y int) bool SetVisible(x, y int, visible bool) error Lighting(x, y int) Light SetLighting(x, y int, light Light) error CheckBounds(x, y int) error ToString(showVisible, showBlocksLight, showBlocksMovement, showLight bool) string }
Map is our interface for field of view Maps.
type MapBBQ ¶
type MapBBQ struct {
MapBase
}
MapBBQ represents a 2D structure for calculating a field of view.
func NewMapBBQ ¶
NewMapBBQ returns an field of view Map sized to the given width and height using the BBQ algorithm.
type MapBase ¶
type MapBase struct {
// contains filtered or unexported fields
}
MapBase is the base implementation of our Map interface. It is used as an embedded structure within most Map implementations.
func (*MapBase) BlocksLight ¶
BlocksLight checks if the cell at x and y blocks light. Returns true if x or y is out of bounds.
func (*MapBase) BlocksMovement ¶
BlocksMovement checks if the cell at x and y blocks movement. Returns true if x or y is out of bounds.
func (*MapBase) CheckBounds ¶
CheckBounds returns an error if the provided x and y is out of bounds.
func (*MapBase) CostAt ¶
Height returns the movement cost of a tile in a map. This allows fov.Maps to be used for pathing.
func (*MapBase) Lighting ¶
Lighting returns the lighting value for a given cell. Returns 0 if x or y is out of bounds.
func (*MapBase) Reset ¶
func (fovMap *MapBase) Reset()
Reset resets the visibility state of all cells.
func (*MapBase) SetBlocksLight ¶
SetBlocksLight sets the blocksLight property of the cell at x and y to blocks.
func (*MapBase) SetBlocksMovement ¶
SetBlocksMovement sets the blocksMovement property of the cell at x and y to blocks.
func (*MapBase) SetLighting ¶
SetLighting sets a given cell's lighting value to the one provided.
func (*MapBase) SetVisible ¶
SetVisible sets whether a given cell is considered as within the FoV.
func (*MapBase) ToString ¶
func (fovMap *MapBase) ToString(showVisible, showBlocksLight, showBlocksMovement, showLight bool) string
ToString returns a stringified view of the map.