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

Static Public Member Functions

static bool ActiveVesselFallback (ref Vessel v, bool logging=true)
 Sets a vessel to the active vessel if it is null and it is possible. More...
 
static int ActualCrewCapacity (Vessel v=null)
 Checks a vessel for its actual crew capacity, works for protovessels. More...
 
static Dictionary< Vessel,
VesselType
ClassifyAllVesselsAt (CelestialBody body, bool useVesselType=true)
 Identifies the vessel type of all vessels at a particular celestial body. More...
 
static VesselType ClassifyVesselType (Vessel v=null, bool useVesselType=true)
 Classifies the type of a vessel based on its physical characteristics, not an arbitrarily defined type. More...
 
static int CrewTraitMissionAvailability (string trait, CelestialBody targetBody=null, Vessel excludeVessel=null)
 Determines how many kerbals with a particular experience trait are available or already near the area of a mission. More...
 
static void DiscoverVessel (Vessel v=null)
 Marks a vessel as "owned" with the discovery system. More...
 
static Vector3 EstimatePartSize (Part p)
 Estimates the size of a part, taking SkinnedMeshRenderer oddities into account. More...
 
static Part FindFirstPartOrModuleName (List< string > partNames, List< string > moduleNames)
 Does a simple search for the first part that exists in a list of part and module names. More...
 
static Vessel FindVesselWithPartIDs (List< uint > partIDs)
 Finds a vessel with the most part IDs from a given list. More...
 
static Orbit GenerateAdjustedVesselOrbit (double minimumDeviation, double modificationLength, int numberOfModifications, System.Random generator=null, Vessel v=null)
 Returns a vessel's orbit with a slight modification by a certain percentage. More...
 
static FlightBand GetFlightBand (double threshold, Vessel v=null)
 Gets the flight band of a vessel based on an altitude threshold. More...
 
static List< uint > GetPartIDList (Vessel v=null)
 Gets a list of part IDs for a specific vessel. More...
 
static string GetPartName (Part p)
 Grabs the name of a part using its part info. More...
 
static List< VesselSpecificVesselClassAt (CelestialBody body, VesselType vesselType, bool requireOwned=false, bool excludeActive=false, bool useVesselType=true)
 Identifies the vessels at a particular celestial body and collects those of a particular type. More...
 
static List< VesselSpecificVesselClassAt (Vessel.Situations situation, CelestialBody body, VesselType vesselType, bool requireOwned=false, bool excludeActive=false, bool useVesselType=true)
 Identifies the vessels at a particular celestial body and collects those of a particular type. More...
 
static bool VesselAtOrbit (Orbit o, double deviationWindow, Vessel v=null)
 Checks whether a specific vessel is present at or near a specific orbit. More...
 
static double VesselAtOrbitAccuracy (Orbit o, double deviationWindow, Vessel v=null)
 Gets the accuracy whether a specific vessel is present at or near a specific orbit. More...
 
static List< ProtoCrewMemberVesselCrewWithTrait (string trait, Vessel v=null)
 Gets a List of the ProtoCrewMembers on a vessel with a certain experience trait. More...
 
static int VesselCrewWithTraitCount (string trait, Vessel v=null)
 Gets a count of the ProtoCrewMembers on a vessel with a certain experience trait. More...
 
static bool VesselHasAnyModules (List< string > moduleList, Vessel v=null)
 Checks a vessel for many modules at once, to save performance. More...
 
static bool VesselHasAnyParts (List< string > partList, Vessel v=null)
 Checks a vessel for many parts at once, to save performance. More...
 
static bool VesselHasAnyPartsOrModules (List< string > partList, List< string > moduleList, Vessel v=null)
 Checks a vessel for many different things at once, to save performance. More...
 
static bool VesselHasModuleName (string moduleName, Vessel v=null)
 Checks a vessel for a specific module. More...
 
static bool VesselHasPartName (string partName, Vessel v=null)
 Checks a vessel for a specific part. More...
 
static bool VesselHasWheelsOnGround (Vessel v=null, params WheelType[] validWheelTypes)
 Determines whether the vessel is landed with wheels. More...
 
static uint VesselID (Vessel v=null)
 Grabs the flightID of a vessel's root part. More...
 
static bool VesselIsOwned (Vessel v=null)
 Checks if a vessel is "owned" with the discovery system. More...
 
