Class RecursiveShadowcastingFOV
Implements IFOV by using a recursive shadow-casting implementation.
Inherited Members
Namespace: GoRogue.FOV
Assembly: GoRogue.dll
Syntax
public class RecursiveShadowcastingFOV : DoubleBasedFOVBase, IFOV, IReadOnlyFOV
Remarks
Compared to the functionally equivalent implementation of recursive shadowcasting, RecursiveShadowcastingBooleanBasedFOV, this version is usually a reasonable default. However, this version can take up a great deal of memory for large maps; in these cases, you may prefer RecursiveShadowcastingBooleanBasedFOV instead.
Constructors
View SourceRecursiveShadowcastingFOV(IGridView<bool>, IEqualityComparer<Point>?)
Constructor.
Declaration
public RecursiveShadowcastingFOV(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 SourceCurrentFOV
IEnumerable of only positions currently in the field of view.
Declaration
public override IEnumerable<Point> CurrentFOV { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Point> |
Overrides
View SourceNewlySeen
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
View SourceNewlyUnseen
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
Methods
View SourceOnCalculate(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
Remarks
Custom implementations would implement this function to perform their calculation; the Calculate functions call this then fire relevant events.
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 --
|
Overrides
Remarks
Custom implementations would implement this function to perform their calculation; the Calculate functions call this then fire relevant events.
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
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.