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

Static Public Member Functions

static bool AllPartsFound (ConfigNode root, ref string error)
 Search through all the parts on a vessel to see if they exist More...
 
static void AssembleForLaunch (ShipConstruct ship, string landedAt, string displaylandedAt, string flagURL, Game sceneState, VesselCrewManifest crewManifest)
 Public API static method for constructing a vessel from a shipconstruct. Adds it to FlightGlobals vessel list and sets it to the ActiveVessel. More...
 
static Vector3 CalculateCraftSize (ShipConstruct ship)
 Calculate the bounds of a craft. More...
 
static Vector3 CalculateCraftSize (List< Part > parts, Part rootPart)
 Calculate the bounds of a craft. More...
 
static Vector3 CalculateCraftSize (ShipTemplate ship)
 Calculate the bounds of a craft. More...
 
static void CaptureStockThumbnail (ShipConstruct ship, string craftPath, bool expansion)
 Used to capture Thumbnails for craft inside the Stock Ships or Expansion Folders More...
 
static void CaptureThumbnail (ShipConstruct ship, string baseFolder, string thumbURL)
 Used to capture thumbnails for craft in saves/missions More...
 
static EditorFacility CheckCraftFileType (string filePath)
 
static bool CheckLaunchSiteClear (FlightState flightState, string launchSiteName, bool doCleanup)
 
static bool CheckLaunchSiteClear (FlightState flightState, string launchSiteName, bool doCleanup, out int firstVesselOnPadIndex)
 
static void ClearBackups ()
 
static void CreateBackup (ShipConstruct ship)
 
static void CreateConstructFromTemplate (ShipTemplate template, Callback< ShipConstruct > onComplete)
 
static Texture2D CreateSubassemblyIcon (ShipConstruct sa, int size)
 
static void DebugBackup ()
 
static Vector3 FindCraftCenter (ShipConstruct ship)
 
static Vector3 FindCraftCenter (ShipConstruct ship, bool excludeClamps)
 Find the position of the center oof the Craft More...
 
static Vector3 FindCraftMOI (Part rootPart, Vector3 CoM)
 
static Vector3 FindCraftMOI (Part part, Vector3 CoM, Vector3 MOI)
 
static Part findFirstControlSource (Vessel v)
 
static Part findFirstCrewablePart (Part part)
 
static Part findFirstPod_Placeholder (Part part)
 
static Part FindPartWithCraftID (uint craftID)
 
static List< ProtoVesselFindVesselsAtLaunchSite (FlightState flightState, string launchSiteName)
 
static List< ProtoVesselFindVesselsLandedAt (FlightState flightState, string landedAt)
 Returns a list of all vessels found to be landed at the given spot. More...
 
static void FindVesselsLandedAt (FlightState flightState, string landedAt, out int count, out string name, out int idx, out VesselType vType)
 
static string GetCurrentGameShipsPathFor (EditorFacility facility)
 Returns the fully qualified file system path for the current game, down to the editor subfolder, e.g., "D:/games/KSP/saves/My Game/Ships/VAB/" More...
 
static float GetPartCosts (ProtoPartSnapshot protoPart, AvailablePart aP, out float dryCost, out float fuelCost)
 Returns the value of a protopart, considering the value of resources in it. Does not account for recovery loss and Does not account for any crew inside the protopart. More...
 
static float GetPartCosts (ProtoPartSnapshot protoPart, bool includeModuleCosts, AvailablePart aP, out float dryCost, out float fuelCost)
 Returns the value of a protopart, considering the value of resources in it. Does not account for recovery loss and Does not account for any crew inside the protopart, it checks if it should include module costs. More...
 
static float GetPartCostsAndMass (ConfigNode partNode, AvailablePart aP, out float dryCost, out float fuelCost, out float dryMass, out float fuelMass)
 Returns the value of a part, considering the value of resources in it. Does not account for recovery loss and Does not account for any crew inside the protopart. More...
 
static string GetPlayerCraftThumbnailName (string fullpath, string craftFileName)
 This returns the filename for a craft thumbnail. This is used when saving craft to generate the thumbnail filename, and when loading craft to determine the thumbnail filename to read. More...
 
