InRangeZone Structure

public struct InRangeZone : IEquatable<InRangeZone>, IComparable<InRangeZone>

Represents an In Range Zone. Contains the index of the Zone, as well as the repeated World indicies of the Zone.

Fields

Name Type Default Value Description
AllZoneGroupingsGauranteedToBeInRange bool

The zone's bounding volume encompasses all Zone Groupings that a zone contains. The min position of this bounding volume will always be equal to the min position of each Zone Grouping, as all Zone Groupings have the same min position. However, each Zone Grouping can have a variable size, which means they can end at different positions in the game world. The Zone's bounding volme max position is thus equal to the position of the largest Zone Grouping, however this means the max position of the bounding volume does not accurately reflect the max position of all Zone Groupings.

When the reference position's components (x, y, and z) are all smaller than the zone's bounding volume min position, we can provide a gaurantee that all Zone Groupings in the zone are within range of the reference position. And that case, this value will be true. In all other cases, this value will be false, and you will need to perform a more precise distance check for the individual Zone Grouping to make sure it is actually in range of the reference position.

DistanceOfZoneFromPosition double

The distance between the Zoen and the position it was tested against.

WorldRepetitionIndices readonly Cell

Index of the Zone Grouping in relation to the Repeated World. This is needed when working with Endless/Repeating Worlds. A value of 0 for an index indicates that that index is within the confines of the original (non repeated) World. A value of 1 would indicate that index falls into the next greatest repetition of the World on that indices axis, 2 would be the next one after that, and so on. Negative values are also possible.

Each index (Row, Column, Layer) might have a different value, since the player can traverse each axis idependently and may have travelled further on one axis than another.

When retrieving Zone Groupings In Range of a position, if using a repeating/endless World, it's possible for the same Zone Grouping to be included multiple times. In these cases, the WorldIndex value will be different for each Zone Grouping. When this occurs, it indicates that a Zone Grouping is in range in multiple iterations of the repeated World (generally, this should not happen, but it is theoretically possible).

ZoneIndex int

The index of the Zone.

ZonePosition Vector3Double

The position of the Zone in the scene, defined as the min point of the zone.

Constructors

InRangeZone(Cell, int)

public InRangeZone(Cell repeatedWorldIndices, int zoneIndex, int groupingIndex)

Initializes a new instance of the InRangeZone structure.

Parameters

Name Type Description
repeatedWorldIndices Cell

Tells you which repeated World this Zone Grouping is a part of on each axis (if using and endless/repeating World).

zoneIndex int

The index of the Zone.

allZoneGroupingsGauranteedToBeInRange bool

The zone's bounding volume encompasses all Zone Groupings that a zone contains. The min position of this bounding volume will always be equal to the min position of each Zone Grouping, as all Zone Groupings have the same min position. However, each Zone Grouping can have a variable size, which means they can end at different positions in the game world. The Zone's bounding volme max position is thus equal to the position of the largest Zone Grouping, however this means the max position of the bounding volume does not accurately reflect the max position of all Zone Groupings.

When the reference position's components (x, y, and z) are all smaller than the zone's bounding volume min position, we can provide a gaurantee that all Zone Groupings in the zone are within range of the reference position. And that case, this value will be true. In all other cases, this value will be false, and you will need to perform a more precise distance check for the individual Zone Grouping to make sure it is actually in range of the reference position.

distanceOfZoneFromPosition double

The distance between the Zoen and the position it was tested against.

zonePosition Vector3Double

The position of the Zone in the scene, defined as the min point of the zone.

Methods

operator !=(InRangeZone, InRangeZone)

public static bool operator !=(InRangeZone left, InRangeZone right)

!= operater implementation that allows you check if two InRangeZones are not equal

The two InRangeZones will not be equal if the ZoneIndex, WorldGroupingIndex, rows, columns, or layers do not match each other from one InRangeZone to the other (row != row, etc.)

Parameters

Name Type Description
left InRangeZone

The first InRangeZone.

right InRangeZone

The second InRangeZone.

Returns

bool
Returns true if the InRangeZones are not equal, false if they are equal.


operator <(InRangeZone, InRangeZone)

public static bool operator <(InRangeZone left, InRangeZone right)

< operater implementation that allows you check if the left InRangeZone is less than the right InRangeZone.

Parameters

Name Type Description
left InRangeZone

The left InRangeZone.

right InRangeZone

The right InRangeZone.

Returns

bool
Please refer to the CompareTo method documentation to understand how InRangeZone comparison works.


operator <=(InRangeZone, InRangeZone)