static bool VesselLaunchedAfterID (uint launchID, Vessel v, params string[] ignore)
 Makes sure a vessel was launched after a certain point. More...
 
static int VesselPartAndModuleCount (List< string > partList, List< string > moduleList, Vessel v=null)
 Checks a vessel for many different things at once, to save performance, returns full amount More...
 
static double VesselResourceAmount (string resourceName, Vessel v=null)
 Calculates how much of a particular resource is on a vessel. More...
 

Properties

static int HighestPodCapacity [get]
 Determines the highest pod capacity in the game. More...
 

Member Function Documentation

static bool FinePrint.Utilities.VesselUtilities.ActiveVesselFallback ( ref Vessel  v,
bool  logging = true 
)
inlinestatic

Sets a vessel to the active vessel if it is null and it is possible.

Parameters
vThe vessel.
loggingOptional flag to temporarily disable logging.
Returns
False if it cannot fall back but needs to.
static int FinePrint.Utilities.VesselUtilities.ActualCrewCapacity ( Vessel  v = null)
inlinestatic

Checks a vessel for its actual crew capacity, works for protovessels.

Parameters
vOptional vessel if not ActiveVessel.
Returns
The crew capacity of the vessel.
static Dictionary<Vessel, VesselType> FinePrint.Utilities.VesselUtilities.ClassifyAllVesselsAt ( CelestialBody  body,
bool  useVesselType = true 
)
inlinestatic

Identifies the vessel type of all vessels at a particular celestial body.

Parameters
bodyThe celestial body.
useVesselTypeUse part config vesselType if vessel cannot be classified.
Returns
A dictionary of all vessels at the body and their types.
static VesselType FinePrint.Utilities.VesselUtilities.ClassifyVesselType ( Vessel  v = null,
bool  useVesselType = true 
)
inlinestatic

Classifies the type of a vessel based on its physical characteristics, not an arbitrarily defined type.

Parameters
vOptional vessel if not ActiveVessel.
useVesselTypeUse part config vesselType if vessel cannot be classified.
Returns
A VesselType describing the vessel.
static int FinePrint.Utilities.VesselUtilities.CrewTraitMissionAvailability ( string  trait,
CelestialBody  targetBody = null,
Vessel  excludeVessel = null 
)
inlinestatic

Determines how many kerbals with a particular experience trait are available or already near the area of a mission.

Parameters
traitThe trait name.
targetBodyThe target body of the mission.
excludeVesselA vessel to exclude in the search.
Returns
The amount of crew with that trait that are available for missions.

< Tourists are treated a bit differently, we need to scan active and offered contracts, and look at where they are heading.

< This tourist is heading to where our request is at anyway, and might want to visit our establishment.

< Now for the ones in the wilderness. We want to find ones that are near the target body, but not on excludeVessel.

static void FinePrint.Utilities.VesselUtilities.DiscoverVessel ( Vessel  v = null)
inlinestatic

Marks a vessel as "owned" with the discovery system.

Parameters
vOptional vessel if not ActiveVessel.
static Vector3 FinePrint.Utilities.VesselUtilities.EstimatePartSize ( Part  p)
inlinestatic

Estimates the size of a part, taking SkinnedMeshRenderer oddities into account.

Parameters
pThe part.
Returns
The part size.
static Part FinePrint.Utilities.VesselUtilities.FindFirstPartOrModuleName ( List< string >  partNames,
List< string >  moduleNames 
)
inlinestatic

Does a simple search for the first part that exists in a list of part and module names.

Parameters
partNamesThe list of part names.
moduleNamesThe list of module names.
Returns
The first part found that has a part or module in the lists.
static Vessel FinePrint.Utilities.VesselUtilities.FindVesselWithPartIDs ( List< uint >  partIDs)
inlinestatic

Finds a vessel with the most part IDs from a given list.

Parameters
partIDsA list of part IDs.
Returns
The vessel containing the most of the part IDs.

< By following the largest chunk of a collection of parts, we can follow a vessel even if it blows up into a million pieces.

static Orbit FinePrint.Utilities.VesselUtilities.GenerateAdjustedVesselOrbit ( double  minimumDeviation,
double  modificationLength,
int  numberOfModifications,
System.Random  generator = null,
Vessel  v = null 
)
inlinestatic

Returns a vessel's orbit with a slight modification by a certain percentage.