static string GetPlayerCraftThumbnailName (string gameName, string subDirectoryPath, string shipName)
 This returns the filename for a craft thumbnail. This is used when saving craft to generate the thumbnail filename, and when loading craft to determine the thumbnail filename to read. More...
 
static string GetRootCraftSavePath ()
 Returns the path to the ~/saves directory where the saved games are More...
 
static string GetSavePath (string shipName)
 
static string GetShipsPathFor (string gameName, EditorFacility facility)
 Returns the fully qualified file system path for the provided game name (use HighLogic.GameName for the current game). E.g., "D:/games/KSP/saves/My game/Ships/VAB/" Omitting the second argument will provide the game's root directory. E.g., "D:/games/KSP/saves/My game/" More...
 
static string GetShipsPathFor (string gameName)
 Returns the fully qualified file system path for the provided game name (use HighLogic.SaveFolder for the current game). E.g., "D:/games/KSP/saves/My game/Ships/VAB/" Omitting the second argument will provide the game's root directory. E.g., "D:/games/KSP/saves/My game/" More...
 
static string GetShipsSubfolderFor (EditorFacility facility)
 Returns the editor subfolder for the provided facility. E.g., "VAB" or "SPH" Does not return a full path. More...
 
static Texture2D GetThumbnail (string thumbURL)
 
static uint GetUniqueFlightID (FlightState flightState)
 
static bool IsCompatible (ConfigNode root, ref string error)
 Check to see if a craft has the correct version to be loaded by this copy of KSP More...
 
static ShipConstruct LoadShip (string filePath)
 
static ShipConstruct LoadShip ()
 
static ShipConstruct LoadSubassembly (string shipFilename)
 
static ShipTemplate LoadTemplate (string shipFilename)
 
static void PutShipToGround (ShipConstruct ship, Transform spawnPoint)
 
static void RecoverVesselFromFlight (ProtoVessel vessel, FlightState fromState)
 Recover a vessel from flight, returning its crew to available state. More...
 
static void RecoverVesselFromFlight (ProtoVessel vessel, FlightState fromState, bool quick)
 Recover a vessel from flight, returning its crew to available state. More...
 
static ShipConstruct RestoreBackup (int index)
 
static void SanitizeCraftIDs (List< Part > parts, bool preserveIDsOnGivenParts)
 
static void SanitizePartCosts (AvailablePart aP, ConfigNode partNode)
 make sure the cost of the part isn't less than the sum of the cost of its resources More...
 
static string SaveShip (ShipConstruct ship, string shipFilename)
 
static string SaveShip (string shipFilename)
 
static string SaveShipToPath (string shipName, string path)
 Saves the craft with the provided name, in the provided location. More...
 
static string SaveShipToPath (string gameFolder, EditorFacility editorFacility, string localPath, string shipName)
 Saves the craft in the provided game directory, under the provided facility, in the provided path, with the provided name. More...
 
static string SaveSubassembly (ShipConstruct ship, string shipFilename)
 
static void ShiftAndCreateBackup (ShipConstruct ship)
 
static bool SubassemblyExists (string shipFilename)
 

Static Public Attributes

static List< ConfigNodebackups = new List<ConfigNode>()
 
static ConfigNode ShipConfig
 
static VesselCrewManifest ShipManifest
 
static EditorFacility ShipType
 

Member Function Documentation

static bool ShipConstruction.AllPartsFound ( ConfigNode  root,
ref string  error 
)
inlinestatic

Search through all the parts on a vessel to see if they exist

Parameters
rootConfig node containing the details of the ship
errorReturns a string containing a list of all the errors
Returns
true if the parts exists in the database, false if none found
static void ShipConstruction.AssembleForLaunch ( ShipConstruct  ship,
string  landedAt,
string  displaylandedAt,
string  flagURL,
Game  sceneState,
VesselCrewManifest  crewManifest 
)
inlinestatic

Public API static method for constructing a vessel from a shipconstruct. Adds it to FlightGlobals vessel list and sets it to the ActiveVessel.

