WorldUserChange Structure

public struct WorldUserChange : IEquatable<WorldGroupingCell>, IComparable<WorldGroupingCell>

Represents a change in users on a World. In addition to regular cell indexes, contains the LOD and World Grouping that the cell belongs to.

Fields

Name Type Default Value Description
Cell readonly Cell

The actual Cell this struct details.

ChangeInUsers readonly int

The change in users.

LOD readonly int

The LOD of the WorldUserChange.

WorldGroupingIndex readonly int

The index of the World Grouping on the World this WorldUserChange is associated with.

Constructors

WorldUserChange(Cell, int, int, int)

public WorldUserChange(Cell cell, int groupingIndex, int lod, int changeInUsers)

Initializes a new instance of the WorldUserChange structure.

Parameters

Name Type Description
cell Cell

The cell of the WorldUserChange.

groupingIndex int

The index of the World Grouping of the world the WorldUserChange is associated with.

lod int

The LOD of the WorldUserChange.

changeInUsers int

The change in users.

Methods

operator !=(WorldUserChange, WorldUserChange)

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

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

The two WorldUserChanges will not be equal if the GridLayerIndex, LOD, rows, columns, or layers do not match each other from one WorldUserChange to the other (row != row, etc.)

Parameters

Name Type Description
left WorldUserChange

The first WorldUserChange.

right WorldUserChange

The second WorldUserChange.

Returns

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


operator <(WorldUserChange, WorldUserChange)

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

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

Parameters

Name Type Description
left WorldUserChange

The left WorldUserChange.

right WorldUserChange

The right WorldUserChange.

Returns

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


operator <=(WorldUserChange, WorldUserChange)

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

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

Parameters

Name Type Description
left WorldUserChange

The left WorldUserChange.

right WorldUserChange

The right WorldUserChange.

Returns

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


operator ==(WorldUserChange, WorldUserChange)

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

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

The two WorldUserChanges will be equal if the GridLayerIndex, LOD, rows, columns, or layers all match each other from one WorldUserChange to the other (row == row, etc.)

Parameters

Name Type Description
left WorldUserChange

The first WorldUserChange.

right WorldUserChange

The second WorldUserChange.

Returns

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


operator >(WorldUserChange, WorldUserChange)

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

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

Parameters

Name Type Description
left WorldUserChange

The left WorldUserChange.

right WorldUserChange

The right WorldUserChange.

Returns

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


operator >=(WorldUserChange, WorldUserChange)

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

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

Parameters

Name Type Description
left WorldUserChange

The left WorldUserChange.

right WorldUserChange

The right WorldUserChange.

Returns

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


AdjustUserChange(int)

public WorldUserChange AdjustUserChange(int newChangeInUsers)

Returns a new instance of the WorldUserChange structure that is effectively the same as the current object, but with a new value for user change.

Parameters

Name Type Description
newChangeInUsers int

The new change in users.

Returns

WorldUserChange
The new structure.


CompareTo(WorldUserChange)

public int CompareTo(WorldUserChange other)

Compares the input WorldUserChange against this WorldUserChange to determine whether this WorldUserChange procedes, follows, or is at the same position of the input WorldUserChange. This can be used to order a collection of WorldUserChanges in the same manner as they would appear in the scene (if they were associated with World WorldUserChanges, that is). The method utilizes the LOD, 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 WorldUserChange to compare this WorldUserChange against.

Returns

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

The following logic is used to determine the order. First, the GridLayerIndex of the two cell's is compared. If this cell's GridLayerIndex is less than the input cell's GridLayerIndex, -1 is returned. If it is greater than the input cell's GridLayerIndex, +1 is returned. If they are equal, the LOD values are compared. If this cell's LOD value is less than the LOD value of the input cell, -1 is returned. If it is greater, +1 is returned. If they are the same, then the Layer value is copared in the same manner. If this WorldUserChange's layer is less than the input WorldUserChange's layer, -1 is returned. If this WorldUserChange's layer is greater than the input WorldUserChange's layer, +1 is returned. If the two have the same layer value, the row is compared in the same manner. If the rows are the same, the columns are compared. If the columns are compared, 0 is returned as the two WorldUserChange's are equal and have the same placement in the order.

An important thing to note is that higher quality LODs (which have a smaller value) will precede lower quality LODs. However, this also means that according to SAM, WorldUserChange's with higher quality LODs are less than WorldUserChange's with lower quality LODs. In addition, 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(WorldUserChange)

public bool Equals(WorldUserChange other)

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

This method compares the GridLayerIndex, LOD, 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 WorldUserChange EqualityComparer that ignores the layer

Parameters

Name Type Description
other object

The other WorldUserChange to compare this WorldUserChange against.

Returns

bool
false if the row, column, and/or layer value on the other WorldUserChange is not equal to this WorldUserChange'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 WorldUserChange to be boxed.

Parameters

Name Type Description
obj object

The object to check this WorldUserChange against.

Returns

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


GetHashCode()

public override int GetHashCode()

Returns a hash code for this WorldUserChange. Uses all five indexes (GridLayerIndex, LOD, Row, Column and Layer) to compute it, so the WorldUserChange is treated as a 3D WorldUserChange. You could also create a custom EqualityComparer that only utilizes the row, column, and LOD, if you know that you do not need the layer value.

Returns

int
The hash code of the WorldUserChange, calculated using all five fields (GridLayerIndex, LOD, row, column, and layer).