Struct SquareGridCell
Namespace: AnyPath.Graphs.SquareGrid
Assembly: AnyPath.dll
Syntax
public struct SquareGridCell : IEquatable<SquareGridCell>, INodeFlags
Constructors
SquareGridCell(int2, float, int)
Creates a square grid cell
Declaration
public SquareGridCell(int2 position, float enterCost = 0, int flags = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | position | Position of this cell. If you're using this as a query start, only the position is sufficient. |
| float | enterCost | Optional extra cost for entering this cell |
| int | flags | Optional flags for this cell |
SquareGridCell(Vector3Int, float, int)
Creates a square grid cell
Declaration
public SquareGridCell(Vector3Int position, float enterCost = 0, int flags = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position of this cell, note that the Z value is not used. If you're using this as a query start, only the position is sufficient. |
| float | enterCost | Optional extra cost for entering this cell |
| int | flags | Optional flags for this cell |
Properties
EnterCost
The cost associated with entering this cell. Note that this is additional to the distance and should not be a negative value.
Declaration
public readonly float EnterCost { get; }
Property Value
| Type | Description |
|---|---|
| float |
Flags
Flags for this location. Can be used in conjunction with FlagBitmask<TNode>.
Declaration
public readonly int Flags { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsOpen
Returns wether this cell is "walkable", that is, the EnterCost is not infinity.
Declaration
public bool IsOpen { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Position
Coordinate of this cell
Declaration
public readonly int2 Position { get; }
Property Value
| Type | Description |
|---|---|
| int2 |
Methods
ToVector3Int(int)
Utility to convert this cell into a Vector3Int for usage with a Unity Tilemap
Declaration
public Vector3Int ToVector3Int(int z = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | z | Optional Z value for the Vector3Int |
Returns
| Type | Description |
|---|---|
| Vector3Int | The position of this cell as a Vector3Int |
Operators
implicit operator int2(SquareGridCell)
Implicitly convert this location to an int2 value.
Declaration
public static implicit operator int2(SquareGridCell cell)
Parameters
| Type | Name | Description |
|---|---|---|
| SquareGridCell | cell |
Returns
| Type | Description |
|---|---|
| int2 |
implicit operator Vector2Int(SquareGridCell)
Implicitly convert this location to an Vector2Int value.
Declaration
public static implicit operator Vector2Int(SquareGridCell cell)
Parameters
| Type | Name | Description |
|---|---|---|
| SquareGridCell | cell |
Returns
| Type | Description |
|---|---|
| Vector2Int |