Show / Hide Table of Contents

Class RecursiveShadowcastingBooleanBasedFOV

An alternative implementation of RecursiveShadowcastingFOV which generates boolean values as the output of the FOV algorithm, rather than generating doubles and translating to booleans as needed. It still implements DoubleResultView, but those values are calculated on the fly from the boolean values, rather than the other way around. These differences have performance implications that can make this algorithm more suitable for some scenarios (see remarks).

Inheritance
object
FOVBase
BooleanBasedFOVBase
RecursiveShadowcastingBooleanBasedFOV
Implements
IFOV
IReadOnlyFOV
Inherited Members
BooleanBasedFOVBase.ResultView
BooleanBasedFOVBase.DoubleResultView
BooleanBasedFOVBase.BooleanResultView
FOVBase.AsReadOnly()
FOVBase.Calculate(int, int, double)
FOVBase.CalculateAppend(int, int, double)
FOVBase.Calculate(Point, double)
FOVBase.CalculateAppend(Point, double)
FOVBase.Calculate(int, int, double, Distance)
FOVBase.CalculateAppend(int, int, double, Distance)
FOVBase.Calculate(Point, double, Distance)
FOVBase.CalculateAppend(Point, double, Distance)
FOVBase.Calculate(int, int, double, Distance, double, double)
FOVBase.CalculateAppend(int, int, double, Distance, double, double)
FOVBase.Calculate(Point, double, Distance, double, double)
FOVBase.CalculateAppend(Point, double, Distance, double, double)
FOVBase.Reset()
FOVBase.ToString(char, char)
FOVBase.ToString(int)
FOVBase.ToString()
FOVBase.TransparencyView
FOVBase.CalculationsPerformed
FOVBase.Recalculated
FOVBase.VisibilityReset
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 class RecursiveShadowcastingBooleanBasedFOV : BooleanBasedFOVBase, IFOV, IReadOnlyFOV
Remarks

This implementation will retrieve values from BooleanResultView more quickly than RecursiveShadowcastingFOV, However, retrieving values from DoubleResultView is, generally slower; much slower, in particular, if there are multiple FOV sources being appended together via multiple calls to CalculateAppend. It will, however, take up significantly less memory for large maps.

These tradeoffs, therefore, make this variation particularly suited to situations where you primarily make use of the BooleanResultView property, or when your map is very large and you wish to reduce the memory consumption of the object.

Constructors

View Source

RecursiveShadowcastingBooleanBasedFOV(IGridView<bool>, IEqualityComparer<Point>?)

Constructor.

Declaration
public RecursiveShadowcastingBooleanBasedFOV(IGridView<bool> transparencyView, IEqualityComparer<Point>? hasher = null)
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.

IEqualityComparer<Point> hasher

The hashing algorithm to use for points in hash sets. Defaults to the default hash algorithm for Points.

Properties

View Source

CurrentFOV

IEnumerable of only positions currently in the field of view.

Declaration
public override IEnumerable<Point> CurrentFOV { get; }
Property Value
Type Description
IEnumerable<Point>
Overrides
FOVBase.CurrentFOV
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 override IEnumerable<Point> NewlySeen { get; }
Property Value
Type Description
IEnumerable<Point>
Overrides
FOVBase.NewlySeen
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 override IEnumerable<Point> NewlyUnseen { get; }
Property Value
Type Description
IEnumerable<Point>
Overrides
FOVBase.NewlyUnseen

Methods

View Source

OnCalculate(int, int, double, Distance)

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

Declaration
protected override 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).

Overrides
FOVBase.OnCalculate(int, int, double, Distance)
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 override 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.

Overrides
FOVBase.OnCalculate(int, int, double, Distance, double, double)
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 override void OnReset()
Overrides
FOVBase.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.

Implements

IFOV
IReadOnlyFOV

Extension Methods

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