fCraft.FloatingIslandMapGenState.MakeWaterSource C# (CSharp) Method

MakeWaterSource() public method

public MakeWaterSource ( int x, int y, int z ) : void
x int
y int
z int
return void
        void MakeWaterSource( int x, int y, int z ) {
            int hop = 0;
            List<Vector3I> choices = new List<Vector3I>();
            while( hop < genParams.SpringMaxHops && z > 1 ) {
                hop++;
                map.SetBlock( x, y, z, Block.Water );
                Block blockUnder = map.GetBlock( x, y, z - 1 );
                if( blockUnder == Block.Air || blockUnder == Block.Water ) {
                    do {
                        if( map.GetBlock( x, y, z - 1 ) == Block.Gravel ) break;
                        z--;
                        blockUnder = map.GetBlock( x, y, z );
                        map.SetBlock( x, y, z, Block.Water );
                    } while( blockUnder == Block.Air || blockUnder == Block.Water );
                    continue;
                }
                map.SetBlock( x, y, z - 1, Block.Gravel );
                choices.Clear();
                if( x > 0 && map.GetBlock( x - 1, y, z + 1 ) == Block.Air ) {
                    choices.Add( new Vector3I( x - 1, y, z ) );
                }
                if( x < map.Width - 1 && map.GetBlock( x + 1, y, z + 1 ) == Block.Air ) {
                    choices.Add( new Vector3I( x + 1, y, z ) );
                }
                if( y > 0 && map.GetBlock( x, y - 1, z + 1 ) == Block.Air ) {
                    choices.Add( new Vector3I( x, y - 1, z ) );
                }
                if( y < map.Length - 1 && map.GetBlock( x, y + 1, z + 1 ) == Block.Air ) {
                    choices.Add( new Vector3I( x, y + 1, z ) );
                }
                if( choices.Count == 0 ) break;
                Vector3I nextCoord = choices[rand.Next( choices.Count )];
                x = nextCoord.X;
                y = nextCoord.Y;
            }
        }