Show / Hide Table of Contents

Class FOV

Implements the capability to calculate a grid-based field of view for a map.

Inheritance
System.Object
FOV
Implements
IReadOnlyFOV
IMapView<System.Double>
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)
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
public class FOV : IReadOnlyFOV, IMapView<double>
Remarks

Generally, this class can be used to calculate and expose the results of a field of view calculation for a map. In includes many options pertaining to the shape and size of the field of view (including options for an infinite-radius field of view). As well, for non-infinite size fields of view, the result contains built-in linear distance falloff for the sake of creating lighting/color/fidelity differences based on distance from the center.

Like most GoRogue algorithms, FOV takes as a construction parameter an IMapView representing the map. Specifically, it takes an IMapView<T>, where true indicates that a tile should be considered transparent, eg. not blocking to line of sight, and false indicates that a tile should be considered opaque, eg. blocking to line of sight.

The field of view can then be calculated by calling one of the various Calculate overloads.

The result of the calculation is exposed in two different forms. First, the values are exposed to you via indexers -- the FOV class itself implements IMapView<T>, where a value of 1.0 represents the center of the field of view calculation, and 0.0 indicates a location that is not inside the resulting field of view at all. Values in between are representative of linear falloff based on distance from the source.

Alternatievly, if the distance from the source is irrelevant, FOV also provides the result of the calculation via BooleanFOV, which is an IMapView<T> where a value of true indicates that a location is within field of view, and a value of false indicates it is ouside of the field of view.

Constructors

| Improve this Doc View Source

FOV(IMapView<Boolean>)

Constructor.

Declaration
public FOV(IMapView<bool> fovMap)
Parameters
Type Name Description
IMapView<System.Boolean> fovMap

The values used to calculate field of view. Values of true are considered non-blocking (transparent) to line of sight, while false values are considered to be blocking.

Properties

| Improve this Doc View Source

BooleanFOV

A view of the calculation results in boolean form, where true indicates a location is inside field of view, and false indicates it is not.

Declaration
public IMapView<bool> BooleanFOV { get; }
Property Value
Type Description
IMapView<System.Boolean>
| Improve this Doc View Source

CurrentFOV

IEnumerable of only positions that are currently inside field of view.

Declaration
public IEnumerable<Coord> CurrentFOV { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<Coord>
| Improve this Doc View Source

Height

Height of the map view.

Declaration
public int Height { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Item[Coord]

Returns the field of view value for the given position.

Declaration
public double this[Coord position] { get; }
Parameters
Type Name Description
Coord position

The position to return the field of view value for.

Property Value
Type Description
System.Double

The field of view value for the given position.

| Improve this Doc View Source

Item[Int32]

Returns the field of view value for the given position.

Declaration
public double this[int index1D] { get; }
Parameters
Type Name Description
System.Int32 index1D

Position to return the field of view value for, as a 1D-index-style value.

Property Value
Type Description
System.Double

The field of view value for the given position.

| Improve this Doc View Source

Item[Int32, Int32]

Returns the field of view value for the given position.

Declaration
public double this[int x, int y] { get; }
Parameters
Type Name Description
System.Int32 x

X-coordinate of the position to return the FOV value for.

System.Int32 y

Y-coordinate of the position to return the FOV value for.

Property Value
Type Description
System.Double

The field of view value for the given position.

| Improve this Doc View Source

NewlySeen

IEnumerable of positions that ARE in field of view as of the most current Calculate call, but were NOT in field of view after the previous time Calculate was called.

Declaration
public IEnumerable<Coord> NewlySeen { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<Coord>
| Improve this Doc View Source

NewlyUnseen

IEnumerable of positions that are NOT in field of view as of the most current Calculate call, but WERE in field of view after the previous time Calculate was called.

Declaration
public IEnumerable<Coord> NewlyUnseen { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<Coord>
| Improve this Doc View Source

Width

Width of map view.

Declaration
public int Width { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

AsReadOnly()

Returns a read-only representation of the field of view.

Declaration
public IReadOnlyFOV AsReadOnly()
Returns
Type Description
IReadOnlyFOV

This FOV object, as an IReadOnlyFOV instance.

| Improve this Doc View Source

Calculate(Coord, Double)

Calculates FOV given an origin point and a radius. If no radius is specified, simply calculates with a radius of maximum integer value, which is effectively infinite. Radius is computed as a circle around the source (type CIRCLE).

Declaration
public void Calculate(Coord start, double radius = 1.7976931348623157E+308)
Parameters
Type Name Description
Coord start

Position of origin.

System.Double radius

The maximum radius -- basically the maximum distance of the field of view if completely unobstructed. If no radius is specified, it is effectively infinite.

| Improve this Doc View Source

Calculate(Coord, Double, Distance)

Calculates FOV given an origin point, a radius, and a radius shape.

Declaration
public void Calculate(Coord start, double radius, Distance distanceCalc)
Parameters
Type Name Description
Coord start

Coordinate of the origin.

System.Double radius

The maximum radius -- basically the maximum distance of the field of view if completely unobstructed.

Distance distanceCalc

The distance calculation used to determine what shape the radius has (or a type implicitly convertible to Distance, eg. Radius).

| Improve this Doc View Source

Calculate(Coord, Double, Distance, Double, Double)

Calculates FOV given an origin point, a radius, a radius shape, and the given field of view restrictions angle and span. The resulting field of view, if unobstructed, will be a cone defined by the angle and span given.

Declaration
public void Calculate(Coord start, double radius, Distance distanceCalc, double angle, double span)
Parameters
Type Name Description
Coord start

Coordinate of the origin.

System.Double radius

The maximum radius -- basically the maximum distance of the field of view if completely unobstructed.

Distance distanceCalc

The distance calculation used to determine what shape the radius has (or a type implicitly convertible to Distance, eg. Radius).

System.Double angle

The angle in degrees that specifies the outermost center point of the field of view cone. 0 degrees points right.

System.Double span

The angle, in degrees, that specifies the full arc contained in the field of view cone -- angle / 2 degrees are included on either side of the span line.

| Improve this Doc View Source

Calculate(Int32, Int32, Double)

Calculates FOV given an origin point and a radius. If no radius is specified, simply calculates with a radius of maximum integer value, which is effectively infinite. Radius is computed as a circle around the source (type CIRCLE).

Declaration
public void Calculate(int startX, int startY, double radius = 1.7976931348623157E+308)
Parameters
Type Name Description
System.Int32 startX

Coordinate x-value of the origin.

System.Int32 startY

Coordinate y-value of the origin.

System.Double radius

The maximum radius -- basically the maximum distance of the field of view if completely unobstructed. If no radius is specified, it is effectively infinite.

| Improve this Doc View Source

Calculate(Int32, Int32, Double, Distance)

Calculates FOV given an origin point, a radius, and radius shape.

Declaration
public void Calculate(int startX, int startY, double radius, Distance distanceCalc)
Parameters
Type Name Description
System.Int32 startX

Coordinate x-value of the origin.

System.Int32 startY

Coordinate y-value of the origin.

System.Double radius

The maximum radius -- basically the maximum distance of the field of view if completely unobstructed.

Distance distanceCalc

The distance calculation used to determine what shape the radius has (or a type implicitly convertible to Distance, eg. Radius).

| Improve this Doc View Source

Calculate(Int32, Int32, Double, Distance, Double, Double)

Calculates FOV given an origin point, a radius, a radius shape, and the given field of view restrictions angle and span. The resulting field of view, if unobstructed, will be a cone defined by the angle and span given.

Declaration
public void Calculate(int startX, int startY, double radius, Distance distanceCalc, double angle, double span)
Parameters
Type Name Description
System.Int32 startX

Coordinate x-value of the origin.

System.Int32 startY

Coordinate y-value of the origin.

System.Double radius

The maximum radius -- basically the maximum distance of the field of view if completely unobstructed.

Distance distanceCalc

The distance calculation used to determine what shape the radius has (or a type implicitly convertible to Distance, eg. Radius).

System.Double angle

The angle in degrees that specifies the outermost center point of the field of view cone. 0 degrees points right.

System.Double span

The angle, in degrees, that specifies the full arc contained in the field of view cone -- angle / 2 degrees are included on either side of the cone's center line.

| Improve this Doc View Source

ToString()

Returns a string representation of the map, where any location not in FOV is represented by a '-' character, and any position in FOV is represented by a '+'.

Declaration
public override string ToString()
Returns
Type Description
System.String

A (multi-line) string representation of the FOV.

Overrides
System.Object.ToString()
| Improve this Doc View Source

ToString(Char, Char)

ToString overload that customizes the characters used to represent the map.

Declaration
public string ToString(char normal = '-', char sourceValue = '+')
Parameters
Type Name Description
System.Char normal

The character used for any location not in FOV.

System.Char sourceValue

The character used for any location that is in FOV.

Returns
Type Description
System.String

The string representation of FOV, using the specified characters.

| Improve this Doc View Source

ToString(Int32)

Returns a string representation of the map, with the actual values in the FOV, rounded to the given number of decimal places.

Declaration
public string ToString(int decimalPlaces)
Parameters
Type Name Description
System.Int32 decimalPlaces

The number of decimal places to round to.

Returns
Type Description
System.String

A string representation of FOV, rounded to the given number of decimal places.

Implements

IReadOnlyFOV
IMapView<T>

Extension Methods

Utility.Yield<T>(T)
IMapViewExtensions.Bounds<T>(IMapView<T>)
IMapViewExtensions.Contains<T>(IMapView<T>, Int32, Int32)
IMapViewExtensions.Contains<T>(IMapView<T>, Coord)
IMapViewExtensions.ExtendToString<T>(IMapView<T>, String, String, Func<T, String>, String, String, String, String)
IMapViewExtensions.ExtendToString<T>(IMapView<T>, Int32, String, String, Func<T, String>, String, String, String, String)
IMapViewExtensions.Positions<T>(IMapView<T>)
IMapViewExtensions.RandomItem<T>(IMapView<T>, IGenerator)
IMapViewExtensions.RandomItem<T>(IMapView<T>, Func<Coord, T, Boolean>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, T, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IEnumerable<T>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, HashSet<T>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IGenerator, T[])
IMapViewExtensions.RandomPosition<T>(IMapView<T>, Func<Coord, T, Boolean>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IGenerator)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX