public bool CheckCellSolutionForCollision(Vector2Int cellCoordinates, OutputGrid outputGrid) { foreach (var neighbour in Create4DirectionNeighbours(cellCoordinates)) { if (outputGrid.CheckIfValidPosition(neighbour.CellToPropagatePosition) == false) { continue; } HashSet <int> possibleIndices = new HashSet <int>(); foreach (var patternIndexAtNeighbour in outputGrid.GetPossibleValueForPossition(neighbour.CellToPropagatePosition)) { var possibleNeighboursForBase = patternManager.GetPossibleNeighboursForPatternInDirection(patternIndexAtNeighbour, neighbour.DirectionFromBase.GetOppositeDirectionTo()); possibleIndices.UnionWith(possibleNeighboursForBase); } if (possibleIndices.Contains(outputGrid.GetPossibleValueForPossition(cellCoordinates).First()) == false) { return(true); } } return(false); }
public List <VectorPair> CheckIfNeighboursAreCollapsed(VectorPair pairToCheck, OutputGrid outputgrid) { return(Create4DirectionNeighbours(pairToCheck.CellToPropagatePosition, pairToCheck.BaseCellPosition) .Where(x => outputgrid.CheckIfValidPosition(x.CellToPropagatePosition) && outputgrid.CheckIfCellIsCollapsed(x.CellToPropagatePosition) == false) .ToList()); }