Difference between revisions of "API:PartModule"

From Kerbal Space Program Wiki
Jump to: navigation, search
(Moved PartModule.StartState to its own page!)
Line 45: Line 45:
 
|name=OnStart
 
|name=OnStart
 
|returntype=void
 
|returntype=void
|args={{Type/Text|PartModule}}.{{Type|StartState}} state
+
|args={{Type|PartModule.StartState}} state
 
|desc=Called during the part startup.
 
|desc=Called during the part startup.
 
}}
 
}}
Line 98: Line 98:
 
|desc=Returns the part information.
 
|desc=Returns the part information.
 
}}
 
}}
}}
 
 
 
{{Enum
 
|name=StartState
 
|summary=An enum that determines what game state a part starts in.
 
 
''' The values for this enum are probably incomplete. '''
 
}}
 
 
 
 
{{Fields|
 
{{Field
 
|name=Docked
 
|type=PartModule.StartState
 
|desc=Part started while docked.
 
}}
 
 
{{Field
 
|name=Editor
 
|type=PartModule.StartState
 
|desc=Part started in editor.
 
}}
 
 
{{Field
 
|name=Flying
 
|type=PartModule.StartState
 
|desc=Part started while flying.
 
}}
 
 
 
{{Field
 
|name=Landed
 
|type=PartModule.StartState
 
|desc=Part started landed on a planet.
 
}}
 
 
 
{{Field
 
|name=None
 
|type=PartModule.StartState
 
|desc=The part state is unknown.
 
}}
 
 
{{Field
 
|name=Orbital
 
|type=PartModule.StartState
 
|desc=The part started in orbit.
 
}}
 
 
{{Field
 
|name=PreLaunch
 
|type=PartModule.StartState
 
|desc=The part started before launch.
 
}}
 
 
 
{{Field
 
|name=Splashed
 
|type=PartModule.StartState
 
|desc=The part started in the water.
 
}}
 
 
 
{{Field
 
|name=SubOrbital
 
|type=PartModule.StartState
 
|desc=The part started in a sub orbital atmosphere.
 
}}
 
 
 
}}
 
}}
  
 
[[Category:Community API Documentation]]
 
[[Category:Community API Documentation]]

Revision as of 00:52, 28 April 2013

PartModule Class

Inherits Implements
  • MonoBehaviour

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

The properties of this class have not been added.

Example

Called during the main menu loading stage.

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

Fields

The following is a list of fields in PartModule.

Signature Description
ProtoPartModuleSnapshot snapshot Unknown
string moduleName The modules name
bool isEnabled The part state.

Methods

The following are methods included in PartModule.

Signature Description
void OnStart(PartModule.StartState state) Called during the part startup.
void OnUpdate() Called when OnUpdate is called on the part.
void OnAwake() Called when the part is loaded, this can be more than once.
void OnFixedUpdate() Per-PhysX frame update, Called only when the part is active!
void OnActive() Called when the part is active.
void OnInactive() Get the part information.
void OnLoad(ConfigNode node) Called when the object is loaded from a save.
void OnSave(ConfigNode node) Called when the object is saved.
string GetInfo() Returns the part information.