Extending PartModule lets you add new functionality to parts. The main class of many plugins will be a subclass of PartModule. See this forum thread for the official instructions on using PartModule:
More...
|
| PartModule () |
|
virtual string | GetInfo () |
| The return value of this function appears in the part's description in the editor. More...
|
|
void | Load (ConfigNode node) |
|
virtual void | OnActive () |
| This function is called once when the part gets activated. More...
|
|
virtual void | OnAwake () |
| This function gets called only once, during the KSP loading screen. See the Unity documentation on Awake for more information. More...
|
|
virtual void | OnFixedUpdate () |
| This function gets called once every Unity FixedUpdate cycle (once per physics frame) once the part has been activated. If you want to be called even if the part has not been activated, define a function called void FixedUpdate() instead of overriding OnFixedUpdate More...
|
|
virtual void | OnInactive () |
| When does this get called? More...
|
|
virtual void | OnLoad (ConfigNode node) |
| This function is called to initialize the part. The ConfigNode contains the parameters of the module as specified in the part.cfg file, or as you last saved them in OnSave. More...
|
|
virtual void | OnSave (ConfigNode node) |
| This function is called when the game is saved to let the part save persistent data. Add any data you want to persist to the ConfigNode. The ConfigNode will then be saved as part of persistent.sfs. When the game is resumed, you can then read this data back out in OnLoad. More...
|
|
virtual void | OnStart (PartModule.StartState state) |
| Called when the flight starts, or when the part is created in the editor. OnStart will be called before OnUpdate or OnFixedUpdate are ever called. More...
|
|
virtual void | OnUpdate () |
| Called once per Unity Update cycle once the part has been activated. If you want to be called even if the part has not been activated, define a function called void Update() instead of overriding OnFixedUpdate. More...
|
|
void | Save (ConfigNode node) |
|
Extending PartModule lets you add new functionality to parts. The main class of many plugins will be a subclass of PartModule. See this forum thread for the official instructions on using PartModule:
http://forum.kerbalspaceprogram.com/showthread.php/10296-0-15-code-update-PartModule-KSPField-KSPEvent-ConfigNode-and-PartResource
A StartState is passed on OnStart in order to provide the PartModule with some information about where it is starting up.
Enumerator |
---|
None |
|
Editor |
|
PreLaunch |
|
Landed |
|
Docked |
|
Flying |
|
Splashed |
|
SubOrbital |
|
Orbital |
|
PartModule.PartModule |
( |
| ) |
|
virtual string PartModule.GetInfo |
( |
| ) |
|
|
virtual |
The return value of this function appears in the part's description in the editor.
- Returns
- Editor info for the part
Reimplemented in ModuleEngines.
virtual void PartModule.OnActive |
( |
| ) |
|
|
virtual |
virtual void PartModule.OnAwake |
( |
| ) |
|
|
virtual |
virtual void PartModule.OnFixedUpdate |
( |
| ) |
|
|
virtual |
This function gets called once every Unity FixedUpdate cycle (once per physics frame) once the part has been activated. If you want to be called even if the part has not been activated, define a function called void FixedUpdate()
instead of overriding OnFixedUpdate
See the Unity documentation on FixedUpdate for more information. You can get the time between FixedUpdates from TimeWarp.fixedDeltaTime. Do any physics stuff in OnFixedUpdate, not OnUpdate.
virtual void PartModule.OnInactive |
( |
| ) |
|
|
virtual |
When does this get called?
This function is called to initialize the part. The ConfigNode contains the parameters of the module as specified in the part.cfg file, or as you last saved them in OnSave.
- Parameters
-
node | A ConfigNode containing the module's parameters from part.cfg or persistent.sfs |
Reimplemented in ModuleEngines, ModuleScienceExperiment, and KerbalEVA.
This function is called when the game is saved to let the part save persistent data. Add any data you want to persist to the ConfigNode. The ConfigNode will then be saved as part of persistent.sfs. When the game is resumed, you can then read this data back out in OnLoad.
- Parameters
-
Reimplemented in ModuleEngines, ModuleScienceExperiment, and KerbalEVA.
Called when the flight starts, or when the part is created in the editor. OnStart will be called before OnUpdate or OnFixedUpdate are ever called.
- Parameters
-
state | Some information about what situation the vessel is starting in. |
Reimplemented in ModuleEngines, ModuleScienceExperiment, KerbalEVA, and ModuleAsteroid.
virtual void PartModule.OnUpdate |
( |
| ) |
|
|
virtual |
Called once per Unity Update cycle once the part has been activated. If you want to be called even if the part has not been activated, define a function called void Update()
instead of overriding OnFixedUpdate.
See the Unity documentation on Update for more information. Poll for user input in OnUpdate, not OnFixedUpdate.
bool PartModule.isEnabled |
string PartModule.moduleName |
ProtoPartModuleSnapshot PartModule.snapshot |
A list of KSPActions which can be added to action groups.
string PartModule.ClassName |
|
get |
In any subclass of PartModule, ClassName
will be the name of the subclass. It gets set by the PartModule loading process.
BaseEventList PartModule.Events |
|
get |
A list of KSPEvents, which can be triggered by code or by the user through the part's right-click menu.
BaseFieldList PartModule.Fields |
|
get |
A list of the KSPFields which the module loads from the part.cfg file.
string PartModule.GUIName |
|
get |
The Part to which this PartModule is attached. Use this to reference the part from your module code.
The documentation for this class was generated from the following file: