public void ProbeGuidelines(Point3 fromPoint) { Voxel fromVox = _board.GetVoxelAt(fromPoint); ClearWireBoxes(); if (fromVox == null) { return; } // probe for guidelines Point3 nextPoint = fromPoint + new Point3(0, 0, 1); Voxel nextVox = _board.GetVoxelAt(nextPoint); Voxel lastVox = fromVox; while (nextVox != null && nextVox.State.name == "Empty") { lastVox = nextVox; nextPoint += new Point3(0, 0, 1); nextVox = _board.GetVoxelAt(nextPoint); } Vector3 top = lastVox != null ? lastVox.transform.position : Vector3.zero; if (fromVox != lastVox) { _wiredBoxes.Add(lastVox); } nextPoint = fromPoint + new Point3(0, 0, -1); nextVox = _board.GetVoxelAt(nextPoint); lastVox = fromVox; while (nextVox != null && nextVox.State.name == "Empty") { lastVox = nextVox; nextPoint += new Point3(0, 0, -1); nextVox = _board.GetVoxelAt(nextPoint); } Vector3 bottom = lastVox != null ? lastVox.transform.position : Vector3.zero; if (fromVox != lastVox) { _wiredBoxes.Add(lastVox); } Vector3 left = Vector3.zero; Vector3 right = Vector3.zero; if (_board.Orientation == Direction.South || _board.Orientation == Direction.North) { nextPoint = fromPoint + new Point3(-1, 0, 0); nextVox = _board.GetVoxelAt(nextPoint); lastVox = fromVox; while (nextVox != null && nextVox.State.name == "Empty") { lastVox = nextVox; nextPoint += new Point3(-1, 0, 0); nextVox = _board.GetVoxelAt(nextPoint); } left = lastVox.transform.position; if (fromVox != lastVox) { _wiredBoxes.Add(lastVox); } nextPoint = fromPoint + new Point3(1, 0, 0); nextVox = _board.GetVoxelAt(nextPoint); lastVox = fromVox; while (nextVox != null && nextVox.State.name == "Empty") { lastVox = nextVox; nextPoint += new Point3(1, 0, 0); nextVox = _board.GetVoxelAt(nextPoint); } right = lastVox.transform.position; if (fromVox != lastVox) { _wiredBoxes.Add(lastVox); } } else { nextPoint = fromPoint + new Point3(0, -1, 0); nextVox = _board.GetVoxelAt(nextPoint); lastVox = fromVox; while (nextVox != null && nextVox.State.name == "Empty") { lastVox = nextVox; nextPoint += new Point3(0, -1, 0); nextVox = _board.GetVoxelAt(nextPoint); } left = lastVox.transform.position; if (fromVox != lastVox) { _wiredBoxes.Add(lastVox); } nextPoint = fromPoint + new Point3(0, 1, 0); nextVox = _board.GetVoxelAt(nextPoint); lastVox = fromVox; while (nextVox != null && nextVox.State.name == "Empty") { lastVox = nextVox; nextPoint += new Point3(0, 1, 0); nextVox = _board.GetVoxelAt(nextPoint); } right = lastVox.transform.position; if (fromVox != lastVox) { _wiredBoxes.Add(lastVox); } } head.EnableGuidelines(top, bottom, left, right); foreach (Voxel v in _wiredBoxes) { _board.SetVoxel(v.point, "Cubed"); } }