void AddColors(SquareCell cell, GridDirection direction) { SquareCell prevNeighbor = cell.GetNeighbor(direction.Previous()) ?? cell; SquareCell neighbor = cell.GetNeighbor(direction) ?? cell; SquareCell nextNeighbor = cell.GetNeighbor(direction.Next()) ?? cell; SquareCell next2Neighbor = cell.GetNeighbor(direction.Next2()) ?? cell; SquareCell next3Neighbor = cell.GetNeighbor(direction.Next3()) ?? cell; Color previousMix = (GetColor(prevNeighbor, cell) + cell.Color) / 2f; Color neighborMix = (GetColor(neighbor, cell) + cell.Color + GetColor(prevNeighbor, cell) + GetColor(nextNeighbor, cell)) / 4f; Color nextMix = (GetColor(nextNeighbor, cell) + cell.Color) / 2f; Color nextNeighborMix = (GetColor(nextNeighbor, cell) + cell.Color + GetColor(next2Neighbor, cell) + GetColor(next3Neighbor, cell)) / 4f; Color next2Mix = (GetColor(next3Neighbor, cell) + cell.Color) / 2f; if (cell.HasRiver) { if (cell.HasRiverThroughEdge(direction.Previous())) { terrain.AddTriangleColor(cell.Color); } if (cell.HasRiverThroughEdge(direction.Next())) { terrain.AddTriangleColor(cell.Color); } terrain.AddTriangleColor(cell.Color); terrain.AddTriangleColor(cell.Color); } else { terrain.AddTriangleColor(cell.Color); } if (cell.HasRiverThroughEdge(direction.Next())) { terrain.AddQuadColor(cell.Color, nextMix, nextMix, cell.Color); terrain.AddQuadColor(cell.Color, nextMix, nextMix, cell.Color); } else { terrain.AddQuadColor(cell.Color, nextMix, nextMix, cell.Color); } // next Edge if (cell.HasRiverThroughEdge(direction.Previous())) { terrain.AddQuadColor(cell.Color, cell.Color, previousMix, previousMix); terrain.AddQuadColor(cell.Color, cell.Color, previousMix, previousMix); } else { terrain.AddQuadColor(cell.Color, cell.Color, previousMix, previousMix); } // previous Edge if (cell.HasRiverThroughEdge(direction)) { } else { terrain.AddQuadColor(cell.Color, previousMix, neighborMix, nextMix); } // direction Corner if (cell.HasRiverThroughEdge(direction.Next2())) { } else { terrain.AddQuadColor(cell.Color, nextMix, nextNeighborMix, next2Mix); } // next Corner }