public static bool operator <=(InRangeZone left, InRangeZone right)

<= operater implementation that allows you check if the left InRangeZone is less than or equal to the right InRangeZone.

Parameters

Name Type Description
left InRangeZone

The left InRangeZone.

right InRangeZone

The right InRangeZone.

Returns

bool
Please refer to the CompareTo method documentation to understand how InRangeZone comparison works.


operator ==(InRangeZone, InRangeZone)

public static bool operator ==(InRangeZone left, InRangeZone right)

!= operater implementation that allows you check if two InRangeZones are equal

The two InRangeZones will be equal if the ZoneIndex, WorldGroupingIndex, rows, columns, or layers all match each other from one InRangeZone to the other (row == row, etc.)

Parameters

Name Type Description
left InRangeZone

The first InRangeZone.

right InRangeZone

The second InRangeZone.

Returns

bool
Returns true if the InRangeZones are equal, false if they are not equal.


operator >(InRangeZone, InRangeZone)

public static bool operator >(InRangeZone left, InRangeZone right)

> operater implementation that allows you check if the left InRangeZone is greater than the right InRangeZone.

Parameters

Name Type Description
left InRangeZone

The left InRangeZone.

right InRangeZone

The right InRangeZone.

Returns

bool
Please refer to the CompareTo method documentation to understand how InRangeZone comparison works.


operator >=(InRangeZone, InRangeZone)

public static bool operator >=(InRangeZone left, InRangeZone right)

>= operater implementation that allows you check if the left InRangeZone is greater than or equal to the right InRangeZone.

Parameters

Name Type Description
left InRangeZone

The left InRangeZone.

right InRangeZone

The right InRangeZone.

Returns

bool
Please refer to the CompareTo method documentation to understand how InRangeZone comparison works.


CompareTo(InRangeZone)

public int CompareTo(InRangeZone other)

Compares the input InRangeZone against this InRangeZone to determine whether this InRangeZone procedes, follows, or is at the same position of the input InRangeZone. This can be used to order a collection of InRangeZones in the same manner as they would appear in the scene (if they were associated with World InRangeZones, that is). The method utilizes the row, column, and layer values. If you know the layer value is not used (such as in a 2D world), you may choose to use a different method rather than this one.

Parameters

Name Type Description
other object

The other InRangeZone to compare this InRangeZone against.

Returns

int
-1 if this InRangeZone precedes (is less than) the input "other" InRangeZone, +1 if this InRangeZone follows (is greater than) the input "other" InRangeZone, and 0 if the InRangeZones are at the same position (are equal).

The following logic is used to determine the order. First, the ZoneIndex of the two cell's is compared. If this cell's ZoneIndex is less than the input cell's ZoneIndex, -1 is returned. If it is greater than the input cell's ZoneIndex, +1 is returned. If they are equal, the WorldGroupingIndex is compared in the same way. Then the Cell Layer, Cell Row, and finally Cell Column. 0 is returned if all values are the same.

An important thing to note is lower World Groupings (which are actually probably more important) will be before higher World Groupings. As such, they are considered less than the higher World Grouping cells.


Equals(InRangeZone)

public bool Equals(InRangeZone other)

Implementation of IEquatable<InRangeZone>.Equals method. Use this, as it does not box input struct.

This method compares the ZoneIndex, WorldGroupingIndex, row, column, and layer. In some instances where you know the layer does not matter (on 2D worlds for instance), it may be slightly more performant to use a custom InRangeZone EqualityComparer that ignores the layer

Parameters

Name Type Description
other object

The other InRangeZone to compare this InRangeZone against.

Returns

bool
false if the row, column, and/or layer value on the other InRangeZone is not equal to this InRangeZone's LOD, row, column, and/or layer value.


Equals(object)

public override bool Equals(object obj)

Override of Equals method. You shouldn't need to use this, and you should not use it since it will cause the input InRangeZone to be boxed.

Parameters

Name Type Description
obj object

The object to check this InRangeZone against.

Returns

bool
false if the object is not a InRangeZone or it is but the ZoneIndex, WorldGroupingIndex, row, column, and/or layer value on the obj is not equal to this InRangeZone's ZoneIndex, WorldGroupingIndex, row, column, and/or layer value.


GetHashCode()

public override int GetHashCode()

Returns a hash code for this InRangeZone. Uses all six indexes (WorldGroupingIndex, Row, Column and Layer) to compute it, so the InRangeZone is treated as a 3D InRangeZone.

Returns

int
The hash code of the InRangeZone.