Difference between revisions of "API:PartModule"

From Kerbal Space Program Wiki
Jump to: navigation, search
(Moved PartModule.StartState to its own page!)
m (Reverted edits by Rocketing Rudolph (talk) to last revision by Martincmartin)
 
(12 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
<!-- Class tables autogenerated against KSP 1.04 by Glyph's kerbal_wiki_pdoc program. -->
 
{{Class
 
{{Class
|inherits=<ul><li>{{Type|MonoBehaviour}}</li></ul>
+
  |inherits={{Type|MonoBehaviour}}
|name=PartModule
+
  |implements=<ul></ul>
|summary=The PartModule class allows you to override its functions to intuitively control your parts.
+
  |name=PartModule
 
+
  |summary=The '''PartModule''' class allows you to override its functions to intuitively control your parts.
'''The properties of this class have not been added.'''
 
 
}}
 
}}
 
=== Example ===
 
=== Example ===
Line 20: Line 20:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
{{Properties|properties=
 +
{{Property
 +
  |type=BaseActionList
 +
  |name=Actions
 +
  |desc=?
 +
  |hasget=1
 +
  |hasset=
 +
}}
 +
{{Property
 +
  |type=int
 +
  |name=ClassID
 +
  |desc=?
 +
  |hasget=1
 +
  |hasset=
 +
}}
 +
{{Property
 +
  |type=string
 +
  |name=ClassName
 +
  |desc=?
 +
  |hasget=1
 +
  |hasset=
 +
}}
 +
{{Property
 +
  |type=BaseEventList
 +
  |name=Events
 +
  |desc=?
 +
  |hasget=1
 +
  |hasset=
 +
}}
 +
{{Property
 +
  |type=BaseFieldList
 +
  |name=Fields
 +
  |desc=?
 +
  |hasget=1
 +
  |hasset=
 +
}}
 +
{{Property
 +
  |type=string
 +
  |name=GUIName
 +
  |desc=?
 +
  |hasget=1
 +
  |hasset=
 +
}}
 +
{{Property
 +
  |type=Part
 +
  |name=part
 +
  |desc=?
 +
  |hasget=1
 +
  |hasset=1
 +
}}
 +
{{Property
 +
  |type=Vessel
 +
  |name=vessel
 +
  |desc=?
 +
  |hasget=1
 +
  |hasset=
 +
}}
 +
}}
 
{{Fields|
 
{{Fields|
 
{{Field
 
{{Field
|name=snapshot
+
  |type=bool
|type=ProtoPartModuleSnapshot
+
  |name=isEnabled
|desc=Unknown
+
  |desc=The part state.
 
}}
 
}}
 
 
{{Field
 
{{Field
|name=moduleName
+
  |type=string
|type=string
+
  |name=moduleName
|desc=The modules name
+
  |desc=The module's name.
 
}}
 
}}
 
 
{{Field
 
{{Field
|name=isEnabled
+
  |type=ProtoPartModuleSnapshot
|type=bool
+
  |name=snapshot
|desc=The part state.
+
  |desc=?
 
}}
 
}}
 
}}
 
}}
 
 
{{Methods|
 
{{Methods|
 
{{Method
 
{{Method
|name=OnStart
+
  |returntype=constructor
|returntype=void
+
  |returndesc=
|args={{Type|PartModule.StartState}} state
+
  |name=PartModule
|desc=Called during the part startup.
+
  |args=
 +
  |desc=?
 +
}}
 +
{{Method
 +
  |returntype=virtual string
 +
  |returndesc=
 +
  |name=GetInfo
 +
  |args=
 +
  |desc=Returns the part information displayed in the part list mouse-over information box.
 +
}}
 +
{{Method
 +
  |returntype=void
 +
  |returndesc=
 +
  |name=Load
 +
  |args={{arg|ConfigNode|node}}
 +
  |desc=?
 +
}}
 +
{{Method
 +
  |returntype=virtual void
 +
  |returndesc=
 +
  |name=OnActive
 +
  |args=
 +
  |desc=Called when the part is active.  Not called in VAB or when on launch pad, but is called when stage is started, assuming that activates the module.
 +
}}
 +
{{Method
 +
  |returntype=virtual void
 +
  |returndesc=
 +
  |name=OnAwake
 +
  |args=
 +
  |desc=Called when the part is loaded, this can be more than once.  Called when part is selected in VAB, and also when switching from VAB to launch pad.
 
}}
 
}}
 
 
{{Method
 
{{Method
|name=OnUpdate
+
  |returntype=virtual void
|returntype=void
+
  |returndesc=
|desc=Called when OnUpdate is called on the part.
+
  |name=OnFixedUpdate
 +
  |args=
 +
  |desc=Per-PhysX frame update, Called only when the part is active!
 
}}
 
}}
 
 
{{Method
 
{{Method
|name=OnAwake
+
  |returntype=virtual void
|returntype=void
+
  |returndesc=
|desc=Called when the part is loaded, this can be more than once.
+
  |name=OnInactive
 +
  |args=
 +
  |desc=Get the part information.
 
}}
 
}}
 
 
{{Method
 
{{Method
|name=OnFixedUpdate
+
  |returntype=virtual void
|returntype=void
+
  |returndesc=
|desc=Per-PhysX frame update, Called only when the part is active!
+
  |name=OnInitialize
 +
  |args=
 +
  |desc=Called when part is selected in VAB, switching to launch pad or loading from a save.
 
}}
 
}}
 
 
{{Method
 
{{Method
|name=OnActive
+
  |returntype=virtual void
|returntype=void
+
  |returndesc=
|desc=Called when the part is active.
+
  |name=OnLoad
 +
  |args={{arg|ConfigNode|node}}
 +
  |desc=Called when the object is loaded from a save.
 
}}
 
}}
 
 
{{Method
 
{{Method
|name=OnInactive
+
  |returntype=virtual void
|returntype=void
+
  |returndesc=
|desc=Get the part information.
+
  |name=OnSave
 +
  |args={{arg|ConfigNode|node}}
 +
  |desc=Called when the object is saved, which happens with any change in VAB, when switching to launch pad, and during auto saving.
 
}}
 
}}
 
 
{{Method
 
{{Method
|name=OnLoad
+
  |returntype=virtual void
|returntype=void
+
  |returndesc=
|args={{Type|ConfigNode}} node
+
  |name=OnStart
|desc=Called when the object is loaded from a save.
+
  |args={{arg|StartState|state}}
 +
  |desc=Called when entering VAB (with arg Editor), launch pad (with arg PreLaunch | Landed), or loading from save.
 
}}
 
}}
 
 
{{Method
 
{{Method
|name=OnSave
+
  |returntype=virtual void
|returntype=void
+
  |returndesc=
|args={{Type|ConfigNode}} node
+
  |name=OnUpdate
|desc=Called when the object is saved.
+
  |args=
 +
  |desc=Called when OnUpdate is called on the part.
 
}}
 
}}
 
 
{{Method
 
{{Method
|name=GetInfo
+
  |returntype=void
|returntype=string
+
  |returndesc=
|desc=Returns the part information.
+
  |name=Save
 +
  |args={{arg|ConfigNode|node}}
 +
  |desc=?
 +
}}
 +
}}
 +
{{Enums|enums=
 +
{{Enum
 +
  |name=StartState
 +
  |values=None<br/>Editor<br/>PreLaunch<br/>Landed = 4<br/>Docked = 8<br/>Flying = 16<br/>Splashed = 32<br/>SubOrbital = 64<br/>Orbital = 128<br/>
 
}}
 
}}
 
}}
 
}}
  
 
[[Category:Community API Documentation]]
 
[[Category:Community API Documentation]]

Latest revision as of 18:49, 17 March 2017

PartModule Class

Inherits Implements
MonoBehaviour

    The PartModule class allows you to override its functions to intuitively control your parts.

    Example

    Called during the main menu loading stage.

    using System;
    using UnityEngine;
     
    public class RandomPart : PartModule
    {
    	public override void OnAwake()
    	{
    		Debug.Log("Hello World");
    	}
    }

    Properties

    The following is a list of properties in PartModule.

    Name Description
    BaseActionList Actions { get; }  ?
    int ClassID { get; }  ?
    string ClassName { get; }  ?
    BaseEventList Events { get; }  ?
    BaseFieldList Fields { get; }  ?
    string GUIName { get; }  ?
    Part part { get; set; }  ?
    Vessel vessel { get; }  ?

    Fields

    The following is a list of fields in PartModule.

    Signature Description
    bool isEnabled The part state.
    string moduleName The module's name.
    ProtoPartModuleSnapshot snapshot  ?

    Methods

    The following are methods included in PartModule.

    Signature Description
    constructor PartModule()  ?
    virtual string GetInfo() Returns the part information displayed in the part list mouse-over information box.
    void Load(ConfigNode node)  ?
    virtual void OnActive() Called when the part is active. Not called in VAB or when on launch pad, but is called when stage is started, assuming that activates the module.
    virtual void OnAwake() Called when the part is loaded, this can be more than once. Called when part is selected in VAB, and also when switching from VAB to launch pad.
    virtual void OnFixedUpdate() Per-PhysX frame update, Called only when the part is active!
    virtual void OnInactive() Get the part information.
    virtual void OnInitialize() Called when part is selected in VAB, switching to launch pad or loading from a save.
    virtual void OnLoad(ConfigNode node) Called when the object is loaded from a save.
    virtual void OnSave(ConfigNode node) Called when the object is saved, which happens with any change in VAB, when switching to launch pad, and during auto saving.
    virtual void OnStart(StartState state) Called when entering VAB (with arg Editor), launch pad (with arg PreLaunch
    virtual void OnUpdate() Called when OnUpdate is called on the part.
    void Save(ConfigNode node)  ?

    Enumerations

    The following is a list of enumerations in PartModule.

    Name Values
    StartState None
    Editor
    PreLaunch
    Landed = 4
    Docked = 8
    Flying = 16
    Splashed = 32
    SubOrbital = 64
    Orbital = 128