private void AddNeighbor(VoronoiGridChunk chunk) { if (!_neighbors.Contains(chunk)) { _neighbors.Add(chunk); } }
private void HandleInput() { Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { VoronoiGridChunk currentChunk = hit.transform.parent.GetComponent <VoronoiGridChunk> (); VoronoiCell currentCell = VoronoiGrid.GetCell(hit.point, currentChunk.GetNeighborhood()); if (_previousCell && _previousCell != currentCell) { ValidateDrag(currentCell); } else { _isDrag = false; } EditCells(currentCell); _previousCell = currentCell; } else { _previousCell = null; } }
private void CreateChunk(int i, Vector3 position) { VoronoiGridChunk chunk = _chunks[i] = Instantiate(ChunkPrefab); chunk.name = "Voronoi Grid Chunk " + i; chunk.transform.SetParent(transform, false); chunk.AddCell(GetCell(position)); chunk.AddToAtmosphere(_atmosphere); }