Parameters
shipthe ShipConstruct
landedAtstring for where the vessel is landed - in English
displaylandedAtstring for where the vessel is landed - Localized
flagURLthe flag URL for the vessel
sceneStatethe Game we are adding the vessel to
crewManifestthe vessels crew manfest
static Vector3 ShipConstruction.CalculateCraftSize ( ShipConstruct  ship)
inlinestatic

Calculate the bounds of a craft.

Parameters
shipShip to calculate the bounds for
static Vector3 ShipConstruction.CalculateCraftSize ( List< Part parts,
Part  rootPart 
)
inlinestatic

Calculate the bounds of a craft.

Parameters
partsList of all the parts in the craft
rootPartRoot part of the craft
static Vector3 ShipConstruction.CalculateCraftSize ( ShipTemplate  ship)
inlinestatic

Calculate the bounds of a craft.

Parameters
shipShip to calculate the bounds for
static void ShipConstruction.CaptureStockThumbnail ( ShipConstruct  ship,
string  craftPath,
bool  expansion 
)
inlinestatic

Used to capture Thumbnails for craft inside the Stock Ships or Expansion Folders

Parameters
shipThe ship
craftPathFull path of the ship/file
expansionTrue if its an expansion ship
static void ShipConstruction.CaptureThumbnail ( ShipConstruct  ship,
string  baseFolder,
string  thumbURL 
)
inlinestatic

Used to capture thumbnails for craft in saves/missions

Parameters
ship
baseFolder
thumbURL
static EditorFacility ShipConstruction.CheckCraftFileType ( string  filePath)
inlinestatic
static bool ShipConstruction.CheckLaunchSiteClear ( FlightState  flightState,
string  launchSiteName,
bool  doCleanup 
)
inlinestatic
static bool ShipConstruction.CheckLaunchSiteClear ( FlightState  flightState,
string  launchSiteName,
bool  doCleanup,
out int  firstVesselOnPadIndex 
)
inlinestatic
static void ShipConstruction.ClearBackups ( )
inlinestatic
static void ShipConstruction.CreateBackup ( ShipConstruct  ship)
inlinestatic
static void ShipConstruction.CreateConstructFromTemplate ( ShipTemplate  template,
Callback< ShipConstruct onComplete 
)
inlinestatic
static Texture2D ShipConstruction.CreateSubassemblyIcon ( ShipConstruct  sa,
int  size 
)
inlinestatic
static void ShipConstruction.DebugBackup ( )
inlinestatic
static Vector3 ShipConstruction.FindCraftCenter ( ShipConstruct  ship)
inlinestatic
static Vector3 ShipConstruction.FindCraftCenter ( ShipConstruct  ship,
bool  excludeClamps 
)
inlinestatic

Find the position of the center oof the Craft

Parameters
shipShip
excludeClampsTrue to not include LaunchClamps in the calculation
Returns
static Vector3 ShipConstruction.FindCraftMOI ( Part  rootPart,
Vector3  CoM 
)
inlinestatic
static Vector3 ShipConstruction.FindCraftMOI ( Part  part,
Vector3  CoM,
Vector3  MOI 
)
inlinestatic
static Part ShipConstruction.findFirstControlSource ( Vessel  v)
inlinestatic
static Part ShipConstruction.findFirstCrewablePart ( Part  part)
inlinestatic
static Part ShipConstruction.findFirstPod_Placeholder ( Part  part)
inlinestatic
static Part ShipConstruction.FindPartWithCraftID ( uint  craftID)
inlinestatic
static List<ProtoVessel> ShipConstruction.FindVesselsAtLaunchSite ( FlightState  flightState,
string  launchSiteName 
)
inlinestatic
static List<ProtoVessel> ShipConstruction.FindVesselsLandedAt ( FlightState  flightState,
string  landedAt 
)
inlinestatic

Returns a list of all vessels found to be landed at the given spot.

static void ShipConstruction.FindVesselsLandedAt ( FlightState  flightState,
string  landedAt,
out int  count,
out string  name,
out int  idx,
out VesselType  vType 
)
inlinestatic
static string ShipConstruction.GetCurrentGameShipsPathFor ( EditorFacility  facility)
inlinestatic

Returns the fully qualified file system path for the current game, down to the editor subfolder, e.g., "D:/games/KSP/saves/My Game/Ships/VAB/"

static float ShipConstruction.GetPartCosts ( ProtoPartSnapshot  protoPart,
AvailablePart  aP,
out float  dryCost,
out float  fuelCost 
)
inlinestatic

Returns the value of a protopart, considering the value of resources in it. Does not account for recovery loss and Does not account for any crew inside the protopart.

Parameters
protoPartThe protoPart
aPThe PartInfo
dryCostCost of the part without resources
fuelCostCost of the Resources
Returns
The cost of the part including the module costs
static float ShipConstruction.GetPartCosts ( ProtoPartSnapshot  protoPart,
bool  includeModuleCosts,
AvailablePart  aP,
out float  dryCost,
out float  fuelCost 
)
inlinestatic

Returns the value of a protopart, considering the value of resources in it. Does not account for recovery loss and Does not account for any crew inside the protopart, it checks if it should include module costs.

Parameters
protoPartThe protoPart
includeModuleCostsShould the calculation include the module cost variables
aPThe PartInfo
dryCostCost of the part without resources
fuelCostCost of the Resources
Returns
The cost of the part
static float ShipConstruction.GetPartCostsAndMass ( ConfigNode  partNode,
AvailablePart  aP,
out float  dryCost,
out float  fuelCost,
out float  dryMass,
out float  fuelMass 
)
inlinestatic

Returns the value of a part, considering the value of resources in it. Does not account for recovery loss and Does not account for any crew inside the protopart.

Parameters
partNode
aP
dryCost
fuelCost
dryMass
fuelMass
Returns
static string ShipConstruction.GetPlayerCraftThumbnailName ( string  fullpath,
string  craftFileName 
)
inlinestatic

This returns the filename for a craft thumbnail. This is used when saving craft to generate the thumbnail filename, and when loading craft to determine the thumbnail filename to read.

Thumbnail naming pattern: {game name}_{editor type}_{sanitized path}_{shipname}.png Where {sanitized path} is the sub-directory path. Diretory separators are replaced with underscore (_). Path starts with the first directory under the editor directory. For example, Using this path: D: first game stage rockets packages Using this ship name: Science Mission 1 Produces this thumbnail name: "my first game_VAB_one stage rockets_science packages_Science Mission 1.png"

Parameters
fullpathThe fully qualified path to the file. Does not include filename.
craftFileNameThe name of the craft. Does not include file exension.
static string ShipConstruction.GetPlayerCraftThumbnailName ( string  gameName,
string  subDirectoryPath,
string  shipName 
)
inlinestatic

This returns the filename for a craft thumbnail. This is used when saving craft to generate the thumbnail filename, and when loading craft to determine the thumbnail filename to read.

Thumbnail naming pattern: {game name}_{editor type}_{sanitized path}_{shipname}.png Where {sanitized path} is the sub-directory path. Diretory separators are replaced with underscore (_). Path starts with the first directory under the editor directory. For example, Using this path: D: first game stage rockets packages Using this ship name: Science Mission 1 Produces this thumbnail name: "my first game_VAB_one stage rockets_science packages_Science Mission 1.png"

Parameters
gameNamethe folder name of the game directory, e.g., "my game"
subDirectoryPaththe user-created directory tree (starting with the editor) where the craft resides, e.g., "/VAB/rockets/single stage"
shipNamethe craft name, e.g., "Saturn 5"
static string ShipConstruction.GetRootCraftSavePath ( )
inlinestatic

Returns the path to the ~/saves directory where the saved games are

Returns
static string ShipConstruction.GetSavePath ( string  shipName)
inlinestatic
static string ShipConstruction.GetShipsPathFor ( string  gameName,
EditorFacility  facility 
)
inlinestatic

Returns the fully qualified file system path for the provided game name (use HighLogic.GameName for the current game). E.g., "D:/games/KSP/saves/My game/Ships/VAB/" Omitting the second argument will provide the game's root directory. E.g., "D:/games/KSP/saves/My game/"

static string ShipConstruction.GetShipsPathFor ( string  gameName)
inlinestatic

Returns the fully qualified file system path for the provided game name (use HighLogic.SaveFolder for the current game). E.g., "D:/games/KSP/saves/My game/Ships/VAB/" Omitting the second argument will provide the game's root directory. E.g., "D:/games/KSP/saves/My game/"

static string ShipConstruction.GetShipsSubfolderFor ( EditorFacility  facility)
inlinestatic

Returns the editor subfolder for the provided facility. E.g., "VAB" or "SPH" Does not return a full path.

static Texture2D ShipConstruction.GetThumbnail ( string  thumbURL)
inlinestatic
static uint ShipConstruction.GetUniqueFlightID ( FlightState  flightState)
inlinestatic
static bool ShipConstruction.IsCompatible ( ConfigNode  root,
ref string  error 
)
inlinestatic

Check to see if a craft has the correct version to be loaded by this copy of KSP

Parameters
rootConfig node containing the details of the ship
errorReturns a string containing a list of all the errors
Returns
true if the version is compatible, false if not
static ShipConstruct ShipConstruction.LoadShip ( string  filePath)
inlinestatic
static ShipConstruct ShipConstruction.LoadShip ( )
inlinestatic
static ShipConstruct ShipConstruction.LoadSubassembly ( string  shipFilename)
inlinestatic
static ShipTemplate ShipConstruction.LoadTemplate ( string  shipFilename)
inlinestatic
static void ShipConstruction.PutShipToGround ( ShipConstruct  ship,
Transform  spawnPoint 
)
inlinestatic
static void ShipConstruction.RecoverVesselFromFlight ( ProtoVessel  vessel,
FlightState  fromState 
)
inlinestatic

Recover a vessel from flight, returning its crew to available state.

Parameters
vesselThe vessel to recover
fromStateThe flightstate
static void ShipConstruction.RecoverVesselFromFlight ( ProtoVessel  vessel,
FlightState  fromState,
bool  quick 
)
inlinestatic

Recover a vessel from flight, returning its crew to available state.

Parameters
vesselThe vessel to recover
fromStateThe flightstate
quickIf true, recovery dialog is skipped.
static ShipConstruct ShipConstruction.RestoreBackup ( int  index)
inlinestatic
static void ShipConstruction.SanitizeCraftIDs ( List< Part parts,
bool  preserveIDsOnGivenParts 
)
inlinestatic

< make sure all craft IDs are unique

static void ShipConstruction.SanitizePartCosts ( AvailablePart  aP,
ConfigNode  partNode 
)
inlinestatic

make sure the cost of the part isn't less than the sum of the cost of its resources

Parameters
aP
partNode
static string ShipConstruction.SaveShip ( ShipConstruct  ship,
string  shipFilename 
)
inlinestatic

< save craft picture in /thumbs

static string ShipConstruction.SaveShip ( string  shipFilename)
inlinestatic

< save craft picture in /thumbs

static string ShipConstruction.SaveShipToPath ( string  shipName,
string  path 
)
inlinestatic

Saves the craft with the provided name, in the provided location.

static string ShipConstruction.SaveShipToPath ( string  gameFolder,
EditorFacility  editorFacility,
string  localPath,
string  shipName 
)
inlinestatic

Saves the craft in the provided game directory, under the provided facility, in the provided path, with the provided name.

Parameters
gameFolderthe name of the game-save folder, e.g., "my game"
editorFacilitythe editor that was used to create the craft, e.g., VAB or SPH
localPaththe player-created subfolders, e.g., "rockets/single stage"
shipNamethe craft name, e.g., "Saturn 5"
Returns
The fully qualified path down to the ship name, e.g., "D:/games/KSP/saves/my game/ships/VAB/rockets/single stage"
static string ShipConstruction.SaveSubassembly ( ShipConstruct  ship,
string  shipFilename 
)
inlinestatic
static void ShipConstruction.ShiftAndCreateBackup ( ShipConstruct  ship)
inlinestatic
static bool ShipConstruction.SubassemblyExists ( string  shipFilename)
inlinestatic

Member Data Documentation

List<ConfigNode> ShipConstruction.backups = new List<ConfigNode>()
static
ConfigNode ShipConstruction.ShipConfig
static
VesselCrewManifest ShipConstruction.ShipManifest
static
EditorFacility ShipConstruction.ShipType
static

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