fCraft.Forester.PlantTrees C# (CSharp) Method

PlantTrees() private static method

private static PlantTrees ( ForesterArgs args, ICollection treelist ) : void
args ForesterArgs
treelist ICollection
return void
        private static void PlantTrees( ForesterArgs args, ICollection<Tree> treelist )
        {
            int treeheight = args.Height;

            int attempts = 0;
            while ( treelist.Count < args.TreeCount && attempts < MaxTries ) {
                attempts++;
                int height = args.Rand.Next( treeheight - args.HeightVariation,
                                             treeheight + args.HeightVariation + 1 );

                Vector3I treeLoc = FindRandomTreeLocation( args, height );
                if ( treeLoc.Y < 0 )
                    continue;
                else
                    treeLoc.Y++;
                treelist.Add( new Tree {
                    Args = args,
                    Height = height,
                    Pos = treeLoc
                } );
            }
        }