Struct CornerIndex
Represents the index of a single corner of a tile.
Namespace: TycoonTerrain.Core
Assembly: TycoonTerrainAssembly.dll
Syntax
public struct CornerIndex : IEquatable<CornerIndex>
Properties
All
Iterates over all corners in the order north-east, south-east, south-west, north-west.
Declaration
public static IEnumerable<CornerIndex> All { get; }
Property Value
Type | Description |
---|---|
IEnumerable<CornerIndex> | Each corner index in the order north-east, south-east, south-west, north-west. |
Invalid
Gets the invalid tile corner.
Declaration
public static CornerIndex Invalid { get; }
Property Value
Type | Description |
---|---|
CornerIndex | The invalid tile corner. |
IsValid
Returns true if the tile corner is valid.
Declaration
public bool IsValid { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
NeighbourClockwise
Gets the clockwise neighbouring corner.
Declaration
public CornerIndex NeighbourClockwise { get; }
Property Value
Type | Description |
---|---|
CornerIndex | The clockwise neighbouring corner. |
NeighbourCounterClockwise
Gets the counter clockwise neighbouring corner.
Declaration
public CornerIndex NeighbourCounterClockwise { get; }
Property Value
Type | Description |
---|---|
CornerIndex | The counter clockwise neighbouring corner. |
NeighbourOpposite
Gets the opposite tile corner.
Declaration
public CornerIndex NeighbourOpposite { get; }
Property Value
Type | Description |
---|---|
CornerIndex | The opposite tile corner. |
NorthEast
Gets the north east tile corner.
Declaration
public static CornerIndex NorthEast { get; }
Property Value
Type | Description |
---|---|
CornerIndex | The north east tile corner. |
NorthWest
Gets the north west tile corner.
Declaration
public static CornerIndex NorthWest { get; }
Property Value
Type | Description |
---|---|
CornerIndex | The north west tile corner. |
SouthEast
Gets the south east tile corner.
Declaration
public static CornerIndex SouthEast { get; }
Property Value
Type | Description |
---|---|
CornerIndex | The south east tile corner. |
SouthWest
Gets the south west tile corner.
Declaration
public static CornerIndex SouthWest { get; }
Property Value
Type | Description |
---|---|
CornerIndex | The south west tile corner. |
Methods
Equals(Object)
Determines whether the specified Object, is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The Object to compare with this instance. |
Returns
Type | Description |
---|---|
Boolean |
|
Overrides
Equals(CornerIndex)
Equalses the specified other.
Declaration
public bool Equals(CornerIndex other)
Parameters
Type | Name | Description |
---|---|---|
CornerIndex | other | The other. |
Returns
Type | Description |
---|---|
Boolean |
GetClosestCorner(float2)
Find the nearest corner of the tile at localPosition
.
Declaration
public static CornerIndex GetClosestCorner(float2 localPosition)
Parameters
Type | Name | Description |
---|---|---|
Unity.Mathematics.float2 | localPosition |
Returns
Type | Description |
---|---|
CornerIndex | The corner index of the nearest corner. |
GetCornerOfDirection(CardinalDirection, Boolean)
Returns a CornerIndex that is associated with a given cardinal direction.
Declaration
public static CornerIndex GetCornerOfDirection(CardinalDirection direction, bool left)
Parameters
Type | Name | Description |
---|---|---|
CardinalDirection | direction | The direction pointing outwards from the center of the tile. |
Boolean | left | Whether to return the left (true) or right (false) corner when viewed from the center of a tile towards |
Returns
Type | Description |
---|---|
CornerIndex | The resulting tile corner index. |
Examples
GetCornerOfDirection(CardinalDirection.North, true) returns CornerIndex.NorthWest
GetCornerOfDirection(CardinalDirection.North, false) returns CornerIndex.NorthEast
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
ToString()
Converts to string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A String that represents this instance. |
Overrides
ToVertexOffset()
Converts to vertexoffset.
Declaration
public int2 ToVertexOffset()
Returns
Type | Description |
---|---|
Unity.Mathematics.int2 | An offset. |
Remarks
This will probably be moved in a future release.
Operators
Equality(CornerIndex, CornerIndex)
Implements the operator ==.
Declaration
public static bool operator ==(CornerIndex index1, CornerIndex index2)
Parameters
Type | Name | Description |
---|---|---|
CornerIndex | index1 | The index1. |
CornerIndex | index2 | The index2. |
Returns
Type | Description |
---|---|
Boolean | The result of the operator. |
Inequality(CornerIndex, CornerIndex)
Implements the operator !=.
Declaration
public static bool operator !=(CornerIndex index1, CornerIndex index2)
Parameters
Type | Name | Description |
---|---|---|
CornerIndex | index1 | The index1. |
CornerIndex | index2 | The index2. |
Returns
Type | Description |
---|---|
Boolean | The result of the operator. |