API:Vessel

From Kerbal Space Program Wiki
Jump to: navigation, search

A Vessel represents a ship, or a piece of debris that was once part of a ship. You can access the vessel that your Part is part of with this.vessel. Particularly useful members are vessel.orbit, which gives your orbit, and vessel.mainBody, which gives CelestialBody whose influence you are currently under.

Vessel Class

Inherits Implements
MonoBehaviour
  • IShipconstruct
  • ITargetable
  • IDiscoverable

Vessels define individual ships in flight. They work essentially as a header for the set of parts that make up the ship.

Properties

The following is a list of properties in Vessel.

Name Description
ActionGroupList ActionGroups { get; }  ?
VesselAutopilot Autopilot { get; }  ?
Vector3 CurrentCoM { get; }  ?
DiscoveryInfo DiscoveryInfo { get; }  ?
float distanceLandedPackThreshold { get; set; }  ? Has attribute [Obsolete("Use Vessel.vesselRanges instead")]
float distanceLandedUnpackThreshold { get; set; }  ? Has attribute [Obsolete("Use Vessel.vesselRanges instead")]
float distancePackThreshold { get; set; }  ? Has attribute [Obsolete("Use Vessel.vesselRanges instead")]
float distanceUnpackThreshold { get; set; }  ? Has attribute [Obsolete("Use Vessel.vesselRanges instead")]
bool HoldPhysics { get; }  ?
bool isActiveVessel { get; } Returns true if this is the vessel that is currently being controled by the player.
bool isCommandable { get; }  ?
bool IsControllable { get; }  ?
bool isEVA { get; } True if the vessel is an EVA kerbal.
bool isPersistent { get; set; }  ?
bool IsRecoverable { get; } Returns true if this vessel is recoverable (ex. is splashed down or landed on Kerbin and is not moving).
bool LandedOrSplashed { get; } Returns true if the vessel is splashed down or landed.
CelestialBody mainBody { get; }  ?
Orbit orbit { get; }  ?
List〈Part〉 Parts { get; }  ?
bool PatchedConicsAttached { get; }  ?
Transform ReferenceTransform { get; } The reference transform is used to define the orientation of a vessel for controls and gauges. It defines which way is 'up' or 'forward' or which way pitch rotates, for instance. Read only. Use SetReferenceTransform to set. Defaults to vessel transform if no other transform is set.
VesselValues VesselValues { get; }  ?
static float loadDistance { get; set; }  ? Has attribute [Obsolete("Use Vessel.vesselRanges instead")]
static float unloadDistance { get; set; }  ? Has attribute [Obsolete("Use Vessel.vesselRanges instead")]

Fields

The following is a list of fields in Vessel.

