Show / Hide Table of Contents

Class RadiusAreaProvider

Class containing functions capable of returning all unique positions inside of a given radius and (optional) bounds.

Inheritance
System.Object
RadiusAreaProvider
Implements
IReadOnlyRadiusAreaProvider
System.IEquatable<RadiusAreaProvider>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
[Serializable]
public class RadiusAreaProvider : IReadOnlyRadiusAreaProvider, IEquatable<RadiusAreaProvider>
Remarks

In the case that MANHATTAN/CHEBYSHEV distance, or DIAMOND/SQUARE/OCTAHEDRON/CUBE radius shapes are used, positions returned are guaranteed to be returned in order of distance from the center, from least to greatest. This guarantee does NOT hold if EUCLIDEAN distance, or CIRCLE/SPHERE radius shapes are specified. If no bounds are specified, the IEnumerable returned by the CalculatePositions() function will contain each coordinate within the radius. Otherwise, it will contain each coordinate in the radius that is also within the bounds of the rectangle. If the same radius length is being used multiple times (even from different center points), it is recommended to use only one RadiusAreaProvider, as the class allocates measurable memory, and using only one instance if the radius is used multiple times prevents reallocation. When the Radius value is changed, reallocation must be performed, however the overhead should be insignificant on everything but extremely large radiuses.

Constructors

| Improve this Doc View Source

RadiusAreaProvider(Coord, Int32, Distance)

Constructor.

Declaration
public RadiusAreaProvider(Coord center, int radius, Distance distanceCalc)
Parameters
Type Name Description
Coord center

The center point of the radius.

System.Int32 radius

The length of the radius.

Distance distanceCalc

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

| Improve this Doc View Source

RadiusAreaProvider(Coord, Int32, Distance, Rectangle)

Constructor.

Declaration
public RadiusAreaProvider(Coord center, int radius, Distance distanceCalc, Rectangle bounds)
Parameters
Type Name Description
Coord center

The center point of the radius.

System.Int32 radius

The length of the radius.

Distance distanceCalc

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

Rectangle bounds

The bounds to constrain the returned locations to.

| Improve this Doc View Source

RadiusAreaProvider(Int32, Int32, Int32, Distance)

Constructor.

Declaration
public RadiusAreaProvider(int centerX, int centerY, int radius, Distance distanceCalc)
Parameters
Type Name Description
System.Int32 centerX

The x-value of the center point of the radius.

System.Int32 centerY

The y-value of the center point of the radius.

System.Int32 radius

The length of the radius.

Distance distanceCalc

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

| Improve this Doc View Source

RadiusAreaProvider(Int32, Int32, Int32, Distance, Rectangle)

Constructor.

Declaration
public RadiusAreaProvider(int centerX, int centerY, int radius, Distance distanceCalc, Rectangle bounds)
Parameters
Type Name Description
System.Int32 centerX

The x-value of the center point of the radius.

System.Int32 centerY

The y-value of the center point of the radius.

System.Int32 radius

The length of the radius.

Distance distanceCalc

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

Rectangle bounds

The bounds to constrain the returned locations to.

Properties

| Improve this Doc View Source

Bounds

The bounds to constrain the returned locations to. Set to EMPTY to indicate that there are no bounds.

Declaration
public Rectangle Bounds { get; set; }
Property Value
Type Description
Rectangle
| Improve this Doc View Source

Center

The center point of the radius.

Declaration
public Coord Center { get; set; }
Property Value
Type Description
Coord
| Improve this Doc View Source

CenterX

The X-value of the center point of the radius.

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

CenterY

The Y-value of the center point of the radius.

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

DistanceCalc

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

Declaration
public Distance DistanceCalc { get; set; }
Property Value
Type Description
Distance
| Improve this Doc View Source

Radius

The length of the radius, eg. the number of tiles from the center point (as defined by the distance calculation/radius shape given) to which the radius extends.

Declaration
public int Radius { get; set; }
Property Value
Type Description
System.Int32
Remarks

When this value is changed, reallocation of an underlying array is performed, however overhead should be relatively small in most cases.

Methods

| Improve this Doc View Source

AsReadOnly()

Returns a read-only representation of this RadiusAreaProvider.

Declaration
public IReadOnlyRadiusAreaProvider AsReadOnly()
Returns
Type Description
IReadOnlyRadiusAreaProvider

A read-only representation of the RadiusAreaProvider

| Improve this Doc View Source

CalculatePositions()

Calculates the new radius, and returns an IEnumerable of all unique locations within that radius and bounds specified (as applicable).

Declaration
public IEnumerable<Coord> CalculatePositions()
Returns
Type Description
System.Collections.Generic.IEnumerable<Coord>

Enumerable of all unique positions within the radius and bounds specified.

Remarks

In the case that MANHATTAN/CHEBYSHEV distance, or DIAMOND/SQUARE/OCTAHEDRON/CUBE radius shapes are specified via DistanceCalc, positions returned are guaranteed to be returned in order of distance from the center, from least to greatest. This guarantee does NOT hold if EUCLIDEAN distance, or CIRCLE/SPHERE radius shapes are specified.

| Improve this Doc View Source

Equals(RadiusAreaProvider)

Compares the current RadiusAreaProvider to the one given.

Declaration
public bool Equals(RadiusAreaProvider other)
Parameters
Type Name Description
RadiusAreaProvider other
Returns
Type Description
System.Boolean

True if the given RadiusAreaProvider represents the same radius/Bounds, false otherwise.

| Improve this Doc View Source

Equals(Object)

Compares the current RadiusAreaProvider to the one given.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean

True if the given object is a RadiusAreaProvider that represents the same radius/Bounds, false otherwise.

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

GetHashCode()

Returns a hash-value for this object.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.Object.GetHashCode()
| Improve this Doc View Source

ToString()

Returns a string representation of the parameters of the RadiusAreaProvider.

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

A string representation of the RadiusAreaProvider.

Overrides
System.Object.ToString()

Operators

| Improve this Doc View Source

Equality(RadiusAreaProvider, RadiusAreaProvider)

Compares the two RadiusAreaProvider instances.

Declaration
public static bool operator ==(RadiusAreaProvider lhs, RadiusAreaProvider rhs)
Parameters
Type Name Description
RadiusAreaProvider lhs
RadiusAreaProvider rhs
Returns
Type Description
System.Boolean

True if the two given RadiusAreaProvider instances represents the same radius/Bounds, false otherwise.

| Improve this Doc View Source

Inequality(RadiusAreaProvider, RadiusAreaProvider)

Compares the two RadiusAreaProvider instances.

Declaration
public static bool operator !=(RadiusAreaProvider lhs, RadiusAreaProvider rhs)
Parameters
Type Name Description
RadiusAreaProvider lhs
RadiusAreaProvider rhs
Returns
Type Description
System.Boolean

True if the two given RadiusAreaProvider instances do NOT represent the same radius/Bounds, false otherwise.

Implements

IReadOnlyRadiusAreaProvider
System.IEquatable<T>

Extension Methods

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