Click or drag to resize

PartModuleUtilsSetupEvent Method

Applies a setup function on a KSP part module event.

Namespace:  KSPDev.PartUtils
Assembly:  KSPDev_Utils.1.1 (in KSPDev_Utils.1.1.dll) Version: 1.1 for KSP v1.6+
Syntax
C#
public static bool SetupEvent(
	PartModule partModule,
	Action eventFn,
	Action<BaseEvent> setupFn
)
Request Example View Source

Parameters

partModule
Type: (Default Namespace)PartModule
The module to find the event in.
eventFn
Type: SystemAction
The event's method signature.
setupFn
Type: SystemActionBaseEvent
The function to apply to the event if the one is found.

Return Value

Type: Boolean
true if the event was found and the function was applied, false otherwise.
Examples
class PartModuleUtils_SetupEvent : PartModule {
  [KSPEvent(guiName = "test", guiActive = true, active = false)]
  void TestEvent() {
    Debug.Log("Test event triggered");
  }

  void SetupEvents() {
    // This call will activate the event.
    PartModuleUtils.SetupEvent(this, TestEvent, x => x.active = true);
  }
}
See Also