Show / Hide Table of Contents

Class FOVBase

Base class that is convenient for creating custom implementations of the IFOV interface.

Inheritance
object
FOVBase
BooleanBasedFOVBase
DoubleBasedFOVBase
Implements
IFOV
IReadOnlyFOV
Inherited Members
object.GetType()
object.MemberwiseClone()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: GoRogue.FOV
Assembly: GoRogue.dll
Syntax
public abstract class FOVBase : IFOV, IReadOnlyFOV
Remarks

This class implements much of the boilerplate code required to implement IFOV properly, making sure that the implementer has to implement only the minimal subset of functions and properties.

An implementer should implement the OnCalculate overloads to perform their FOV calculation. Notably, these functions SHOULD NOT call Reset() nor perform any equivalent functionality, and SHOULD NOT fire the Recalculated or VisibilityReset events. All of this is taken care of by the Calculate and CalculateAppend functions, which call OnCalculate.

The implementation of OnCalculate, therefore, must not make any assumptions that squares start at a light level of 0, or any other light level. It should responsibly handle overlapping with other values, an assume that any value it does see at a location is a valid one. Therefore, the highest of the number currently present and the new number should always be kept.

Constructors

View Source

FOVBase(IGridView<bool>)

Constructor.

Declaration
protected FOVBase(IGridView<bool> transparencyView)
Parameters
Type Name Description
IGridView<bool> transparencyView

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

View Source

BooleanResultView

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

Declaration
public abstract IGridView<bool> BooleanResultView { get; }
Property Value
Type Description
IGridView<bool>
View Source

CalculationsPerformed

A list of the parameters passed to each call to Calculate/CalculateAppend that has been performed since the last reset, in the order in which they were called.

Declaration
public IReadOnlyList<FOVCalculateParameters> CalculationsPerformed { get; }
Property Value
Type Description
IReadOnlyList<FOVCalculateParameters>
View Source

CurrentFOV

IEnumerable of only positions currently in the field of view.

Declaration
public abstract IEnumerable<Point> CurrentFOV { get; }
Property Value
Type Description
IEnumerable<Point>
View Source

DoubleResultView

A view of the calculation results in double form, where a value greater than 0.0 indicates that the value is inside of FOV, and a value of 1.0 indicates the center point. All other values vary between 0.0 and 1.0, decreasing as positions get farther away from the center point.

Declaration
public abstract IGridView<double> DoubleResultView { get; }
Property Value
Type Description
IGridView<double>
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 abstract IEnumerable<Point> NewlySeen { get; }
Property Value
Type Description
IEnumerable<Point>
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 abstract IEnumerable<Point> NewlyUnseen { get; }
Property Value
Type Description
IEnumerable<Point>
View Source

TransparencyView

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.

Declaration
public IGridView<bool> TransparencyView { get; }
Property Value
Type Description
IGridView<bool>

Methods

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.

View Source

Calculate(Point, double)

Calculates FOV given an origin point and a radius, overwriting the current FOV entirely. 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(Point origin, double radius = 1.7976931348623157E+308)
Parameters
Type Name Description
Point origin

Position of origin.

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.

View Source

Calculate(Point, double, Distance)

Calculates FOV given an origin point, a radius, and a radius shape, overwriting the current FOV entirely.

Declaration
public void Calculate(Point origin, double radius, Distance distanceCalc)
Parameters
Type Name Description
Point origin

Coordinate of the origin.

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).

View Source

Calculate(Point, 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 current field of view will be entirely overwritten with the new one. The resulting field of view, if unobstructed, will be a cone defined by the angle and span given.

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

Coordinate of the origin.

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).

double angle

The angle in degrees that specifies the outermost center point of the field of view cone. 0 degrees points up, and angle increases result in the cone moving clockwise (like a compass).

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.

View Source

Calculate(int, int, double)

Calculates FOV given an origin point and a radius, overwriting the current FOV entirely. 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 originX, int originY, double radius = 1.7976931348623157E+308)
Parameters
Type Name Description
int originX

Coordinate x-value of the origin.

int originY

Coordinate y-value of the origin.

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.

View Source

Calculate(int, int, double, Distance)

Calculates FOV given an origin point, a radius, and radius shape, overwriting the current FOV entirely.

Declaration
public void Calculate(int originX, int originY, double radius, Distance distanceCalc)
Parameters
Type Name Description
int originX

Coordinate x-value of the origin.

int originY

Coordinate y-value of the origin.

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).

View Source

Calculate(int, int, 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 current field of view will be entirely overwritten with the new one. The resulting field of view, if unobstructed, will be a cone defined by the angle and span given.

Declaration
public void Calculate(int originX, int originY, double radius, Distance distanceCalc, double angle, double span)
Parameters
Type Name Description
int originX

Coordinate x-value of the origin.

int originY

Coordinate y-value of the origin.

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).

double angle

The angle in degrees that specifies the outermost center point of the field of view cone. 0 degrees points up, and angle increases result in the cone moving clockwise (like a compass).

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.

