Show / Hide Table of Contents

Class SenseSourceBase

A base class for creating ISenseSource implementations that boils an implementation down to primarily implementing the OnCalculate() function.

Inheritance
object
SenseSourceBase
RecursiveShadowcastingSenseSource
RippleSenseSource
Implements
ISenseSource
Inherited Members
object.GetType()
object.MemberwiseClone()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: GoRogue.SenseMapping.Sources
Assembly: GoRogue.dll
Syntax
public abstract class SenseSourceBase : ISenseSource
Remarks

This class uses an ArrayView as the ResultView, in order to enable common functions efficiently. Use cases for a custom view here should be relatively limited, as the view must be settable and resizable; if a custom implementation is needed, you may implement ISenseSource directly.

Constructors

View Source

SenseSourceBase(Point, double, Distance, double)

Creates a source which spreads outwards in all directions.

Declaration
protected SenseSourceBase(Point position, double radius, Distance distanceCalc, double intensity = 1)
Parameters
Type Name Description
Point position

The position on a map that the source is located at.

double radius

The maximum radius of the source -- this is the maximum distance the source values will emanate, provided the area is completely unobstructed.

Distance distanceCalc

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

double intensity

The starting intensity value of the source. Defaults to 1.0.

View Source

SenseSourceBase(Point, double, Distance, double, double, double)

Constructor. Creates a source which spreads only in a cone defined by the given angle and span.

Declaration
protected SenseSourceBase(Point position, double radius, Distance distanceCalc, double angle, double span, double intensity = 1)
Parameters
Type Name Description
Point position

The position on a map that the source is located at.

double radius

The maximum radius of the source -- this is the maximum distance the source values will emanate, provided the area is completely unobstructed.

Distance distanceCalc

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

double angle

The angle in degrees that specifies the outermost center point of the cone formed by the source's values. 0 degrees points right.

double span

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

double intensity

The starting intensity value of the source. Defaults to 1.0.

View Source

SenseSourceBase(int, int, double, Distance, double)

Creates a source which spreads outwards in all directions.

Declaration
protected SenseSourceBase(int positionX, int positionY, double radius, Distance distanceCalc, double intensity = 1)
Parameters
Type Name Description
int positionX

The X-value of the position on a map that the source is located at.

int positionY

The Y-value of the position on a map that the source is located at.

double radius

The maximum radius of the source -- this is the maximum distance the source values will emanate, provided the area is completely unobstructed.

Distance distanceCalc

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

double intensity

The starting intensity value of the source. Defaults to 1.0.

View Source

SenseSourceBase(int, int, double, Distance, double, double, double)

Constructor. Creates a source which spreads only in a cone defined by the given angle and span.

Declaration
protected SenseSourceBase(int positionX, int positionY, double radius, Distance distanceCalc, double angle, double span, double intensity = 1)
Parameters
Type Name Description
int positionX

The x-value for the position on a map that the source is located at.

int positionY

The y-value for the position on a map that the source is located at.

double radius

The maximum radius of the source -- this is the maximum distance the source values will emanate, provided the area is completely unobstructed.

Distance distanceCalc

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

double angle

The angle in degrees that specifies the outermost center point of the cone formed by the source's values. 0 degrees points right.

double span

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

double intensity

The starting intensity value of the source. Defaults to 1.0.

Fields

View Source

AngleInternal

The Angle value, but offset 90 degrees clockwise; ie, 0 points right instead of up. This value typically works better for actual light calculations (as the definition more closely matches the unit circle).

Declaration
protected double AngleInternal
Field Value
Type Description
double
View Source

Center

The coordinate which will be the center point of the result view, ie. the center is (Center, Center).

Declaration
protected int Center
Field Value
Type Description
int
Remarks

This is equivalent to Size / 2; however is cached for performance and convenience since this calculation is performed frequently.

View Source

ResultViewBacking

The result view used to record results.

Declaration
protected ArrayView<double> ResultViewBacking
Field Value
Type Description
ArrayView<double>
View Source

Size

The size of the result view (eg. it's width and height); cached for efficiency and convenience.

Declaration
protected int Size
Field Value
Type Description
int

Properties

View Source

Angle

If IsAngleRestricted is true, the angle in degrees that represents a line from the source's start to the outermost center point of the cone formed by the source's calculated values. 0 degrees points up, and increases in angle move clockwise (like a compass). Otherwise, this will be 0.0 degrees.

Declaration
public double Angle { get; set; }
Property Value
Type Description
double
View Source

Decay

The amount of decrease in sense source value per unit of distance. Calculated automatically as a product of Intensity and Radius.

Declaration
public double Decay { get; }
Property Value
Type Description
double
View Source

DistanceCalc

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

Declaration
public Distance DistanceCalc { get; set; }
Property Value
Type Description
Distance
View Source

Enabled

Whether or not this source is enabled. If a source is disabled when Calculate() is called, the source does not calculate values and is effectively assumed to be "off".

Declaration
public bool Enabled { get; set; }
Property Value
Type Description
bool
View Source

Intensity

The starting value of the source to spread. Defaults to 1.0.

Declaration
public double Intensity { get; set; }
Property Value
Type Description
double
View Source

IsAngleRestricted

Whether or not the spreading of values from this source is restricted to an angle and span.

Declaration
public bool IsAngleRestricted { get; set; }
Property Value
Type Description
bool
View Source

Position

The position on a map that the source is located at.

Declaration
public ref Point Position { get; }
Property Value
Type Description
Point
View Source

Radius

The maximum radius of the source -- this is the maximum distance the source values will emanate, provided the area is completely unobstructed. Changing this will trigger resizing (re-allocation) of the underlying arrays.

Declaration
public double Radius { get; set; }
Property Value
Type Description
double
View Source

ResistanceView

The resistance map used to perform calculations.

Declaration
public IGridView<double>? ResistanceView { get; }
Property Value
Type Description
IGridView<double>
Remarks

Sense map implementations will set this to the sense map's resistance map prior to calculating. This can be set via SetResistanceMap(IGridView<double>?), but you shouldn't do this unless you're creating a custom sense map implementation.

View Source

ResultView

A grid view representing the result of a sense map calculation.

Declaration
public IGridView<double> ResultView { get; }
Property Value
Type Description
IGridView<double>
View Source

Span

If IsAngleRestricted is true, the angle in degrees that represents the full arc of the cone formed by the source's calculated values. Otherwise, it will be 360 degrees.

Declaration
public double Span { get; set; }
Property Value
Type Description
double

Methods

View Source

CalculateLight()

Perform the lighting calculations if the source is enabled, by first clearing results of the existing calculation, then re-calculating it by calling OnCalculate().

Declaration
public void CalculateLight()
View Source

OnCalculate()

Performs the actual spreading calculation.

Declaration
public abstract void OnCalculate()
View Source

Reset()

Resets calculation state so a new set of calculations can begin.

Declaration
protected virtual void Reset()
View Source

SetResistanceMap(IGridView<double>?)

Should ONLY be called from SenseMap or equivalent implementations. Sets the resistance map used by the source for calculations.

Declaration
public void SetResistanceMap(IGridView<double>? resMap)
Parameters
Type Name Description
IGridView<double> resMap
View Source

ToString()

Returns a string representation of the configuration of this SenseSource.

Declaration
public override string ToString()
Returns
Type Description
string

A string representation of the configuration of this SenseSource.

Overrides
object.ToString()

Events

View Source

RadiusChanged

Fired when the radius of the source changes.

Declaration
public event EventHandler? RadiusChanged
Event Type
Type Description
EventHandler

Implements

ISenseSource

Extension Methods

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