Kerbal Space Program  1.12.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Static Public Member Functions | Public Attributes | List of all members
FinePrint.Utilities.SystemUtilities Class Reference

Static Public Member Functions

static bool CheckTouristRecoveryContractKerbals (string kerbalName)
 Scans All tourist contracts and recovery contracts for a matching Kerbal Name. Returns True if a match is found, otherwise false. More...
 
static bool CoinFlip (System.Random generator=null)
 Returns a random true/false. More...
 
static void CondenseNodeList (ConfigNode node, string valueName, string listName)
 Takes multiple separate values in a ConfigNode and condenses them into a single delimited node list value. More...
 
static void ExpungeKerbal (ProtoCrewMember pcm)
 Completely erases a kerbal from existence. More...
 
static void ExpungeVessel (Vessel v)
 Completely erases a vessel from existence. More...
 
static bool FlightIsReady (bool checkVessel=false, CelestialBody targetBody=null)
 Performs all the necessary checks to make sure the flight scene is ready to go, and some optional ones. More...
 
static bool FlightIsReady (Contract.State currentState, Contract.State targetState, bool checkVessel=false, CelestialBody targetBody=null)
 Performs all the necessary checks to make sure the flight scene is ready to go, and some optional ones. More...
 
static uint HashNumber (uint x)
 Hashes an unsigned integer into another, unrelated unsigned integer. More...
 
static void LoadNode< T > (ConfigNode node, string className, string valueName, ref T value, T defaultValue, bool logging=true)
 Loads a ConfigNode value, handles logging and recovery if loading fails. More...
 
static void LoadNodeList< T > (ConfigNode node, string className, string valueName, ref List< T > list)
 Loads a list of objects stored in a single ConfigNode value as a delimited string. More...
 
static void LoadNodePair< T1, T2 > (ConfigNode node, string className, string valueName, ref KeyValuePair< T1, T2 > pair)
 Loads a pair of objects stored in a single ConfigNode value as a delimited string. More...
 
static Texture2D LoadTexture (string textureName)
 Simplifies the action of loading a texture. More...
 
static double MeasureDeviation (double v1, double v2)
 Meaures the deviation between two values relative to each other. More...
 
static double MeasureDeviationByValue (double v1, double v2, double fullValue)
 Meaures the deviation between two values relative to a reference value. More...
 
static void ProcessSideRequests (Contract contract, ConfigNode contractNode, CelestialBody targetBody, string vesselName, ref float fundsMultiplier, ref float scienceMultiplier, ref float reputationMultiplier, Vessel vessel=null)
 Adds request parameters to a contract. Affects several contracts and parameters. More...
 
static Color RandomColor (int seed=0, float alpha=1.0f, float saturation=1.0f, float brightness=0.5f)
 Generates a randomized HSV color. More...
 
static T RandomSplitChoice< T > (List< List< T >> listOfLists, System.Random generator=null)
 Chooses a value randomly from several list references without combining them into a larger one. More...
 
static void SaveNodeList< T > (ConfigNode node, string listName, List< T > list)
 Saves a list of objects in a single ConfigNode value as a delimited string. More...
 
static void ShuffleList< T > (ref List< T > list, System.Random generator=null)
 Shuffles a list at random. More...
 
static int SuperSeed (Contract c)
 Creates an excessively unique and unpredictable seed for a contract. More...
 
static bool TryConvert< T > (string input, out T value, ref string error)
 Attempts to convert a string into any given type or enumeration. More...
 
static PreBuiltCraftDefinition ValidateLoadCraftNode (string url, string className, bool brokenParts)
 Will Validate/Load a Craft file located in the file at url in the filesystem. If the Craft is valid it will return a PreBuiltCraftDefinition pre-populated. If the Craft is invalid or fails to load will return Null. More...
 