Signature Description
Vector3d acceleration The current acceleration vector of the vessel.
double altitude Height above the surface of the reference body, including liquid bodies.
Vector3 angularMomentum  ?
Vector3 angularVelocity The angular velocity vector of the vessel.
double atmDensity  ?
double atmosphericTemperature  ?
Vector3d CentrifugalAcc  ?
Vector3 CoM The vector corresponding to the vessel's center of mass, relative to the vessel origin.
double convectiveCoefficient  ?
double convectiveMachFlux  ?
Vector3d CoriolisAcc  ?
FlightCtrlState ctrlState The vessel's flight control state object, used for accessing and modifying user and fly-by-wire input.
int currentStage Current stage of the vessel.
bool directSunlight  ?
double distanceToSun  ?
double dynamicPressurekPa  ?
KerbalEVA evaController  ?
double externalTemperature  ?
ConfigNode flightPlanNode  ?
double geeForce The current magnitude of gravity, in meters per second squared. (Is this right? geeForce is not gravity)
double geeForce_immediate  ?
Vector3d gForce  ?
bool handlePhysicsStats  ?
float heightFromSurface The height above the surface of the reference body, including liquid bodies.
float heightFromTerrain  ?
double horizontalSrfSpeed  ?
Guid id Unique identifier for each vessel.
double indicatedAirSpeed  ?
bool Landed True if the vessel has landed.
string landedAt  ?
double latitude  ?
double launchTime  ?
bool loaded True if the vessel has loaded.
Vector3 localCoM This is used for persistence purposes. Use findLocalCenterOfMass() if you just want the center of mass.
double longitude  ?
double mach  ?
double missionTime  ?
Vector3 MOI  ?
double obt_speed  ?
Vector3d obt_velocity The orbital velocity vector of the vessel, relative to the reference body.
FlightInputCallback OnAutopilotUpdate  ?
FlightInputCallback OnFlyByWire  ?
Callback OnJustAboutToBeDestroyed  ?
FlightInputCallback OnPostAutopilotUpdate  ?
FlightInputCallback OnPreAutopilotUpdate  ?
OrbitDriver orbitDriver  ?
OrbitRenderer orbitRenderer  ?
OrbitTargeter orbitTargeter  ?
bool packed  ?
List〈Part〉 parts  ?
PatchedConicRenderer patchedConicRenderer  ?
PatchedConicSolver patchedConicSolver  ?
Vector3d perturbation  ?
double pqsAltitude  ?
ProtoVessel protoVessel  ?
Vector3 rb_velocity The current velocity of the Unity physics rigidbody.
uint referenceTransformId  ?
Part rootPart The root part of the vessel.
Situations situation  ?
double solarFlux  ?
double specificAcceleration Specific acceleration is the vessel's potential acceleration per unit of throttle. Used to estimate burn times and such. NOTE: this value is calculated based on smoothed acceleration, so it isn't completely accurate. It will also change as the vessel's mass is reduced as fuel burns away. (it does get pretty accurate after burning for a few seconds)
double speed  ?
double speedOfSound  ?
bool Splashed  ?
Vector3d srf_velocity The velocity vector of the vessel while in the atmosphere. (Prograde)
Quaternion srfRelRotation The Quaternion corresponding to the vessel's rotation, relative to the surface of reference body.
double srfSpeed  ?
State state  ?
double staticPressurekPa The current atmospheric pressure of this vessel.
ITargetable targetObject  ?
double terrainAltitude The height of the terrain, relative to the center of the reference body.
Vector3 terrainNormal The vector perpendicular to the terrain.
Vector3d upAxis Vector corresponding to the vessel's up facing direction.
double verticalSpeed The vertical speed of the vessel, relative to the surface of the reference body.
string vesselName Name identifier of the vessel.
VesselRanges vesselRanges  ?
Transform vesselTransform  ?
VesselType vesselType  ?

Methods

The following are methods included in Vessel.

