Custom Asteroids  0.2.0
A mod for Kerbal Space Program that lets users control where asteroids appear
 All Classes Namespaces Files Functions Properties Pages
PopulationLoader Class Reference

Stores raw asteroid data. More...

Package Functions

 PopulationLoader ()
 Creates an uninitialized solar system. More...
 
Population drawPopulation ()
 Randomly selects an asteroid population. More...
 
double getTotalRate ()
 Returns the total spawn rate of all asteroid populations. More...
 

Static Package Functions

static PopulationLoader Load ()
 Factory method obtaining Custom Asteroids settings from a config file. More...
 

Detailed Description

Stores raw asteroid data.

Invariant
At most one instance of this class exists
Todo:
Clean up this class

Constructor & Destructor Documentation

PopulationLoader ( )
package

Creates an uninitialized solar system.

Postcondition
No asteroids will be created
Exception Safety
Does not throw exceptions.

Member Function Documentation

Population drawPopulation ( )
package

Randomly selects an asteroid population.

The selection is weighted by the spawn rate of each population; a population with a rate of 2.0 is twice as likely to be chosen as one with a rate of 1.0.

Returns
A reference to the selected population
Exceptions
System.InvalidOperationExceptionThrown if there are no populations from which to choose one, or if all spawn rates are zero, or if any rate is negative
Exception Safety
Does not throw exceptions
double getTotalRate ( )
package

Returns the total spawn rate of all asteroid populations.

Currently only needed for normalizing the asteroid selection.

Returns
The sum of all spawn rates for all populations.
Exception Safety
Does not throw exceptions
static PopulationLoader Load ( )
staticpackage

Factory method obtaining Custom Asteroids settings from a config file.

Returns
A newly constructed PopulationLoader object containing up-to-date settings from the Custom Asteroids config file, or the default settings if no such file exists.
Exceptions
ThrowsSystem.TypeInitializationException if the PopulationLoader object could not be constructed
Exception Safety
The program is in a consistent state in the event of an exception
Todo:
Can I make Load() atomic?

The documentation for this class was generated from the following file: