Class RegionUtility
Utilities for working with regions.
public static class RegionUtility
- Inheritance
-
RegionUtility
- Inherited Members
Remarks
Stolen from DevkitServer.
Methods
AssertGetRegion(Vector3, out byte, out byte)
Gets the region of a position, or throws an error if it's out of range.
public static void AssertGetRegion(Vector3 position, out byte x, out byte y)
Parameters
Exceptions
AssertGetRegion(Vector3, out byte, out byte, string)
Gets the region of a position, or throws an error if it's out of range. Pass an argument name when the name is not 'position'.
public static void AssertGetRegion(Vector3 position, out byte x, out byte y, string argumentName)
Parameters
Exceptions
CastFrom<T>(List<T>[,])
Enumerate through a list of regions around the center of the level.
public static ListRegionsEnumerator<T> CastFrom<T>(this List<T>[,] regions)
Parameters
regionsList<T>[,]
Returns
Type Parameters
T
CastFrom<T>(List<T>[,], RegionCoord, byte)
Enumerate through a list of regions around a given region.
public static ListRegionsEnumerator<T> CastFrom<T>(this List<T>[,] regions, RegionCoord center, byte maxRegionDistance = 255)
Parameters
Returns
Type Parameters
T
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
CastFrom<T>(List<T>[,], byte, byte, byte)
Enumerate through a list of regions around a given region.
public static ListRegionsEnumerator<T> CastFrom<T>(this List<T>[,] regions, byte centerX, byte centerY, byte maxRegionDistance = 255)
Parameters
Returns
Type Parameters
T
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
CastFrom<T>(List<T>[,], Vector3, byte)
Enumerate through a list of regions around a given position in a region.
public static ListRegionsEnumerator<T> CastFrom<T>(this List<T>[,] regions, Vector3 position, byte maxRegionDistance = 255)
Parameters
Returns
Type Parameters
T
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
EnumerateRegions()
Enumerate through all regions around a the center of the level.
public static SurroundingRegionsIterator EnumerateRegions()
Returns
EnumerateRegions(RegionCoord)
Enumerate through all regions around a given region.
public static SurroundingRegionsIterator EnumerateRegions(RegionCoord center)
Parameters
centerRegionCoord
Returns
EnumerateRegions(RegionCoord, byte)
Enumerate through all regions around a given region, with a maximum distance in regions.
public static SurroundingRegionsIterator EnumerateRegions(RegionCoord center, byte maxRegionDistance)
Parameters
centerRegionCoordmaxRegionDistancebyte
Returns
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
EnumerateRegions(byte, byte)
Enumerate through all regions around a given region.
public static SurroundingRegionsIterator EnumerateRegions(byte centerX, byte centerY)
Parameters
Returns
EnumerateRegions(byte, byte, byte)
Enumerate through all regions around a given region, with a maximum distance in regions.
public static SurroundingRegionsIterator EnumerateRegions(byte centerX, byte centerY, byte maxRegionDistance)
Parameters
Returns
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
EnumerateRegions(Vector2, float)
Enumerate through all regions around a given 2D position which contain a circle with a radius.
public static RadiusRegionsEnumerator EnumerateRegions(Vector2 center, float radius)
Parameters
centerVector2radiusfloat
Returns
EnumerateRegions(Vector3)
Enumerate through all regions around a given position in a region.
public static SurroundingRegionsIterator EnumerateRegions(Vector3 center)
Parameters
centerVector3
Returns
EnumerateRegions(Vector3, float)
Enumerate through all regions around a given position which contain a circle with a radius.
public static RadiusRegionsEnumerator EnumerateRegions(Vector3 center, float radius)
Parameters
centerVector3radiusfloat
Returns
ForEachRegion(RegionCoord, byte, RegionAction)
Invoke an action for each region around a given region with a radius of maxRegionDistance.
public static void ForEachRegion(RegionCoord center, byte maxRegionDistance, RegionAction action)
Parameters
centerRegionCoordmaxRegionDistancebyteactionRegionAction
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
ForEachRegion(RegionCoord, byte, RegionActionWhile)
Invoke an action for each region around a given region with a radius of maxRegionDistance.
Can break within action by returning false.
public static void ForEachRegion(RegionCoord center, byte maxRegionDistance, RegionActionWhile action)
Parameters
centerRegionCoordmaxRegionDistancebyteactionRegionActionWhile
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
ForEachRegion(RegionCoord, RegionAction)
Invoke an action for each region starting around a given region.
public static void ForEachRegion(RegionCoord center, RegionAction action)
Parameters
centerRegionCoordactionRegionAction
ForEachRegion(RegionCoord, RegionActionWhile)
Invoke an action for each region around a given region. Can break within action by returning false.
public static void ForEachRegion(RegionCoord center, RegionActionWhile action)
Parameters
centerRegionCoordactionRegionActionWhile
ForEachRegion(byte, byte, byte, RegionAction)
Invoke an action for each region around a given region with a radius of maxRegionDistance.
public static void ForEachRegion(byte centerX, byte centerY, byte maxRegionDistance, RegionAction action)
Parameters
centerXbytecenterYbytemaxRegionDistancebyteactionRegionAction
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
ForEachRegion(byte, byte, byte, RegionActionWhile)
Invoke an action for each region around a given region with a radius of maxRegionDistance.
Can break within action by returning false.
public static void ForEachRegion(byte centerX, byte centerY, byte maxRegionDistance, RegionActionWhile action)
Parameters
centerXbytecenterYbytemaxRegionDistancebyteactionRegionActionWhile
Remarks
The square enumerated will have a size of regions.maxRegionDistance * 2 + 1
ForEachRegion(byte, byte, RegionAction)
Invoke an action for each region starting around a given region.
public static void ForEachRegion(byte centerX, byte centerY, RegionAction action)
Parameters
centerXbytecenterYbyteactionRegionAction
ForEachRegion(byte, byte, RegionActionWhile)
Invoke an action for each region around a given region. Can break within action by returning false.
public static void ForEachRegion(byte centerX, byte centerY, RegionActionWhile action)
Parameters
centerXbytecenterYbyteactionRegionActionWhile
ForEachRegion(RegionAction)
Invoke an action for each region around the center of the level.
public static void ForEachRegion(RegionAction action)
Parameters
actionRegionAction
ForEachRegion(RegionActionWhile)
Invoke an action for each region around the center of the level. Can break within action by returning false.
public static void ForEachRegion(RegionActionWhile action)
Parameters
actionRegionActionWhile
ForEachRegion(Vector3, float, RegionAction)
Invoke an action for each region around a given position in a region that contain a circle with a given radius.
public static void ForEachRegion(Vector3 center, float radius, RegionAction action)
Parameters
centerVector3radiusfloatactionRegionAction
ForEachRegion(Vector3, float, RegionActionWhile)
Invoke an action for each region around a given position in a region that contain a circle with a given radius.
Can break within action by returning false.
public static void ForEachRegion(Vector3 center, float radius, RegionActionWhile action)
Parameters
centerVector3radiusfloatactionRegionActionWhile
ForEachRegion(Vector3, RegionAction)
Invoke an action for each region starting around a given position in a region.
public static void ForEachRegion(Vector3 center, RegionAction action)
Parameters
centerVector3actionRegionAction
ForEachRegion(Vector3, RegionActionWhile)
Invoke an action for each region around a given position in a region. Can break within action by returning false.
public static void ForEachRegion(Vector3 center, RegionActionWhile action)
Parameters
centerVector3actionRegionActionWhile
LinearEnumerateRegions()
Linearly enumerate through all regions.
public static RegionsIterator LinearEnumerateRegions()
Returns
LinearEnumerateRegions(bool)
Linearly enumerate through all regions, but use the Y-axis as the primary axis.
public static RegionsIterator LinearEnumerateRegions(bool yPrimary)
Parameters
yPrimarybool