View Source

CalculateAppend(Point, double)

Calculates FOV given an origin point and a radius, adding the result onto the currently visible cells. 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 CalculateAppend(Point origin, double radius = 1.7976931348623157E+308)
Parameters
Type Name Description
Point origin

Position of origin.

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.

View Source

CalculateAppend(Point, double, Distance)

Calculates FOV given an origin point, a radius, and a radius shape, , adding the result onto the currently visible cells.

Declaration
public void CalculateAppend(Point origin, double radius, Distance distanceCalc)
Parameters
Type Name Description
Point origin

Coordinate of the origin.

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).

View Source

CalculateAppend(Point, 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 new field of view will be added onto the current one. The resulting field of view, if unobstructed, will be a cone defined by the angle and span given.

Declaration
public void CalculateAppend(Point origin, double radius, Distance distanceCalc, double angle, double span)
Parameters
Type Name Description
Point origin

Coordinate of the origin.

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).

double angle

The angle in degrees that specifies the outermost center point of the field of view cone. 0 degrees points up, and angle increases result in the cone moving clockwise (like a compass).

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.

View Source

CalculateAppend(int, int, double)

Calculates FOV given an origin point and a radius, adding the result onto the currently visible cells. 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 CalculateAppend(int originX, int originY, double radius = 1.7976931348623157E+308)
Parameters
Type Name Description
int originX

Coordinate x-value of the origin.

int originY

Coordinate y-value of the origin.

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.

View Source

CalculateAppend(int, int, double, Distance)

Calculates FOV given an origin point, a radius, and radius shape, adding the result onto the currently visible cells.

Declaration
public void CalculateAppend(int originX, int originY, double radius, Distance distanceCalc)
Parameters
Type Name Description
int originX

Coordinate x-value of the origin.

int originY

Coordinate y-value of the origin.

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).

View Source

CalculateAppend(int, int, 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 new field of view will be added onto the current one. The resulting field of view, if unobstructed, will be a cone defined by the angle and span given.

Declaration
public void CalculateAppend(int originX, int originY, double radius, Distance distanceCalc, double angle, double span)
Parameters
Type Name Description
int originX

Coordinate x-value of the origin.

int originY

Coordinate y-value of the origin.

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).

double angle

The angle in degrees that specifies the outermost center point of the field of view cone. 0 degrees points up, and angle increases result in the cone moving clockwise (like a compass).

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.

View Source

OnCalculate(int, int, double, Distance)

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

Declaration
protected abstract void OnCalculate(int originX, int originY, double radius, Distance distanceCalc)
Parameters
Type Name Description
int originX

Coordinate x-value of the origin.

int originY

Coordinate y-value of the origin.

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).

Remarks

Custom implementations would implement this function to perform their calculation; the Calculate functions call this then fire relevant events.

View Source

OnCalculate(int, int, 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
protected abstract void OnCalculate(int originX, int originY, double radius, Distance distanceCalc, double angle, double span)
Parameters
Type Name Description
int originX

Coordinate x-value of the origin.

int originY

Coordinate y-value of the origin.

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).

double angle

The angle in degrees that specifies the outermost center point of the field of view cone. 0 degrees points up, and angle increases result in the cone moving clockwise (like a compass).

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.

Remarks

Custom implementations would implement this function to perform their calculation; the Calculate functions call this then fire relevant events.

View Source

OnReset()

Resets all cells to not visible, and cycles current FOV to previous FOV, allowing a fresh set of calculations to begin.

Declaration
protected abstract void OnReset()
Remarks

This is (indirectly) called automatically by all Calculate overloads. Custom implementations should implement this to reset their ResultView to all 0's in a way appropriate for their architecture, as well as cycle the current FOV to the previous FOV to prepare for a fresh FOV calculation. Reset() also calls this function, along with firing relevant events.

View Source

Reset()

Resets the given field of view to no tiles visible.

Declaration
public void Reset()
Remarks

After this function is called, any value in DoubleResultView will be 0, and any value in BooleanResultView will be false. Additionally, CurrentFOV will be blank.

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
string

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

Overrides
object.ToString()
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
char normal

The character used for any location not in FOV.

char sourceValue

The character used for any location that is in FOV.

Returns
Type Description
string

The string representation of FOV, using the specified characters.

View Source

ToString(int)

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
int decimalPlaces

The number of decimal places to round to.

Returns
Type Description
string

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

Events

View Source

Recalculated

Fired whenever the FOV is recalculated.

Declaration
public event EventHandler<FOVRecalculatedEventArgs>? Recalculated
Event Type
Type Description
EventHandler<FOVRecalculatedEventArgs>
View Source

VisibilityReset

Fired when the existing FOV is reset prior to calculating a new one.

Declaration
public event EventHandler? VisibilityReset
Event Type
Type Description
EventHandler

Implements

IFOV
IReadOnlyFOV

Extension Methods

Utility.Yield<T>(T)
  • View Source
In this article
Back to top Generated by DocFX