static PreBuiltCraftDefinition ValidateLoadCraftNode (string url, string className, bool brokenParts, bool bypassTechCheck)
 Will Validate/Load a Craft file located in the file at url in the filesystem. If the Craft is valid it will return a PreBuiltCraftDefinition pre-populated. If the Craft is invalid or fails to load will return Null. More...
 
static bool WithinDeviation (double v1, double v2, double deviation)
 Checks if two values are within a certain percentage of each other. More...
 
static double WithinDeviationAccuracy (double v1, double v2, double deviation)
 Get the accuracy value of two values within a certain percentage of each other. More...
 
static double WithinDeviationByReferenceAccuracy (double v1, double v2, double reference, double deviation)
 Gets the accuracy value of two values within a certain percentage of each other based on a reference value More...
 
static bool WithinDeviationByValue (double v1, double v2, double deviation, double fullValue)
 Checks if two values are within a certain percentage of the reference value. More...
 

Public Attributes

const int frameSuccessDelay = 5
 

Member Function Documentation

static bool FinePrint.Utilities.SystemUtilities.CheckTouristRecoveryContractKerbals ( string  kerbalName)
inlinestatic

Scans All tourist contracts and recovery contracts for a matching Kerbal Name. Returns True if a match is found, otherwise false.

Parameters
kerbalNameThe name to scan for. Best result is to pass in the first name only.
Returns
True if a match is found, otherwise false.
static bool FinePrint.Utilities.SystemUtilities.CoinFlip ( System.Random  generator = null)
inlinestatic

Returns a random true/false.

Parameters
generatorAn optional random generator to use.
Returns
Random boolean.
static void FinePrint.Utilities.SystemUtilities.CondenseNodeList ( ConfigNode  node,
string  valueName,
string  listName 
)
inlinestatic

Takes multiple separate values in a ConfigNode and condenses them into a single delimited node list value.

Parameters
nodeThe node to check.
valueNameThe name of the values to find and condense.
listNameThe name of the delimited list to save to the node.
static void FinePrint.Utilities.SystemUtilities.ExpungeKerbal ( ProtoCrewMember  pcm)
inlinestatic

Completely erases a kerbal from existence.

Parameters
pcmThe ProtoCrewMember.

< Somewhat nuclear kerbal annihilation process.

< Do not check GetVesselCrew, it basically does the same thing as below.

static void FinePrint.Utilities.SystemUtilities.ExpungeVessel ( Vessel  v)
inlinestatic

Completely erases a vessel from existence.

Parameters
vThe vessel.
static bool FinePrint.Utilities.SystemUtilities.FlightIsReady ( bool  checkVessel = false,
CelestialBody  targetBody = null 
)
inlinestatic

Performs all the necessary checks to make sure the flight scene is ready to go, and some optional ones.

Parameters
checkVesselOptional: Check if vessel is null.
targetBodyOptional: Make sure vessel is at a celestial body.
Returns
If the scene is ready to go.
static bool FinePrint.Utilities.SystemUtilities.FlightIsReady ( Contract.State  currentState,
Contract.State  targetState,
bool  checkVessel = false,
CelestialBody  targetBody = null 
)
inlinestatic

Performs all the necessary checks to make sure the flight scene is ready to go, and some optional ones.

Parameters
currentStateCurrent contract state.
targetStateContract state that must be matched.
checkVesselOptional: Check if vessel is null.
targetBodyOptional: Make sure vessel is at a celestial body.
Returns
If the scene is ready to go.
static uint FinePrint.Utilities.SystemUtilities.HashNumber ( uint  x)
inlinestatic

Hashes an unsigned integer into another, unrelated unsigned integer.

Parameters
xThe unsigned integer.
Returns
Another unsigned integer.
static void FinePrint.Utilities.SystemUtilities.LoadNode< T > ( ConfigNode  node,
string  className,
string  valueName,
ref T  value,
defaultValue,
bool  logging = true 
)
inlinestatic

Loads a ConfigNode value, handles logging and recovery if loading fails.

