Exemple #1
0
    private Voxel GetNearestVoxelAt(Vector3 position, int range = 1)
    {
        var posCoord = position.ToCoordinate();
        Voxel voxel = null;

        if (TryGetVoxelAt(posCoord, out voxel))
        {
            return voxel;
        }
        else
        {
            return GetNeighbourBlocksAtRange(new Coordinate(posCoord.x, posCoord.y, posCoord.z), range).OrderBy(n => Vector3.Distance(position, new Vector3(n.coordinate.x, n.coordinate.y, n.coordinate.z))).FirstOrDefault();
        }
    }
Exemple #2
0
 private bool TryGetVoxelAt(Vector3 position, out Voxel voxel)
 {
     var coords = position.ToCoordinate();
     return TryGetVoxelAt(coords.x, coords.y, coords.z, out voxel);
 }
Exemple #3
0
 private void AddVoxelsToModify(Vector3 position, int range, VoxelType desiredType)
 {
     Voxel centralVoxel;
     if (TryGetVoxelAt(position, out centralVoxel))
     {
         AddVoxelToModify(centralVoxel, desiredType);
         var neighbours = GetNeighbourVoxelsAtRange(position.ToCoordinate(), range);
         neighbours.ForEach(v => AddVoxelToModify(v, desiredType));
     }
 }