C# Class kOS.Module.kOSVesselModule

The kOSVesselModule class contains references to anything that is vessel specific rather than processor part specific. For instance, flight controls and steering. It gives a single location to manage instances where docking, staging, and similar events should be handled automatically.
Inheritance: VesselModule
Show file Open project: KSP-KOS/KOS Class Usage Examples

Public Methods

Method Description
AddFlightControlParameter ( string name, IFlightControlParameter parameter ) : void

Adds an IFlightControlParameter to the reference dictionary, and throws an error if it already exists.

FixedUpdate ( ) : void

FixedUpdate is called once per physics tick.

GetFlightControlParameter ( string name ) : IFlightControlParameter

Returns the named IFlightControlParameter

GetInstance ( Vessel vessel ) : kOSVesselModule

Return the kOSVesselModule instance associated with the given Vessel object

HasFlightControlParameter ( string name ) : bool

Returns true if the named IFlightControlParameter already exists

LastUpdate ( ) : void

LastUpdate is called at the end of the update frame. Useful if something needs to be done after the physics and UI updates have been completed, but before scene or gui rendering.

OnDestroy ( ) : void

OnDestroy is called when the Vessel object is destroyed. This is the last method called by KSP. We can remove the instance tracking and unhook events here.

OnGUI ( ) : void

OnGUI is where any vessel specific interface rendering should be done.

RemoveFlightControlParameter ( string name ) : void

Removes the named IFlightControlParameter from the reference dictionary.

Update ( ) : void

Update is called once per UI tick.

Protected Methods

Method Description
OnAwake ( ) : void

OnAwake is called once when instatiating a new VesselModule. This is the first method called by KSP after the VesselModule has been attached to the parent Vessel. We use it to store the parent Vessel and track the kOSVesselModule instances.

OnLoad ( ConfigNode node ) : void
OnStart ( ) : void

Start is called after OnEnable activates the module. This is the second method called by KSP after Awake. All parts should be added to the vessel now, so it is safe to walk the parts tree to find the attached kOSProcessor modules.

Private Methods

Method Description
AddDefaultParameters ( ) : void

Setup the default flight parameters.

CheckRehookAutopilot ( ) : void

A race condition exists where KSP can load the kOS module onto the vessel before it loaded the RemoteTech module. That makes it so that kOS may not see the existence of RT yet when kOS is first initialized.

This fixes that case by continually re-querying for RT post-loading, and re-initializing kOS's RT-related behaviors if it seems that the RT module now exists when it didn't before (or visa versa).
With the update for KSP 1.2, this function was renamed and made more generic so that it may support future autopilot connectivity configurations.

ClearParts ( ) : void

Clear the childParts list. This is used when refreshing the parts list, or when destroying the module.

HandleOnPreAutopilotUpdate ( FlightCtrlState c ) : void
HandleRemoteTechSanctionedPilot ( FlightCtrlState c ) : void
HarvestParts ( ) : void

Generates a list of all processorModules included on the parentVessel.

HookEvents ( ) : void

Hook up to any vessel/game events that might be needed.

UnHookEvents ( ) : void

Unhook from events we previously hooked up to.

UpdateAutopilot ( FlightCtrlState c ) : void

Call to each IFlightControlParameter to update the flight controls. This is called during OnPreAutopilotUpdate

UpdateParameterState ( ) : void

Update the current stte of the each IFlightControlParameter. This is called during FixedUpdate

cacheControllable ( ) : void
resetControllable ( ) : void

Method Details

AddFlightControlParameter() public method

Adds an IFlightControlParameter to the reference dictionary, and throws an error if it already exists.
public AddFlightControlParameter ( string name, IFlightControlParameter parameter ) : void
name string the bound name of the parameter, this will be converted to lower case internally
parameter IFlightControlParameter
return void

FixedUpdate() public method

FixedUpdate is called once per physics tick.
public FixedUpdate ( ) : void
return void

GetFlightControlParameter() public method

Returns the named IFlightControlParameter
public GetFlightControlParameter ( string name ) : IFlightControlParameter
name string the bound name of the parameter, this will be converted to lower case internally
return IFlightControlParameter

GetInstance() public static method

Return the kOSVesselModule instance associated with the given Vessel object
public static GetInstance ( Vessel vessel ) : kOSVesselModule
vessel Vessel the vessel for which the module should be returned
return kOSVesselModule

HasFlightControlParameter() public method

Returns true if the named IFlightControlParameter already exists
public HasFlightControlParameter ( string name ) : bool
name string the bound name of the parameter, this will be converted to lower case internally
return bool

LastUpdate() public method

LastUpdate is called at the end of the update frame. Useful if something needs to be done after the physics and UI updates have been completed, but before scene or gui rendering.
public LastUpdate ( ) : void
return void

OnAwake() protected method

OnAwake is called once when instatiating a new VesselModule. This is the first method called by KSP after the VesselModule has been attached to the parent Vessel. We use it to store the parent Vessel and track the kOSVesselModule instances.
protected OnAwake ( ) : void
return void

OnDestroy() public method

OnDestroy is called when the Vessel object is destroyed. This is the last method called by KSP. We can remove the instance tracking and unhook events here.
public OnDestroy ( ) : void
return void

OnGUI() public method

OnGUI is where any vessel specific interface rendering should be done.
public OnGUI ( ) : void
return void

OnLoad() protected method

protected OnLoad ( ConfigNode node ) : void
node System.ConfigNode
return void

OnStart() protected method

Start is called after OnEnable activates the module. This is the second method called by KSP after Awake. All parts should be added to the vessel now, so it is safe to walk the parts tree to find the attached kOSProcessor modules.
protected OnStart ( ) : void
return void

RemoveFlightControlParameter() public method

Removes the named IFlightControlParameter from the reference dictionary.
public RemoveFlightControlParameter ( string name ) : void
name string the bound name of the parameter, this will be converted to lower case internally
return void

Update() public method

Update is called once per UI tick.
public Update ( ) : void
return void