Template Parameters
TThe type of the final variable.
Parameters
nodeThe node to load from.
classNameName of the calling class for logs.
valueNameName of the value in the ConfigNode.
valueValue to dump into if successful.
defaultValueDefault value to recover with if unsuccessful.
loggingOptional flag to temporarily disable logging.
static void FinePrint.Utilities.SystemUtilities.LoadNodeList< T > ( ConfigNode  node,
string  className,
string  valueName,
ref List< T >  list 
)
inlinestatic

Loads a list of objects stored in a single ConfigNode value as a delimited string.

Template Parameters
TThe type of the list.
Parameters
nodeThe node to load from.
classNameName of the calling class for logs.
valueNameName of the delimited string in the ConfigNode.
listList to dump into if successful.

< We don't save empty lists at all to prevent save pollution, so loading can fail quite frequently. We disable logs here for this reason.

static void FinePrint.Utilities.SystemUtilities.LoadNodePair< T1, T2 > ( ConfigNode  node,
string  className,
string  valueName,
ref KeyValuePair< T1, T2 >  pair 
)
inlinestatic

Loads a pair of objects stored in a single ConfigNode value as a delimited string.

Template Parameters
T1The type of the key in the pair.
T2The type of the value in the pair.
Parameters
nodeThe node to load from.
classNameName of the calling class for logs.
valueNameName of the delimited string in the ConfigNode.
pairKeyValuePair to dump into if successful.

< We don't save empty pairs at all to prevent save pollution, so loading can fail quite frequently. We disable logs here for this reason.

static Texture2D FinePrint.Utilities.SystemUtilities.LoadTexture ( string  textureName)
inlinestatic

Simplifies the action of loading a texture.

Parameters
textureNameName of the texture.
Returns
A Unity texture.
static double FinePrint.Utilities.SystemUtilities.MeasureDeviation ( double  v1,
double  v2 
)
inlinestatic

Meaures the deviation between two values relative to each other.

Parameters
v1The first value.
v2The second value.
Returns
fraction representing the deviation between the two values.
static double FinePrint.Utilities.SystemUtilities.MeasureDeviationByValue ( double  v1,
double  v2,
double  fullValue 
)
inlinestatic

Meaures the deviation between two values relative to a reference value.

Parameters
v1The first value.
v2The second value.
fullValueThe value that equals 100% deviation
Returns
fraction representing the deviation between the two values.
static void FinePrint.Utilities.SystemUtilities.ProcessSideRequests ( Contract  contract,
ConfigNode  contractNode,
CelestialBody  targetBody,
string  vesselName,
ref float  fundsMultiplier,
ref float  scienceMultiplier,
ref float  reputationMultiplier,
Vessel  vessel = null 
)
inlinestatic

Adds request parameters to a contract. Affects several contracts and parameters.

Parameters
contractThe contract.
contractNodeThe contract template configuration node.
targetBodyThe celestial body of the contract.
vesselNameA vessel type description string.
fundsMultiplierReference to running funds multiplier.
scienceMultiplierReference to running science multiplier.
reputationMultiplierReference to running reputation multiplier.
vesselOptional vessel to pass to the part request for contextuals.

< Crew requests take a bit more digging.

< Crew interest will be based off of an even split of each trait for half the vessel, plus any specialized parts.

static Color FinePrint.Utilities.SystemUtilities.RandomColor ( int  seed = 0,
float  alpha = 1.0f,
float  saturation = 1.0f,
float  brightness = 0.5f 
)
inlinestatic

Generates a randomized HSV color.

Parameters
seedThe random seed to use.
alphaThe alpha of the color.
saturationThe saturation of the color.
brightnessThe brightness of the color.
Returns
A usable Unity Color.
static T FinePrint.Utilities.SystemUtilities.RandomSplitChoice< T > ( List< List< T >>  listOfLists,
System.Random  generator = null 
)
inlinestatic

Chooses a value randomly from several list references without combining them into a larger one.

Parameters
listOfListsAn List of Lists to choose from.
generatorAn optional random generator to use.

