Example #1
0
 /// <summary>Creates an event info.</summary>
 /// <param name="source">The source that initiated the link.</param>
 /// <param name="target">The target that accepted the link.</param>
 /// <param name="actorType">The actor that did the change.</param>
 public KasLinkEventImpl(ILinkSource source, ILinkTarget target,
                         LinkActorType actorType = LinkActorType.API)
 {
     _source = source;
     _target = target;
     _actor  = actorType;
 }
Example #2
0
 /// <summary>Creates an event info.</summary>
 /// <param name="source">The source that initiated the link.</param>
 /// <param name="target">The target that accepted the link.</param>
 /// <param name="actorType">The actor that did the change.</param>
 public KasLinkEventImpl(ILinkSource source, ILinkTarget target,
                         LinkActorType actorType = LinkActorType.API)
 {
     this.source = source;
     this.target = target;
     actor       = actorType;
 }
Example #3
0
 /// <inheritdoc/>
 public override bool StartLinking(GUILinkMode mode, LinkActorType actor)
 {
     // Don't allow EVA linking mode.
     if (mode != GUILinkMode.Interactive && mode != GUILinkMode.API)
     {
         return(false);
     }
     return(base.StartLinking(mode, actor));
 }
Example #4
0
 /// <inheritdoc/>
 public virtual void BreakCurrentLink(LinkActorType actorType)
 {
     if (!isLinked)
     {
         HostedDebugLog.Error(this, "Cannot break link in state: {0}", linkState);
         return;
     }
     PhysicalUnlink();
     LogicalUnlink(actorType);
 }
Example #5
0
 /// <inheritdoc/>
 public virtual bool LinkToTarget(LinkActorType actor, ILinkTarget target)
 {
     if (StartLinking(GUILinkMode.API, actor))
     {
         if (LinkToTarget(target))
         {
             return(true);
         }
         CancelLinking();
     }
     return(false);
 }
Example #6
0
 /// <inheritdoc/>
 protected override void LogicalUnlink(LinkActorType actorType)
 {
     SaveConnectorModelPosAndRot(saveNonPhysical: true);
     if (actorType == LinkActorType.Physics)
     {
         UISoundPlayer.instance.Play(sndPathBroke);
         ShowStatusMessage(CableLinkBrokenMsg, isError: true);
     }
     base.LogicalUnlink(actorType);
     SetConnectorState(isConnectorLocked ? ConnectorState.Locked : ConnectorState.Deployed);
     if (actorType == LinkActorType.Player && connectorState == ConnectorState.Deployed)
     {
         UISoundPlayer.instance.Play(sndPathUnplugConnector);
     }
 }
Example #7
0
 /// <inheritdoc/>
 public virtual bool StartLinking(GUILinkMode mode, LinkActorType actor)
 {
     if (!linkStateMachine.CheckCanSwitchTo(LinkState.Linking))
     {
         if (actor == LinkActorType.Player)
         {
             ShowStatusMessage(SourceIsNotAvailableForLinkMsg, isError: true);
         }
         HostedDebugLog.Warning(this, "Cannot start linking mode in state: {0}", linkState);
         return(false);
     }
     guiLinkMode = mode;
     linkActor   = actor;
     linkState   = LinkState.Linking;
     return(true);
 }
Example #8
0
        /// <summary>
        /// Logically un-links the source and the current target, and stops the renderer.
        /// </summary>
        /// <remarks>It's always called <i>after</i> the physical link updates.</remarks>
        /// <param name="actorType">The actor which has initiated the un-linking.</param>
        protected virtual void LogicalUnlink(LinkActorType actorType)
        {
            HostedDebugLog.Info(this, "Un-linking from target: {0}, actor={1}", linkTarget, actorType);
            linkActor = actorType;
            var linkInfo = new KasLinkEventImpl(this, linkTarget, actorType);

            linkRenderer.StopRenderer();
            SetLinkState(LinkState.Available);
            if (linkTarget != null)
            {
                linkTarget.linkSource = null;
                SetOtherPeer(null);
            }
            linkActor = LinkActorType.None;
            KASAPI.KasEvents.OnLinkBroken.Fire(linkInfo);
            part.Modules.OfType <ILinkStateEventListener>().ToList()
            .ForEach(x => x.OnKASLinkedState(linkInfo, isLinked: false));
        }
Example #9
0
 public abstract void BreakCurrentLink(LinkActorType actorType);
Example #10
0
 public abstract bool LinkToTarget(LinkActorType actor, ILinkTarget target);
Example #11
0
 public abstract bool StartLinking(GUILinkMode mode, LinkActorType actor);