PartModuleUtils Class |
Namespace: KSPDev.PartUtils
The PartModuleUtils type exposes the following members.
Name | Description | |
---|---|---|
AddEvent | Add an event into a part module. | |
DropEvent | Removes the specified event from the part module. | |
GetAction | Returns an action for the requested method. | |
GetEvent | Returns an event for the requested method. | |
InjectEvent | Injects an event from one part to another. | |
InvalidateContextMenu | Forces the context menu of the part to refresh itself. | |
SetupAction | Applies a setup function on a KSP part module action. | |
SetupEvent | Applies a setup function on a KSP part module event. | |
WithdrawEvent | Removes an event that was previously injected. |
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); } }
class PartModuleUtils_GetEvent : PartModule { [KSPEvent(guiName = "test", guiActive = true, active = false)] void TestEvent() { Debug.Log("Test event triggered"); } void SetupEvents() { var e = PartModuleUtils.GetEvent(this, TestEvent); e.active = true; // Activates the event. } }