Class Cell
Represents a single space on the map for a tile to be potentially placed.
Namespace: Global
Assembly: cs.temp.dll.dll
Syntax
public class Cell : IHeapItem<Cell>
Constructors
Cell(Vector3Int, Cell.CellStatus)
Constructor for Cell. Must set an initial postions and status.
Declaration
public Cell(Vector3Int position, Cell.CellStatus status = Cell.CellStatus.ValidCell)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | position | The position of the cell on the Map, including its depth (z). |
Cell.CellStatus | status | Denotes the cells current state. |
Fields
gCost
The cost of traversal between the start cell and the cell.
Declaration
public int gCost
Field Value
Type | Description |
---|---|
Int32 |
hCost
The estimated cost of traversal from the cell to the end goal cell.
Declaration
public int hCost
Field Value
Type | Description |
---|---|
Int32 |
isTraversable
Denotes whether the cell is able to be travelled across.
Declaration
public bool isTraversable
Field Value
Type | Description |
---|---|
Boolean |
isWaterBound
Denotes whether the cell is a water boundary; that is , if the cell is adjacent to water.
Declaration
public bool isWaterBound
Field Value
Type | Description |
---|---|
Boolean |
onBoundary
Denotes whether the cell is on the boundary; that is, if the cell neighours an invalid cell or is at the end of the map.
Declaration
public bool onBoundary
Field Value
Type | Description |
---|---|
Boolean |
parent
The parent of the current cell. Used for path generation.
Declaration
public Cell parent
Field Value
Type | Description |
---|---|
Cell |
position
The position of the cell on the Map, including its depth (z).
Declaration
public Vector3Int position
Field Value
Type | Description |
---|---|
Vector3Int |
status
Denotes the cells current state.
Declaration
public Cell.CellStatus status
Field Value
Type | Description |
---|---|
Cell.CellStatus |
Properties
HeapIndex
Getter and setter for the heap index.
Declaration
public int HeapIndex { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
CompareTo(Cell)
Used to order cells in the heap based on lowest fCost or hCost first. Used during path generation.
Declaration
public int CompareTo(Cell otherCell)
Parameters
Type | Name | Description |
---|---|---|
Cell | otherCell | The cell to compare to. |
Returns
Type | Description |
---|---|
Int32 | The priority of the cell relative to the other cell. -1 for lower priority, 0 for same priority, and 1 for higher priority. |
fCost()
Calculates the f cost, which is a sum of the g cost and h cost.
Declaration
public int fCost()
Returns
Type | Description |
---|---|
Int32 | The f cost. |
setCellStatus(Cell.CellStatus, Boolean)
Sets the cell's status to a new status.
Declaration
public void setCellStatus(Cell.CellStatus newStatus, bool intersectionsEnabled = false)
Parameters
Type | Name | Description |
---|---|---|
Cell.CellStatus | newStatus | The new status to set the cell to. |
Boolean | intersectionsEnabled | Whether intersections are enabled. For path generation. Optional parameter. |