LambdaHack-0.9.3.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe HaskellNone
LanguageHaskell2010

Game.LambdaHack.Server.Fov

Contents

Description

Field Of View scanning.

See https://github.com/LambdaHack/LambdaHack/wiki/Fov-and-los for discussion.

Synopsis

Perception cache

data FovValid a Source #

Constructors

FovValid a 
FovInvalid 
Instances
Eq a => Eq (FovValid a) Source # 
Instance details

Defined in Game.LambdaHack.Server.Fov

Methods

(==) :: FovValid a -> FovValid a -> Bool #

(/=) :: FovValid a -> FovValid a -> Bool #

Show a => Show (FovValid a) Source # 
Instance details

Defined in Game.LambdaHack.Server.Fov

Methods

showsPrec :: Int -> FovValid a -> ShowS #

show :: FovValid a -> String #

showList :: [FovValid a] -> ShowS #

type PerValidFid = EnumMap FactionId (EnumMap LevelId Bool) Source #

Main perception validity map, for all factions.

newtype PerReachable Source #

Visually reachable positions (light passes through them to the actor). They need to be intersected with lucid positions to obtain visible positions.

Constructors

PerReachable 

type PerCacheLid = EnumMap LevelId PerceptionCache Source #

Server cache of perceptions of a single faction, indexed by level identifier.

type PerCacheFid = EnumMap FactionId PerCacheLid Source #

Server cache of perceptions, indexed by faction identifier.

Data used in FOV computation and cached to speed it up

newtype FovShine Source #

Map from level positions that currently hold item or actor(s) with shine to the maximum of radiuses of the shining lights.

Note that floor and (many projectile) actors light on a single tile should be additive for FovShine to be incrementally updated.

FovShine should not even be kept in StateServer, because it's cheap to compute, compared to FovLucid and invalidated almost as often (not invalidated only by UpdAlterTile).

Constructors

FovShine 
Instances
Eq FovShine Source # 
Instance details

Defined in Game.LambdaHack.Server.Fov

Show FovShine Source # 
Instance details

Defined in Game.LambdaHack.Server.Fov

newtype FovLucid Source #

Level positions with either ambient light or shining items or actors.

Constructors

FovLucid 
Instances
Eq FovLucid Source # 
Instance details

Defined in Game.LambdaHack.Server.Fov

Show FovLucid Source # 
Instance details

Defined in Game.LambdaHack.Server.Fov

newtype FovClear Source #

Level positions that pass through light and vision.

Constructors

FovClear 

Fields

Instances
Eq FovClear Source # 
Instance details

Defined in Game.LambdaHack.Server.Fov

Show FovClear Source # 
Instance details

Defined in Game.LambdaHack.Server.Fov

newtype FovLit Source #

Level positions with tiles that have ambient light.

Constructors

FovLit 

Fields

Instances
Eq FovLit Source # 
Instance details

Defined in Game.LambdaHack.Server.Fov

Methods

(==) :: FovLit -> FovLit -> Bool #

(/=) :: FovLit -> FovLit -> Bool #

Show FovLit Source # 
Instance details

Defined in Game.LambdaHack.Server.Fov

Operations

perceptionFromPTotal :: FovLucid -> CacheBeforeLucid -> Perception Source #

Compute positions visible (reachable and seen) by the party. A position is lucid, if it's lit by an ambient light or by a weak, portable light source, e.g,, carried by an actor. A reachable and lucid position is visible. Additionally, positions directly adjacent to an actor are assumed to be visible to him (through sound, touch, noctovision, whatever).

lucidFromLevel :: FovClearLid -> FovLitLid -> State -> LevelId -> Level -> FovLucid Source #

Update lights on the level. This is needed every (even enemy) actor move to show thrown torches. We need to update lights even if cmd doesn't change any perception, so that for next cmd that does, but doesn't change lights, and operates on the same level, the lights are up to date. We could make lights lazy to ensure no computation is wasted, but it's rare that cmd changed them, but not the perception (e.g., earthquake in an uninhabited corner of the active arena, but the we'd probably want some feedback, at least sound).

perFidInDungeon :: State -> (FovLitLid, FovClearLid, FovLucidLid, PerValidFid, PerCacheFid, PerFid) Source #

Calculate the perception and its caches for the whole dungeon.

Internal operations

cacheBeforeLucidFromActor :: FovClear -> Actor -> Skills -> CacheBeforeLucid Source #

Compute positions reachable by the actor. Reachable are all fields on a visually unblocked path from the actor position. Also compute positions seen by noctovision and perceived by smell.

lucidFromItems :: FovClear -> [(Point, Int)] -> [FovLucid] Source #

Compute all dynamically lit positions on a level, whether lit by actors or shining floor items. Note that an actor can be blind, in which case he doesn't see his own light (but others, from his or other factions, possibly do).

perLidFromFaction :: FovLucidLid -> FovClearLid -> FactionId -> State -> (PerLid, PerCacheLid) Source #

Calculate perception of a faction.

type Matrix = (Int, Int, Int, Int) Source #

fullscan Source #

Arguments

:: Int

scanning radius

-> Point

position of the spectator

-> FovClear

the array with clear positions

-> EnumSet Point 

Perform a full scan for a given position. Returns the positions that are currently in the field of view. The actor's own position is considred in his field of view.