Signature Description
constructor Vessel()  ?
void AttachPatchedConicsSolver()  ?
ProtoVessel BackupVessel()  ?
void CalculatePhysicsStats()  ?
void ChangeWorldVelocity(Vector3d velOffset) change the worldspace velocity of this vessel
bool checkLanded()  ?
bool checkSplashed()  ?
bool checkVisibility() Returns true if this vessel is within the visible range of any commandable (focusable) vessel, false otherwise.
void ClearStaging()  ?
bool ContainsCollider(Collider c)  ?
void DespawnCrew()  ?
void DestroyVesselComponents()  ?
void DetachPatchedConicsSolver()  ?
void Die()  ?
void FallBackReferenceTransform()  ?
void FeedInputFeed()  ?
VesselType FindDefaultVesselType()  ?
Vector3 findLocalCenterOfMass() Finds the local center of mass recursively from the given ship part.
Vector3 findLocalCenterOfPressure()  ?
Vector3 findLocalMOI()  ?
Vector3 findLocalMOI(Vector3 worldCoM)  ?
List〈T〉 FindPartModulesImplementing〈T〉()  ?
Vector3 findWorldCenterOfMass() Finds the world center of mass recursively from the given ship part.
List〈Part〉 GetActiveParts()  ?
ActiveResource GetActiveResource(PartResourceDefinition def)  ?
List〈ActiveResource〉 GetActiveResources()  ?
int GetCrewCapacity()  ?
int GetCrewCount()  ?
Vector3 GetFwdVector()  ?
float GetHeightFromSurface()  ?
float GetHeightFromTerrain() The vessel's altitude above the reference body's terrain, not including liquid bodies.
string GetName()  ?
Vector3 GetObtVelocity()  ?
Orbit GetOrbit()  ?
OrbitDriver GetOrbitDriver()  ?
Part GetReferenceTransformPart()  ?
Vector3 GetSrfVelocity()  ?
VesselTargetModes GetTargetingMode()  ?
float GetTotalMass() Get the sum of the mass of all (physical) parts on this vessel
Transform GetTransform()  ?
Vessel GetVessel()  ?
List〈ProtoCrewMember〉 GetVesselCrew() Returns a list of ProtoCrewMembers corresponding to each kerbal on board. ProtoCrewMember contains many fields relating to the kerbals stats such as name, courage, etc.
Vector3d GetWorldPos3D() Get a double precision vector for the vessel's worldspace position (for when transform.position isn't accurate enough)
void GoOffRails() puts the ship back into a simulated orbit and reenables physics
void GoOnRails() disables physics and puts the ship into a propagated orbit
bool HasControlSources()  ?
bool Initialize(bool fromShipAssembly) Initialize is used in cases where the Vessel component is added to a ship that already exists.
ClearToSaveStatus IsClearToSave()  ?
void Load()  ? Has attribute [ContextMenu("Load")]
void MakeActive()  ?
void MakeInactive()  ?
void MurderCrew()  ?
void OnDestroy()  ?
void OnLoadFlightState(Dictionary〈string, KSPParseable〉 dataPool)  ?
void OnSaveFlightState(Dictionary〈string, KSPParseable〉 dataPool)  ?
double PQSAltitude()  ?
void printCollisions()  ? Has attribute [ContextMenu("Print All Collisions")]
void printGroundContacts()  ? Has attribute [ContextMenu("Print Ground Contacts")]
void RenameVessel()  ? Has attribute [ContextMenu("Rename Vessel")]
void ResetCollisionIgnores()  ? Has attribute [ContextMenu("Reset Collision Ignores")]
void ResumeStaging()  ?
void ResumeTarget()  ?
double RevealAltitude()  ?
float RevealMass()  ?
string RevealName()  ?
string RevealSituationString()  ?
double RevealSpeed()  ?
string RevealType()  ?
void SetActiveInternalPart()  ?
void SetActiveInternalPart(List〈Part〉 visibleParts)  ?
void SetActiveInternalPart(Part visiblePart)  ?
void SetPosition(Vector3 position) Sets the worldspace position of this vessel, and all its parts
void SetPosition(Vector3 position,bool usePristineCoords)  ?
void SetReferenceTransform(Part p)  ?
void SetRotation(Quaternion rotation) Sets the worldspace rotation of this vessel, and all its parts
void SetWorldVelocity(Vector3d vel) set the absolute world velocity of this vessel
void SpawnCrew()  ?
void StartFromBackup(ProtoVessel pv) Start from backup is used when the scene is being resumed, and the Vessel component is added before the parts themselves. Note that this method won't load the parts. It only creates the vessel object. To load parts, use the Vessel.Load() method.
void Translate(Vector3 offset)  ?
void Unload()  ? Has attribute [ContextMenu("Unload")]
static string AutoRename(Vessel v,string baseName)  ?
static string GetLandedAtString(string landedAt)  ?
static string GetMETString(Vessel v)  ?
static string GetSituationString(Vessel v)  ?
static bool IsValidVesselName(string name)  ?

Enumerations

The following is a list of enumerations in Vessel.

Name Values
Situations LANDED
SPLASHED
PRELAUNCH
FLYING
SUB_ORBITAL
ORBITING
ESCAPING
DOCKED
State INACTIVE
ACTIVE
DEAD

Other API

Vessel also contains the following, not included above.

...
public Part this[int index] { get; }
public Part this[uint flightID] { get; }
 
public class ActiveResource
{
  public double amount;
  public PartResourceDefinition info;
  public double maxAmount;
  public List<Part> parts;
 
  public ActiveResource(PartResourceDefinition def);
}
...