RogueSharp
Show / Hide Table of Contents

Class FieldOfView

A class for performing field-of-view calculations to determine what is observable in a Map from a given Cell within a given light radius

Inheritance
System.Object
FieldOfView
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: RogueSharp
Assembly: RogueSharp.dll
Syntax
public class FieldOfView

Constructors

| Improve this Doc View Source

FieldOfView(IMap)

Constructs a new FieldOfView class for the specified Map

Declaration
public FieldOfView(IMap map)
Parameters
Type Name Description
IMap map

The Map that this FieldOfView class will use to perform its field-of-view calculations

Methods

| Improve this Doc View Source

AppendFov(Int32, Int32, Int32, Boolean)

Performs a field-of-view calculation with the specified parameters and appends it any existing field-of-view calculations. Field-of-view (FOV) is basically a calculation of what is observable in the Map from a given Cell with a given light radius.

Declaration
public ReadOnlyCollection<ICell> AppendFov(int xOrigin, int yOrigin, int radius, bool lightWalls)
Parameters
Type Name Description
System.Int32 xOrigin

X location of the Cell to perform the field-of-view calculation with 0 as the farthest left

System.Int32 yOrigin

Y location of the Cell to perform the field-of-view calculation with 0 as the top

System.Int32 radius

The number of Cells in which the field-of-view extends from the origin Cell. Think of this as the intensity of the light source.

System.Boolean lightWalls

True if walls should be included in the field-of-view when they are within the radius of the light source. False excludes walls even when they are within range.

Returns
Type Description
System.Collections.ObjectModel.ReadOnlyCollection<ICell>

List of Cells representing what is observable in the Map based on the specified parameters

Examples

When a character is holding a light source in a large area that also has several other sources of light such as torches along the walls ComputeFov could first be called for the character and then AppendFov could be called for each torch to give us the final combined FOV given all the light sources

| Improve this Doc View Source

Clone()

Create and return a deep copy of an existing FieldOfView class

Declaration
public FieldOfView Clone()
Returns
Type Description
FieldOfView

A deep copy of an existing FieldOfViewClass

| Improve this Doc View Source

ComputeFov(Int32, Int32, Int32, Boolean)

Performs a field-of-view calculation with the specified parameters. Field-of-view (FOV) is basically a calculation of what is observable in the Map from a given Cell with a given light radius. Any existing field-of-view calculations will be overwritten when calling this method.

Declaration
public ReadOnlyCollection<ICell> ComputeFov(int xOrigin, int yOrigin, int radius, bool lightWalls)
Parameters
Type Name Description
System.Int32 xOrigin

X location of the Cell to perform the field-of-view calculation with 0 as the farthest left

System.Int32 yOrigin

Y location of the Cell to perform the field-of-view calculation with 0 as the top

System.Int32 radius

The number of Cells in which the field-of-view extends from the origin Cell. Think of this as the intensity of the light source.

System.Boolean lightWalls

True if walls should be included in the field-of-view when they are within the radius of the light source. False excludes walls even when they are within range.

Returns
Type Description
System.Collections.ObjectModel.ReadOnlyCollection<ICell>

List of Cells representing what is observable in the Map based on the specified parameters

| Improve this Doc View Source

IsInFov(Int32, Int32)

Check if the Cell is in the currently computed field-of-view Field-of-view must first be calculated by calling ComputeFov and/or AppendFov

Declaration
public bool IsInFov(int x, int y)
Parameters
Type Name Description
System.Int32 x

X location of the Cell to check starting with 0 as the farthest left

System.Int32 y

Y location of the Cell to check, starting with 0 as the top

Returns
Type Description
System.Boolean

True if the Cell is in the currently computed field-of-view, false otherwise

Remarks

Field-of-view (FOV) is basically a calculation of what is observable in the Map from a given Cell with a given light radius

Examples

Field-of-view can be used to simulate a character holding a light source and exploring a Map representing a dark cavern Any Cells within the FOV would be what the character could see from their current location and lighting conditions

See Also

Based on the visibility determination algorithm described here
  • Improve this Doc
  • View Source
RogueSharp © 2014-2020 Faron Bracy
Back to top