Difference between revisions of "API:Vessel"

From Kerbal Space Program Wiki
Jump to: navigation, search
(Release of XML code docs authorized by HarvestR.)
m
Line 690: Line 690:
 
}}
 
}}
 
{{MethodsEnd}}
 
{{MethodsEnd}}
 +
[[Category:Community API Documentation]]

Revision as of 03:40, 10 November 2012

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

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 are public properties available in Vessel.

Signature Description
string landedAt { }
Part this { get; }
enum Situations { }
bool isCommandable { }
bool packed { }
bool LandedOrSplashed { get; set; }
ActionGroupList ActionGroups { }
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.
double launchTime { }
bool HoldPhysics { }
PatchedConicSolver patchedConicSolver { get; }
Situations situation { }

Fields

The following is a list of publically-accessible fields in Vessel. This includes protected items, which can be accessed by subclasses.

Signature Description
double verticalSpeed
Vector3 rb_velocity
Quaternion srfRelRotation
double staticPressure
Vector3d acceleration
double geeForce
int currentStage
ProtoVessel protoVessel
Vector3d obt_velocity
Vector3d upAxis
string vesselName
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)
float heightFromTerrain
OrbitDriver orbitDriver
FlightIntegrator flightIntegrator
Vector3 terrainNormal
static float
double pqsAltitude
double terrainAltitude
Vector3 angularVelocity
PatchedConicRenderer patchedConicRenderer
CelestialBody mainBody
bool isPersistent
OrbitTargeter orbitTargeter
float heightFromSurface
bool Landed
bool isEVA
bool HasActiveCrew True if the vessel has at least one crewmember and is active (focused).
Vector3d perturbation
double missionTime
Vector3 CoM
double longitude
Part rootPart
Orbit orbit
bool loaded
uint referenceTransformId
double latitude
bool isActiveVessel
double altitude
State state
enum State
Vector3 localCoM This is used for persistence purposes. Use findLocalCenterOfMass() if you just want the center of mass.
Guid id Unique identifier for each vessel.

Methods

The following are methods included in Vessel.

Signature Description
static string GetMETString()
static string GetSituationString()
Vector3 findWorldCenterOfMass() Finds the world center of mass recursively from the given ship part.
bool checkSplashed()
void GoOffRails() puts the ship back into a simulated orbit and reenables physics
OrbitDriver GetOrbitDriver()
Vector3 GetObtVelocity()
void FallBackReferenceTransform()
void ClearStaging()
void DestroyVesselComponents()
void ResetCollisionIgnores()
Transform GetTransform()
void ChangeWorldVelocity() change the worldspace velocity of this vessel
float GetHeightFromTerrain()
string GetName()
void SpawnCrew()
float GetHeightFromSurface()
ProtoVessel BackupVessel()
void FeedInputFeed()
Vector3 GetSrfVelocity()
void ResumeStaging()
Orbit GetOrbit()
void SetPosition()
void printGroundContacts()
void SetWorldVelocity() set the absolute world velocity of this vessel
void SetRotation() Sets the worldspace rotation of this vessel, and all its parts
void DespawnCrew()
Vector3 findLocalCenterOfMass() Finds the local center of mass recursively from the given ship part.
void OnLoadFlightState()
int GetCrewCount()
void OnDestroy()
void OnSaveFlightState()
ClearToSaveStatus IsClearToSave()
Vector3 GetFwdVector()
void Translate()
Vector3d GetWorldPos3D() Get a double precision vector for the vessel's worldspace position (for when transform.position isn't accurate enough)
Vector3 findLocalCenterOfPressure()
void Unload()
void StartFromBackup() 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.
bool checkVisibility() Returns true if this vessel is within the visible range of any commandable (focusable) vessel, false otherwise.
int GetCrewCapacity()
float GetTotalMass() Get the sum of the mass of all (physical) parts on this vessel
Vessel GetVessel()
void Die()
Vector3 findLocalMOI()
void GoOnRails() disables physics and puts the ship into a propagated orbit
bool checkLanded()
void MakeInactive()
void SetReferenceTransform()
void printCollisions()
void MakeActive()
void Initialize() Initialize is used in cases where the Vessel component is added to a ship that already exists.
void SetPosition(Vector3 position) Sets the worldspace position of this vessel, and all its parts
void Load()