public void EstablishCellNeighbours() { foreach (var pair in _occupiedCells) { ObjectPlacementPathTileConnectionGridCell tileConnectionGridCell = pair.Value; var potentialNeighbour = new ObjectPlacementPathTileConnectionGridCellIndices(tileConnectionGridCell.XIndex + 1, tileConnectionGridCell.ZIndex); if (IsCellOccupied(potentialNeighbour)) { tileConnectionGridCell.AddNeighbourIfPossible(GetCellAtIndicesIfOccupied(potentialNeighbour)); } potentialNeighbour = new ObjectPlacementPathTileConnectionGridCellIndices(tileConnectionGridCell.XIndex - 1, tileConnectionGridCell.ZIndex); if (IsCellOccupied(potentialNeighbour)) { tileConnectionGridCell.AddNeighbourIfPossible(GetCellAtIndicesIfOccupied(potentialNeighbour)); } potentialNeighbour = new ObjectPlacementPathTileConnectionGridCellIndices(tileConnectionGridCell.XIndex, tileConnectionGridCell.ZIndex + 1); if (IsCellOccupied(potentialNeighbour)) { tileConnectionGridCell.AddNeighbourIfPossible(GetCellAtIndicesIfOccupied(potentialNeighbour)); } potentialNeighbour = new ObjectPlacementPathTileConnectionGridCellIndices(tileConnectionGridCell.XIndex, tileConnectionGridCell.ZIndex - 1); if (IsCellOccupied(potentialNeighbour)) { tileConnectionGridCell.AddNeighbourIfPossible(GetCellAtIndicesIfOccupied(potentialNeighbour)); } } }
public ObjectPlacementPathTileConnectionGridCell GetCellAtIndicesIfOccupied(ObjectPlacementPathTileConnectionGridCellIndices cellIndices) { if (IsCellOccupied(cellIndices)) { return(_occupiedCells[cellIndices]); } else { return(null); } }
public ObjectPlacementPathTileConnectionGridCell(ObjectPlacementPathTileConnectionGridCellIndices cellIndices, ObjectPlacementPathTileConnectionGrid parentGrid) { _cellIndices = cellIndices; _parentGrid = parentGrid; }
public Vector3 CalculateCellPosition(ObjectPlacementPathTileConnectionGridCellIndices cellIndices) { return(CalculateCellPosition(cellIndices.XIndex, cellIndices.ZIndex)); }
public bool IsCellOccupied(ObjectPlacementPathTileConnectionGridCellIndices cellIndices) { return(_occupiedCells.ContainsKey(cellIndices)); }