public Galaxy Generate(GalaxyGeneratorSettings settings) { // TODO: Validate settings if (CalculatePlanetCapacity(settings) < settings.PlanetCount) { throw new OutOfSpaceException($"Not enough space for planets in the galaxy."); } Galaxy galaxy = new Galaxy() { Bounds = new GalaxyBounds(settings.GalaxySize) }; var planets = RandomPositions(settings) .Take(settings.PlanetCount) .Select(CreatePlanet); galaxy.Planets.AddRange(planets); return(galaxy); }
private int CalculatePlanetCapacity(GalaxyGeneratorSettings settings) {