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

Stores raw asteroid data. More...

Classes

class  DefaultAsteroids
 Contains settings for asteroids that aren't affected by Custom Asteroids. More...
 

Package Functions

 PopulationLoader ()
 Creates an empty solar system. More...
 
Population drawPopulation ()
 Randomly selects an asteroid population. More...
 
double getTotalRate ()
 Returns the total spawn rate of all asteroid populations. More...
 
string defaultName ()
 Returns the name used for asteroids on stock orbits. More...
 

Static Package Functions

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

Static Private Member Functions

static void printNode (ConfigNode node)
 Debug function for traversing node tree. More...
 

Private Attributes

List< PopulationasteroidSets
 The set of loaded asteroid Population objects. More...
 
DefaultAsteroids untouchedSet
 Settings related to stock-like asteroids. 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 empty solar system.

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

Member Function Documentation

string defaultName ( )
package

Returns the name used for asteroids on stock orbits.

Returns
The name with which to replace "Ast."
Exception Safety
Does not throw exceptions
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, 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.

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 a full list of all valid asteroid groups in asteroid config files
Exceptions
System.TypeInitializationExceptionThrown 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?
static void printNode ( ConfigNode  node)
staticprivate

Debug function for traversing node tree.

Parameters
[in]nodeThe top-level node of the tree to be printed
Postcondition
The current node and all nodes beneath it are printed, in depth-first order

Member Data Documentation

List<Population> asteroidSets
private

The set of loaded asteroid Population objects.

Note
Initialized via ConfigNode
DefaultAsteroids untouchedSet
private

Settings related to stock-like asteroids.

Note
Initialized via ConfigNode

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