Table of Contents

Class RegionUtility

Namespace
Uncreated.Warfare.Util.Region
Assembly
Uncreated.Warfare.dll

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

position Vector3
x byte
y byte

Exceptions

ArgumentOutOfRangeException

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

position Vector3
x byte
y byte
argumentName string

Exceptions

ArgumentOutOfRangeException

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

regions List<T>[,]

Returns

ListRegionsEnumerator<T>

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

regions List<T>[,]
center RegionCoord
maxRegionDistance byte

Returns

ListRegionsEnumerator<T>

Type Parameters

T

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

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

regions List<T>[,]
centerX byte
centerY byte
maxRegionDistance byte

Returns

ListRegionsEnumerator<T>

Type Parameters

T

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

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

regions List<T>[,]
position Vector3
maxRegionDistance byte

Returns

ListRegionsEnumerator<T>

Type Parameters

T

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

EnumerateRegions()

Enumerate through all regions around a the center of the level.

public static SurroundingRegionsIterator EnumerateRegions()

Returns

SurroundingRegionsIterator

EnumerateRegions(RegionCoord)

Enumerate through all regions around a given region.

public static SurroundingRegionsIterator EnumerateRegions(RegionCoord center)

Parameters

center RegionCoord

Returns

SurroundingRegionsIterator

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

center RegionCoord
maxRegionDistance byte

Returns

SurroundingRegionsIterator

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

EnumerateRegions(byte, byte)

Enumerate through all regions around a given region.

public static SurroundingRegionsIterator EnumerateRegions(byte centerX, byte centerY)

Parameters

centerX byte
centerY byte

Returns

SurroundingRegionsIterator

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

centerX byte
centerY byte
maxRegionDistance byte

Returns

SurroundingRegionsIterator

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

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

center Vector2
radius float

Returns

RadiusRegionsEnumerator

EnumerateRegions(Vector3)

Enumerate through all regions around a given position in a region.

public static SurroundingRegionsIterator EnumerateRegions(Vector3 center)

Parameters

center Vector3

Returns

SurroundingRegionsIterator

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

center Vector3
radius float

Returns

RadiusRegionsEnumerator

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

center RegionCoord
maxRegionDistance byte
action RegionAction

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

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

center RegionCoord
maxRegionDistance byte
action RegionActionWhile

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

ForEachRegion(RegionCoord, RegionAction)

Invoke an action for each region starting around a given region.

public static void ForEachRegion(RegionCoord center, RegionAction action)

Parameters

center RegionCoord
action RegionAction

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

center RegionCoord
action RegionActionWhile

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

centerX byte
centerY byte
maxRegionDistance byte
action RegionAction

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

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

centerX byte
centerY byte
maxRegionDistance byte
action RegionActionWhile

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

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

centerX byte
centerY byte
action RegionAction

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

centerX byte
centerY byte
action RegionActionWhile

ForEachRegion(RegionAction)

Invoke an action for each region around the center of the level.

public static void ForEachRegion(RegionAction action)

Parameters

action RegionAction

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

action RegionActionWhile

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

center Vector3
radius float
action RegionAction

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

center Vector3
radius float
action RegionActionWhile

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

center Vector3
action RegionAction

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

center Vector3
action RegionActionWhile

LinearEnumerateRegions()

Linearly enumerate through all regions.

public static RegionsIterator LinearEnumerateRegions()

Returns

RegionsIterator

LinearEnumerateRegions(bool)

Linearly enumerate through all regions, but use the Y-axis as the primary axis.

public static RegionsIterator LinearEnumerateRegions(bool yPrimary)

Parameters

yPrimary bool

Returns

RegionsIterator