Difference between revisions of "API:Vessel"
From Kerbal Space Program Wiki
(Created page with "Category:Community API Documentation") |
|||
Line 1: | Line 1: | ||
+ | A Vessel represents a ship, or a piece of debris that was once part of a ship. | ||
+ | |||
+ | == Useful members == | ||
+ | |||
+ | <table border="1"> | ||
+ | <tr> | ||
+ | <td><code>void ChangeWorldVelocity(Vector3d velOffset)</code></td> | ||
+ | <td>Adds velOffset to the vessel's velocity. This seems to happen instantaneously and without imposing any stresses on the ship. You can use this to simulate some sort of force, like gravity, that accelerates the vessel as a whole.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>Vector3 findWorldCenterOfMass()</code></td> | ||
+ | <td>Returns the center of mass of the ship, in world coordinates</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>void SetWorldVelocity(Vector3d vel)</code></td> | ||
+ | <td>Sets the velocity of the vessel to the supplied velocity vector. This seems to happen instantaneously and without imposing any stresses on the ship.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>bool isActiveVessel { get; }</code></td> | ||
+ | <td>Whether this vessel is the one the player is currently controlling. This is often useful to know, as your code will run even on non-active ships when they are within a few km of the active vessel. You can enclose your code in if(this.vessel.isActiveVessel) {} if you only want to do stuff when your plugin part is on the active ship.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>bool isCommandable { get; }</code></td> | ||
+ | <td>Whether the vessel is commandable or debris. Commandable vessels can be selected from the tracking station and show up on the map with little command pod symbols. Non-commandable vessels can't and show up with debris symbols.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>CelestialBody mainBody { get; }</code></td> | ||
+ | <td>The celestial body whose sphere of influence the vessel is currently inside. You will probably use this a lot.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>bool Landed</code></td> | ||
+ | <td>Whether the vessel is currently landed on solid ground.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>Orbit orbit</code></td> | ||
+ | <td>The Orbit object storing all the information about the vessel's orbit. You can get the vessel's current velocity with vessel.orbit.GetVel()</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>List<Part> parts</code></td> | ||
+ | <td>A list of the parts in the ship.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>ProtoVessel protoVessel</code></td> | ||
+ | <td>Some sort of data structure that stores saved information about the vessel. It can be useful for getting data about parts in vessels that are on rails, when vessel.parts is empty. ProtoVessel.protoPartSnapshots is a List<ProtoPartSnapshot>, with one ProtoPartSnapshot for each part in the vessel. ProtoPartSnapshot.partStateValues is a Dictionary<string, KSPParseable>, which you can store data into by overriding Part.onFlightStateSave(). This data is then accessible even if the vessel that stored the data is on rails.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>Part rootPart</code></td> | ||
+ | <td>The part at the root of the vessel's part tree, i.e., the command pod.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>bool Splashed</code></td> | ||
+ | <td>Whether the vessel is currently splashed down in the ocean.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td><code>string vesselName</code></td> | ||
+ | <td>The name of the vessel that appears e.g. when you mouse over it on the orbital map.</td> | ||
+ | </table> | ||
+ | |||
[[Category:Community API Documentation]] | [[Category:Community API Documentation]] |
Revision as of 21:38, 11 May 2012
A Vessel represents a ship, or a piece of debris that was once part of a ship.
Useful members
void ChangeWorldVelocity(Vector3d velOffset) |
Adds velOffset to the vessel's velocity. This seems to happen instantaneously and without imposing any stresses on the ship. You can use this to simulate some sort of force, like gravity, that accelerates the vessel as a whole. |
Vector3 findWorldCenterOfMass() |
Returns the center of mass of the ship, in world coordinates |
void SetWorldVelocity(Vector3d vel) |
Sets the velocity of the vessel to the supplied velocity vector. This seems to happen instantaneously and without imposing any stresses on the ship. |
bool isActiveVessel { get; } |
Whether this vessel is the one the player is currently controlling. This is often useful to know, as your code will run even on non-active ships when they are within a few km of the active vessel. You can enclose your code in if(this.vessel.isActiveVessel) {} if you only want to do stuff when your plugin part is on the active ship. |
bool isCommandable { get; } |
Whether the vessel is commandable or debris. Commandable vessels can be selected from the tracking station and show up on the map with little command pod symbols. Non-commandable vessels can't and show up with debris symbols. |
CelestialBody mainBody { get; } |
The celestial body whose sphere of influence the vessel is currently inside. You will probably use this a lot. |
bool Landed |
Whether the vessel is currently landed on solid ground. |
Orbit orbit |
The Orbit object storing all the information about the vessel's orbit. You can get the vessel's current velocity with vessel.orbit.GetVel() |
List<Part> parts |
A list of the parts in the ship. |
ProtoVessel protoVessel |
Some sort of data structure that stores saved information about the vessel. It can be useful for getting data about parts in vessels that are on rails, when vessel.parts is empty. ProtoVessel.protoPartSnapshots is a List<ProtoPartSnapshot>, with one ProtoPartSnapshot for each part in the vessel. ProtoPartSnapshot.partStateValues is a Dictionary<string, KSPParseable>, which you can store data into by overriding Part.onFlightStateSave(). This data is then accessible even if the vessel that stored the data is on rails. |
Part rootPart |
The part at the root of the vessel's part tree, i.e., the command pod. |
bool Splashed |
Whether the vessel is currently splashed down in the ocean. |
string vesselName |
The name of the vessel that appears e.g. when you mouse over it on the orbital map. |