Click or drag to resize

IKasEventsOnStartLinking Property

Triggers when a source has initiated linking mode.

Namespace:  KASAPIv2
Assembly:  KAS-API-v2 (in KAS-API-v2.dll) Version: KAS API v2
Syntax
C#
EventData<ILinkSource> OnStartLinking { get; }
Request Example View Source

Property Value

Type: EventDataILinkSource
Collection to add or remove a callback.
Remarks
The argument of the callback is the link source that started the mode.
Examples
public class KasEventsExample1: PartModule {
  public override void OnAwake() {
    base.OnAwake();
    KASAPI.KasEvents.OnStartLinking.Add(LinkStarted);
    KASAPI.KasEvents.OnStopLinking.Add(LinkStopped);
    KASAPI.KasEvents.OnLinkCreated.Add(LinkCreated);
    KASAPI.KasEvents.OnLinkBroken.Add(LinkBroken);
  }

  void OnDestroy() {
    KASAPI.KasEvents.OnStartLinking.Remove(LinkStarted);
    KASAPI.KasEvents.OnStopLinking.Remove(LinkStopped);
    KASAPI.KasEvents.OnLinkCreated.Remove(LinkCreated);
    KASAPI.KasEvents.OnLinkBroken.Remove(LinkBroken);
  }

  void LinkStarted(ILinkSource source) {
    DebugEx.Info("Link started by: {0}", source);
  }

  void LinkStopped(ILinkSource source) {
    DebugEx.Info("Link stopepd by: {0}", source);
  }

  void LinkCreated(IKasLinkEvent ev) {
    DebugEx.Info("Link created: {0} <=> {1}", ev.source, ev.target);
  }

  void LinkBroken(IKasLinkEvent ev) {
    DebugEx.Info("Link broken: {0} <=> {1}", ev.source, ev.target);
  }
}
See Also