CellLong Structure

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

Represents a 2D or 3D cell. Similar to Cell but it uses longs to store the indices. Set the layer to 1 if the cell is meant to be 2D.

This struct is mainly used by editor code and is not really intended to be used by users, however you can use it if you wish. In most cases, however, you will need to cast the CellLong to a Cell in order to interact with the SAM API, so using the CellLong structure just results in more memory being used without any gain.

Fields

Name Type Default Value Description
One CellLong

A CellLong set to row/column/layer = 1. Provided for ease of use.

Zero CellLong

A CellLong set to row/column/layer = 0. Provided for ease of use.

Properties

Name Type Description
Column long

Gets the column index of the CellLong.

Item(System.Int32) long

Indexer which Gets the row, column, or layer component of the CellLong by using an index (0 = row, 1 = columns, 2 = layer).

Use it like you'd use an array, i.e., long row = CellLong[0];

Layer long

Gets the layer index of the CellLong.

Row long

Gets the row index of the CellLong.

Constructors

CellLong(long, long, long)

public CellLong(long row, long column, long layer)

Initializes a new instance of the CellLong structure.

Parameters

Name Type Description
row long

The row index of the CellLong.

column long

The column index of the CellLong.

layer long

The layer index of the CellLong. Only needed when the CellLong is associated with a three dimensional entity, otherwise just pass in 1.

Methods

operator *(CellLong, CellLong)

public static CellLong operator *(CellLong left, CellLong right)

* operater implementation that allows you to multiple one CellLong by another.

The row from the second CellLong is multiplied by the row from the first. The column by the column. The layer by the layer.

Parameters

Name Type Description
left CellLong

The first CellLong.

right CellLong

The second CellLong.

Returns

CellLong
The CellLong representing the multiplication of the second CellLong by the first


operator +(CellLong, CellLong)

public static CellLong operator +(CellLong left, CellLong right)

+ operater implementation that allows you to add two CellLongs together. Row is added to row, column to column, and layer to layer from each CellLong.

Parameters

Name Type Description
left CellLong

The first CellLong.

right CellLong

The second CellLong.

Returns

CellLong
The CellLong representing the addition of the two input CellLongs.


operator -(CellLong, CellLong)

public static CellLong operator -(CellLong left, CellLong right)

- operater implementation that allows you to subtract one CellLong from another.

The row from the second CellLong is subtracted from the row of the first. The column from the column. The layer from the layer.

Parameters

Name Type Description
left CellLong

The first CellLong.

right CellLong

The second CellLong.

Returns

CellLong
The CellLong representing the subtraction of the second CellLong from the first


operator !=(CellLong, CellLong)

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

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

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

Parameters

Name Type Description
left CellLong

The first CellLong.

right CellLong

The second CellLong.

Returns

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


operator /(CellLong, CellLong)

public static CellLong operator /(CellLong numerator, CellLong denominator)

/ operater implementation that allows you to divide one CellLong by another.

The row from the numerator CellLong is divided by the row from the denominator CellLong (numerator/denominator). The column by the column. The layer by the layer.

Parameters

Name Type Description
numerator CellLong

The numerator CellLong.

denominator CellLong

The denominator CellLong.

Returns

CellLong
The CellLong representing the division of the numerator CellLong by the denominator CellLong. Uses longeger division for each component of the CellLong.


operator <(CellLong, CellLong)

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

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

Parameters

Name Type Description
left CellLong

The left CellLong.

right CellLong

The right CellLong.

Returns

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


operator <=(CellLong, CellLong)

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

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

Parameters

Name Type Description
left CellLong

The left CellLong.

right CellLong

The right CellLong.

Returns

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


operator ==(CellLong, CellLong)

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

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

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

Parameters

Name Type Description
left CellLong

The first CellLong.

right CellLong

The second CellLong.

Returns

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


operator >(CellLong, CellLong)

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

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

Parameters

Name Type Description
left CellLong

The left CellLong.

right CellLong

The right CellLong.

Returns

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


operator >=(CellLong, CellLong)

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

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

Parameters

Name Type Description
left CellLong

The left CellLong.

right CellLong

The right CellLong.

Returns

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


CompareTo(CellLong)

public int CompareTo(CellLong other)

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

Returns

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

The following logic is used to determine the order. First, the layer of the two CellLongs is compared. If this CellLong's layer is less than the input CellLong's layer, -1 is returned. If this CellLong's layer is greater than the input CellLong'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 CellLong's are equal and have the same placement in the order.


Equals(CellLong)

public bool Equals(CellLong other)

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

Parameters

Name Type Description
other object

The other CellLong to compare this CellLong against.

Returns

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

Parameters

Name Type Description
obj object

The object to check this CellLong against.

Returns

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


GetHashCode()

public override int GetHashCode()

Returns a hash code for this CellLong. Uses all three indexes (row, column and layer) to compute it.

Returns

int
The hash code of the CellLong, calculated using all three fields (row, column, and layer).


ToString()

public override string ToString()

Returns a nicely formatted string representation of the CellLong's Indexes.

Returns


A string representation of the CellLong's Indexes.


WithColumnAdjusted(long)

public CellLong WithColumnAdjusted(long layerAdjustment)

Returns a copy of the CellLong structure with all values the same except for the Column. The new column value is equal to old column value + columnAdjustment

Parameters

Name Type Description
columnAdjustment long

The adjustment to the column (added to current column value)

Returns

CellLong
The copy of this CellLong structure with the new adjusted column value


WithLayerAdjusted(long)

public CellLong WithLayerAdjusted(long layerAdjustment)

Returns a copy of the CellLong structure with all values the same except for the Layer. The new layer value is equal to old layer value + layerAdjustment

Parameters

Name Type Description
layerAdjustment long

The adjustment to the layer (added to current layer value)

Returns

CellLong
The copy of this CellLong structure with the new adjusted layer value


WithNewColumn(long)

public CellLong WithNewColumn(long newColumn)

Returns a copy of the CellLong structure with all values the same except for the Column, which is replaced by the input newColumn value.

Parameters

Name Type Description
newColumn long

The new column value to use.

Returns

CellLong
The copy of this CellLong structure with the new column value.


WithNewLayer(long)

public CellLong WithNewLayer(long newLayer)

Returns a copy of the CellLong structure with all values the same except for the Layer, which is replaced by the input newLayer value.

Parameters

Name Type Description
newLayer long

The new layer value to use.

Returns

CellLong
The copy of this CellLong structure with the new layer value.


WithNewRow(long)

public CellLong WithNewRow(long newRow)

Returns a copy of the CellLong structure with all values the same except for the Row, which is replaced by the input newRow value.

Parameters

Name Type Description
newRow long

The new row value to use.

Returns

CellLong
The copy of this CellLong structure with the new row value.


WithRowAdjusted(long)

public CellLong WithRowAdjusted(long rowAdjustment)

Returns a copy of the CellLong structure with all values the same except for the Row. The new row value is equal to old row value + rowAdjustment

Parameters

Name Type Description
rowAdjustment long

The adjustment to the row (added to current row value)

Returns

CellLong
The copy of this CellLong structure with the new adjusted row value