< First we want the total count of all the lists, that will be used for a weighted choice.

static void FinePrint.Utilities.SystemUtilities.SaveNodeList< T > ( ConfigNode  node,
string  listName,
List< T >  list 
)
inlinestatic

Saves a list of objects in a single ConfigNode value as a delimited string.

Template Parameters
TThe type of the list.
Parameters
nodeThe node to save to.
listNameName of the delimited string in the ConfigNode.
listList to save.
static void FinePrint.Utilities.SystemUtilities.ShuffleList< T > ( ref List< T >  list,
System.Random  generator = null 
)
inlinestatic

Shuffles a list at random.

Template Parameters
TThe type of list.
Parameters
listThe list reference.
generatorAn optional random generator to use.
static int FinePrint.Utilities.SystemUtilities.SuperSeed ( Contract  c)
inlinestatic

Creates an excessively unique and unpredictable seed for a contract.

Parameters
cThe contract.
Returns
A very unique seed.
static bool FinePrint.Utilities.SystemUtilities.TryConvert< T > ( string  input,
out T  value,
ref string  error 
)
inlinestatic

Attempts to convert a string into any given type or enumeration.

Template Parameters
TThe type of the final variable.
Parameters
inputThe input string.
valueValue to dump into if successful.
errorError to dump into if unsuccessful.
Returns
If the conversion succeeds.
static PreBuiltCraftDefinition FinePrint.Utilities.SystemUtilities.ValidateLoadCraftNode ( string  url,
string  className,
bool  brokenParts 
)
inlinestatic

Will Validate/Load a Craft file located in the file at url in the filesystem. If the Craft is valid it will return a PreBuiltCraftDefinition pre-populated. If the Craft is invalid or fails to load will return Null.

Parameters
urlThe url for the craft file.
classNameName of the calling class for logs.
Returns
static PreBuiltCraftDefinition FinePrint.Utilities.SystemUtilities.ValidateLoadCraftNode ( string  url,
string  className,
bool  brokenParts,
bool  bypassTechCheck 
)
inlinestatic

Will Validate/Load a Craft file located in the file at url in the filesystem. If the Craft is valid it will return a PreBuiltCraftDefinition pre-populated. If the Craft is invalid or fails to load will return Null.

Parameters
urlThe url for the craft file.
classNameName of the calling class for logs.
Returns
static bool FinePrint.Utilities.SystemUtilities.WithinDeviation ( double  v1,
double  v2,
double  deviation 
)
inlinestatic

Checks if two values are within a certain percentage of each other.

Parameters
v1The first value.
v2The second value.
deviationThe deviation percentage (0->100).
Returns
If the values are within that percentage of each other.
static double FinePrint.Utilities.SystemUtilities.WithinDeviationAccuracy ( double  v1,
double  v2,
double  deviation 
)
inlinestatic

Get the accuracy value of two values within a certain percentage of each other.

Parameters
v1The first value.
v2The second value.
deviationThe deviation percentage.
Returns
The accuracy percentage.
static double FinePrint.Utilities.SystemUtilities.WithinDeviationByReferenceAccuracy ( double  v1,
double  v2,
double  reference,
double  deviation 
)
inlinestatic

Gets the accuracy value of two values within a certain percentage of each other based on a reference value

Parameters
v1The first value.
v2The second value.
referenceThe difference that equates to 100%
deviationThe deviation percentage.
Returns
The accuracy percentage.
static bool FinePrint.Utilities.SystemUtilities.WithinDeviationByValue ( double  v1,
double  v2,
double  deviation,
double  fullValue 
)
inlinestatic

Checks if two values are within a certain percentage of the reference value.

Parameters
v1The first value.
v2The second value.
deviationThe deviation percentage (0->100).
fullValueThe value that equals 100% deviation
Returns
If the values are within that percentage of each other.

Member Data Documentation

const int FinePrint.Utilities.SystemUtilities.frameSuccessDelay = 5

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