/// <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; }
/// <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; }
/// <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)); }
/// <inheritdoc/> public virtual void BreakCurrentLink(LinkActorType actorType) { if (!isLinked) { HostedDebugLog.Error(this, "Cannot break link in state: {0}", linkState); return; } PhysicalUnlink(); LogicalUnlink(actorType); }
/// <inheritdoc/> public virtual bool LinkToTarget(LinkActorType actor, ILinkTarget target) { if (StartLinking(GUILinkMode.API, actor)) { if (LinkToTarget(target)) { return(true); } CancelLinking(); } return(false); }
/// <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); } }
/// <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); }
/// <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)); }
public abstract void BreakCurrentLink(LinkActorType actorType);
public abstract bool LinkToTarget(LinkActorType actor, ILinkTarget target);
public abstract bool StartLinking(GUILinkMode mode, LinkActorType actor);