Parameters
minimumDeviationThe matching deviation of the contract.
modificationLengthThe length of the resulting adjustment after deviation.
numberOfModificationsThe number of properties of the orbit to modify.
generatorAn optional random generator to use.
vOptional vessel if not ActiveVessel.
Returns
A slightly modified orbit.

< Do not attempt to adjust hyperbolic orbits. It ends badly.

< Modifications will be to inclination, argument if eccentric, LAN if inclined, periapsis, and apoapsis.

< LAN changes are not fun at horizontal inclinations.

< And argument changes are not fun in circular orbits.

< We want to modify a few properties (modCount), shuffle and remove all but those.

< If inclination is negative, fix it and flip the LAN.

static FlightBand FinePrint.Utilities.VesselUtilities.GetFlightBand ( double  threshold,
Vessel  v = null 
)
inlinestatic

Gets the flight band of a vessel based on an altitude threshold.

Parameters
thresholdThe border between high and low altitudes.
vOptional vessel if not ActiveVessel.
Returns
The flight band of the vessel.
static List<uint> FinePrint.Utilities.VesselUtilities.GetPartIDList ( Vessel  v = null)
inlinestatic

Gets a list of part IDs for a specific vessel.

Parameters
vOptional vessel if not ActiveVessel.
Returns
A list of part IDs.
static string FinePrint.Utilities.VesselUtilities.GetPartName ( Part  p)
inlinestatic

Grabs the name of a part using its part info.

Parameters
pThe part.
Returns
The part's name.
static List<Vessel> FinePrint.Utilities.VesselUtilities.SpecificVesselClassAt ( CelestialBody  body,
VesselType  vesselType,
bool  requireOwned = false,
bool  excludeActive = false,
bool  useVesselType = true 
)
inlinestatic

Identifies the vessels at a particular celestial body and collects those of a particular type.

Parameters
bodyThe celestial body.
vesselTypeThe vessel classification.
requireOwnedSkip unowned vessels.
excludeActiveSkip active vessels.
useVesselTypeUse part config vesselType if vessel cannot be classified.
Returns
A list of all vessels at the body of that classification.
static List<Vessel> FinePrint.Utilities.VesselUtilities.SpecificVesselClassAt ( Vessel.Situations  situation,
CelestialBody  body,
VesselType  vesselType,
bool  requireOwned = false,
bool  excludeActive = false,
bool  useVesselType = true 
)
inlinestatic

Identifies the vessels at a particular celestial body and collects those of a particular type.

Parameters
situationThe vessel situation.
bodyThe celestial body.
vesselTypeThe vessel classification.
requireOwnedSkip unowned vessels.
excludeActiveSkip active vessels.
useVesselTypeUse part config vesselType if vessel cannot be classified.
Returns
A list of all vessels at the body of that classification.
static bool FinePrint.Utilities.VesselUtilities.VesselAtOrbit ( Orbit  o,
double  deviationWindow,
Vessel  v = null 
)
inlinestatic

Checks whether a specific vessel is present at or near a specific orbit.

Parameters
oThe specific orbit.
deviationWindowThe acceptable margin - percent value 0->100.
vOptional vessel if not ActiveVessel.
Returns
If the vessel is present at the orbit.

< Check periapsis and apoapsis, enforce minimum deviation to prevent low orbits (Molniya) from becoming super hard to match.

< Argdifference was originally argument of periapsis, but on horizontal orbits, use longitude of periapsis instead.

< Only checks argument of periapsis on non-circular orbits.

static double FinePrint.Utilities.VesselUtilities.VesselAtOrbitAccuracy ( Orbit  o,
double  deviationWindow,
Vessel  v = null 
)
inlinestatic

Gets the accuracy whether a specific vessel is present at or near a specific orbit.

Parameters
oThe specific orbit.
accuracyThe accuracy we are expecting as a percentage. eg: 80% - pass in 80
vOptional vessel if not ActiveVessel.
Returns
If the vessel is present at the orbit.
static List<ProtoCrewMember> FinePrint.Utilities.VesselUtilities.VesselCrewWithTrait ( string  trait,
Vessel  v = null 
)
inlinestatic

Gets a List of the ProtoCrewMembers on a vessel with a certain experience trait.

Parameters
traitThe trait name.
vOptional vessel if not ActiveVessel.
Returns
The crew with the trait.
static int FinePrint.Utilities.VesselUtilities.VesselCrewWithTraitCount ( string  trait,
Vessel  v = null 
)
inlinestatic

Gets a count of the ProtoCrewMembers on a vessel with a certain experience trait.

Parameters
traitThe trait name.
vOptional vessel if not ActiveVessel.
Returns
The crew with the trait.
static bool FinePrint.Utilities.VesselUtilities.VesselHasAnyModules ( List< string >  moduleList,
Vessel  v = null 
)
inlinestatic

Checks a vessel for many modules at once, to save performance.

Parameters
moduleListA list of module names.
vOptional vessel if not ActiveVessel.
Returns
If any of the modules are on the ship.
static bool FinePrint.Utilities.VesselUtilities.VesselHasAnyParts ( List< string >  partList,
Vessel  v = null 
)
inlinestatic

Checks a vessel for many parts at once, to save performance.

Parameters
partListA list of part names.
vOptional vessel if not ActiveVessel.
Returns
If any of the parts are on the ship.
static bool FinePrint.Utilities.VesselUtilities.VesselHasAnyPartsOrModules ( List< string >  partList,
List< string >  moduleList,
Vessel  v = null 
)
inlinestatic

Checks a vessel for many different things at once, to save performance.

Parameters
partListA list of part names.
moduleListA list of module names.
vOptional vessel if not ActiveVessel.
Returns
If any of the things are on the vessel.

< Double check all of the parameters, redirect to appropriate methods if something's awry.

< This gets pretty deep, but it's best to do this all in one loop, rather than multiple loops.

static bool FinePrint.Utilities.VesselUtilities.VesselHasModuleName ( string  moduleName,
Vessel  v = null 
)
inlinestatic

Checks a vessel for a specific module.

Parameters
moduleNameName of the module.
vOptional vessel if not ActiveVessel.
Returns
If the vessel has that module.
static bool FinePrint.Utilities.VesselUtilities.VesselHasPartName ( string  partName,
Vessel  v = null 
)
inlinestatic

Checks a vessel for a specific part.

Parameters
partNameName of the part.
vOptional vessel if not ActiveVessel.
Returns
If the vessel has that part.

< Part names cannot have underscores.

static bool FinePrint.Utilities.VesselUtilities.VesselHasWheelsOnGround ( Vessel  v = null,
params WheelType[]  validWheelTypes 
)
inlinestatic

Determines whether the vessel is landed with wheels.

Parameters
vOptional vessel if not ActiveVessel.
validWheelTypesWheel types that are checked.
Returns
If the vessel is landed with wheels.
static uint FinePrint.Utilities.VesselUtilities.VesselID ( Vessel  v = null)
inlinestatic

Grabs the flightID of a vessel's root part.

Parameters
vOptional vessel if not ActiveVessel.
Returns
static bool FinePrint.Utilities.VesselUtilities.VesselIsOwned ( Vessel  v = null)
inlinestatic

Checks if a vessel is "owned" with the discovery system.

Parameters
vOptional vessel if not ActiveVessel.
static bool FinePrint.Utilities.VesselUtilities.VesselLaunchedAfterID ( uint  launchID,
Vessel  v,
params string[]  ignore 
)
inlinestatic

Makes sure a vessel was launched after a certain point.

Parameters
launchIDThe launch ID to compare.
vThe vessel to check.
ignoreOptional part names to ignore in the check.
Returns
If the vessel was launched after the given ID.
static int FinePrint.Utilities.VesselUtilities.VesselPartAndModuleCount ( List< string >  partList,
List< string >  moduleList,
Vessel  v = null 
)
inlinestatic

Checks a vessel for many different things at once, to save performance, returns full amount

Parameters
partListA list of part names.
moduleListA list of module names.
vOptional vessel if not ActiveVessel.
Returns
The full amount of matches.

< This gets pretty deep, but it's best to do this all in one loop, rather than multiple loops.

static double FinePrint.Utilities.VesselUtilities.VesselResourceAmount ( string  resourceName,
Vessel  v = null 
)
inlinestatic

Calculates how much of a particular resource is on a vessel.

Parameters
resourceNameThe name of the resource.
vOptional vessel if not ActiveVessel.
Returns
How much of the resource is on the vessel.

Property Documentation

int FinePrint.Utilities.VesselUtilities.HighestPodCapacity
staticget

Determines the highest pod capacity in the game.

Returns
The highest pod capacity.

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