/// <inheritdoc/> public virtual bool CheckCanLinkTo(ILinkTarget target, bool checkStates = true, bool reportToGui = false, bool reportToLog = true) { var errors = new List <string>() .Concat(CheckBasicLinkConditions(target, checkStates)) .Concat(linkRenderer.CheckColliderHits(nodeTransform, target.nodeTransform)) .Concat(linkJoint.CheckConstraints(this, target)) .ToArray(); if (errors.Length > 0) { if (reportToGui || reportToLog) { HostedDebugLog.Warning( this, "Cannot link a part of type={0} with: part={1}, type={2}, errors={3}", cfgLinkType, target.part, target.cfgLinkType, DbgFormatter.C2S(errors)); } if (reportToGui) { ShowStatusMessage(DbgFormatter.C2S(errors, separator: "\n"), isError: true); } } return(errors.Length == 0); }
public CompareQuery(XElement inputxml, ILinkTarget owner) : base(owner) { this._querylist = new QueryPriorityList(this); this._processingwrangler.Separator = string.Empty; this._reprocess = true; this.LoadXml(inputxml); }
/// <summary> /// Performs a check to ensure that the link between the source and the target, if it's made, will /// be consistent. /// </summary> /// <remarks> /// This method must pass for both started and not started linking mode even when the state /// checking is requested. /// </remarks> /// <param name="target">The target of the pipe to check link with.</param> /// <param name="checkStates">Tells if the source and target states need to be validated.</param> /// <returns> /// An empty array if the link can be created, or a list of user friendly errors otherwise. /// </returns> // ReSharper disable once VirtualMemberNeverOverridden.Global protected virtual string[] CheckBasicLinkConditions(ILinkTarget target, bool checkStates) { var errors = new List <string>(); if (checkStates) { if (linkState != LinkState.Available && linkState != LinkState.Linking || isLocked) { errors.Add(SourceIsNotAvailableForLinkMsg); } if (linkState == LinkState.Available && target.linkState != LinkState.Available || linkState == LinkState.Linking && target.linkState != LinkState.AcceptingLinks || target.isLocked) { errors.Add(TargetDoesntAcceptLinksMsg); } } if (cfgLinkType != target.cfgLinkType) { errors.Add(IncompatibleTargetLinkTypeMsg); } if (coupleMode == CoupleMode.AlwaysCoupled && target.coupleNode == null) { errors.Add(TargetCannotCoupleMsg); } return(errors.ToArray()); }
/// <inheritdoc/> public virtual bool LinkToTarget(ILinkTarget target) { if (!linkStateMachine.CheckCanSwitchTo(LinkState.Linked)) { if (linkActor == LinkActorType.Player) { ShowStatusMessage(SourceIsNotAvailableForLinkMsg, isError: true); } HostedDebugLog.Error(this, "Cannot link in state: {0}", linkState); return(false); } if (!CheckCanLinkTo(target, reportToGui: linkActor == LinkActorType.Player)) { return(false); } if (coupleMode == CoupleMode.AlwaysCoupled || coupleNode != null && coupleNode.attachedPart != null) { linkJoint.SetCoupleOnLinkMode(true); } else if (coupleMode == CoupleMode.NeverCouple) { linkJoint.SetCoupleOnLinkMode(false); } LogicalLink(target); PhysicalLink(); return(true); }
// <Query Type="IfElse"> // <Source> // <Query Type="OptionValue"> // <ID Name="TestLink1"/> // </Query> // </Source> // <Ruleset> // <Rule Type="Equals">TRUE/FALSE</Rule> // </Ruleset> // <Result> // <Query Type = "OptionValue"> // <ID Name = "TestLink1"/> // </Query> // </Result> // </Query> #endregion public static IQuery GetLinkTrueFalseOnlyQuery(string SourceID, ILinkTarget linktarget, bool truefalse) { XElement sharedqueryx = new XElement("Query"); sharedqueryx.Add(new XAttribute("Type", "OptionValue")); XElement idx = new XElement("ID"); idx.Add(new XAttribute("Name", SourceID)); sharedqueryx.Add(idx); XElement rulex = new XElement("Rule", truefalse.ToString()); rulex.Add(new XAttribute("Type", "Equals")); XElement rulesetx = new XElement("Ruleset", rulex); XElement ifx = new XElement("IF"); XElement sourcex = new XElement("Source", sharedqueryx); XElement resultx = new XElement("Result", sharedqueryx); ifx.Add(sourcex); ifx.Add(rulesetx); ifx.Add(resultx); XElement ifelsex = new XElement("Query", ifx); ifelsex.Add(new XAttribute("Type", "IfElse")); return(new IfElseQuery(ifelsex, linktarget)); }
public StringValidation(ILinkTarget owner) { this._owner = owner; this._validrules = new MatchingRuleLibrary(owner); this._invalidrules = new MatchingRuleLibrary(owner); this.SetDefaults(); }
/// <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; }
public GuiVariableQuery(XElement inputxml, ILinkTarget owner) : base(owner) { this.LoadXml(inputxml); this.AddExistingOptions(); //add and register any existing options Director.Instance.OptionLibrary.OptionAdded += this.OnOptionAddedToLibrary; //register to get any new options this.ProcessAndRefresh(); }
internal static void MemberDetailText(MemberInfo mi) { GetDesc(mi, "Member"); String memberType; if (mi.MemberType == MemberTypes.TypeInfo) { memberType = GetTypeKind((Type)mi); } else { memberType = mi.MemberType.ToString(); } String memInfo = MemberInfoString(mi, PARENS); if (memInfo != null) { memberType += memInfo; } ILinkTarget linkTarget = null; if (mi.DeclaringType != null) { TypeLibrary typeLib = TypeLibrary.GetTypeLib(mi.DeclaringType); if (typeLib != null) { linkTarget = ComLinkHelper.CLHelper; } } // No AX type linkage available, link to the assy/types nodes if (linkTarget == null) { linkTarget = TypeLinkHelper.TLHelper; } DetailPanel.AddLink(memberType, !ObjectBrowser.INTERNAL, 10, linkTarget, mi, HelpLinkHelper. MakeLinkModifier(mi)); if (mi.DeclaringType != null) { DetailPanel.AddLink("Member Declaring Type", !ObjectBrowser.INTERNAL, 61, TypeLinkHelper.TLHelper, mi.DeclaringType, HelpLinkHelper. MakeLinkModifier(mi.DeclaringType)); } }
public Conditional(XElement inputxml, ILinkTarget targetoption) { this._linktargetoption = targetoption; this._ruleset = new RuleSet(targetoption); this._sourcequerylist = new QueryPriorityList(this._linktargetoption); this._resultquerylist = new QueryPriorityList(this._linktargetoption); this.LoadXml(inputxml); }
public override void Set(ILinkTarget target, Linking linking) { if (linking == Linking.AsConnection) { Clear(); } base.Set(target, linking); }
public Compliance(ILinkTarget linktarget) { this.IsActive = true; this._okrules = new MatchingRuleLibrary(linktarget); this._warningrules = new MatchingRuleLibrary(linktarget); this._errorrules = new MatchingRuleLibrary(linktarget); this._invalidrules = new MatchingRuleLibrary(linktarget); }
public OptionValueQuery(XElement inputxml, ILinkTarget owner) : base(owner) { this._ignoreempty = false; this.SetDefaults(); this.LoadXml(inputxml); Director.Instance.LinkingLibrary.AddHandler(this._formatter.Name, this); this.ProcessQuery(); }
public bool Equals(ILinkTarget other) { if (other == null) { return(false); } return(Id.Equals(other.Id)); }
/// <summary>Checks if the link's angle at the target joint is within the limits.</summary> /// <remarks>This method takes into consideration the anchor settings.</remarks> /// <param name="source">The possible source of the link.</param> /// <param name="target">The possible target of the link.</param> /// <returns>An error message if the angle is over limit or <c>null</c> otherwise.</returns> /// <seealso cref="anchorAtSource"/> /// <seealso cref="anchorAtTarget"/> protected string CheckAngleLimitAtTarget(ILinkSource source, ILinkTarget target) { var linkVector = GetSourcePhysicalAnchor(source) - GetTargetPhysicalAnchor(source, target); var angle = Vector3.Angle(target.nodeTransform.rotation * Vector3.forward, linkVector); return(targetLinkAngleLimit > 0 && angle > targetLinkAngleLimit ? TargetNodeAngleLimitReachedMsg.Format(angle, targetLinkAngleLimit) : null); }
private void UpdateBeamEnds(ILinkTarget target) { StartPosition = transform.position; TargetPosition = target.LinkObject.transform.position; _lr.SetPosition(0, StartPosition); _lr.SetPosition(1, TargetPosition); BeamLength = Vector3.Distance(StartPosition, TargetPosition); BeamCenter = (StartPosition + TargetPosition) * 0.5f; }
internal static void AddLink(String title, bool isInternal, int order, ILinkTarget linkTarget, Object linkModifier) { AddLink(title, isInternal, order, linkTarget, linkModifier, null); }
// Регистрирует пару "объект-наблюдатель" public void Register(ILinkSource source, ILinkTarget target) { if (source == null || target == null || _links.Any(l => l.Item1.Equals(source) && l.Item2.Equals(target))) { return; } _links.Add(new Tuple <ILinkSource, ILinkTarget>(source, target)); }
/// <summary>Displays linking status in real time.</summary> void UpdateLinkingState() { // Catch the hovered part, a possible target on it, and the link feasibility. if (Mouse.HoveredPart != lastHoveredPart) { lastHoveredPart = Mouse.HoveredPart; targetCandidateIsGood = false; if (lastHoveredPart == null) { targetCandidate = null; } else { targetCandidate = lastHoveredPart.Modules.OfType <ILinkTarget>() .FirstOrDefault(x => x.cfgLinkType == cfgLinkType && x.linkState == LinkState.AcceptingLinks); if (targetCandidate != null) { var linkStatusErrors = new List <string>() .Concat(CheckBasicLinkConditions(targetCandidate, checkStates: true)) .Concat(linkRenderer.CheckColliderHits(nodeTransform, targetCandidate.nodeTransform)) .Concat(linkJoint.CheckConstraints(this, targetCandidate)) .ToArray(); if (linkStatusErrors.Length == 0) { targetCandidateIsGood = true; statusScreenMessage.message = CanBeConnectedMsg.Format( Vector3.Distance(nodeTransform.position, targetCandidate.nodeTransform.position)); } else { statusScreenMessage.message = ScreenMessaging.SetColorToRichText( String.Join("\n", linkStatusErrors), ScreenMessaging.ErrorColor); } } } // Show the possible link or indicate the error. if (targetCandidate != null) { linkRenderer.colorOverride = targetCandidateIsGood ? GoodLinkColor : BadLinkColor; linkRenderer.StartRenderer(nodeTransform, targetCandidate.nodeTransform); } else { linkRenderer.colorOverride = BadLinkColor; linkRenderer.StopRenderer(); } } // Update linking messages (it needs to be refreshed to not go out by timeout). if (targetCandidate == null) { statusScreenMessage.message = LinkingInProgressMsg; } ScreenMessages.PostScreenMessage(statusScreenMessage); }
/// <inheritdoc/> public virtual string[] CheckConstraints(ILinkSource source, ILinkTarget target) { var errors = new[] { CheckLengthLimit(source, target), CheckAngleLimitAtSource(source, target), CheckAngleLimitAtTarget(source, target), }; return(errors.Where(x => x != null).ToArray()); }
/// <summary> /// Load a reference by ID. /// </summary> private LoadLinkProtocolForLinkedSourceBuilder <TLinkedSource> LoadLinkReferencesByIds <TReference, TId>( Func <TLinkedSource, IEnumerable <TId> > getLookupIds, ILinkTarget <TLinkedSource, TReference> linkTarget) { return(AddNonPolymorphicLoadLinkExpression( getLookupIds, linkTarget, new IncludeReferenceById <TReference, TId, TReference, TId>(id => id) )); }
/// <inheritdoc/> public override bool CreateJoint(ILinkSource source, ILinkTarget target) { if (!base.CreateJoint(source, target)) { return(false); } trgJoint.angularXMotion = ConfigurableJointMotion.Locked; SetLockingMode(persistedLockingMode, updateUi: false); SetActiveSteeringState(persistedActiveSteeringEnabled); return(true); }
public static IStringMatchingRule GetRootRuleObject(XElement InputXml, ILinkTarget linktarget) { IStringMatchingRule newrule = GetRuleObject(InputXml, linktarget); RuleSet testset = newrule as RuleSet; if (testset != null) { testset.IsChild = false; } return(newrule); }
public virtual void Set(ILinkTarget target, Linking linking) { if (linking == Linking.AsReference) { Reference = target; } else { SaveConnection((IPage)target); } }
/// <summary>Cleans up the attach nodes and, optionally, breaks the link.</summary> /// <remarks> /// The actual changes are delyed till the end of frame. So it's safe to call this method from an /// event handler. /// </remarks> /// <param name="source">The link source at the moemnt of cleanup.</param> /// <param name="target">The link target at the moment of cleanup.</param> void MaybeBreakLink(ILinkSource source, ILinkTarget target) { // Delay the nodes cleanup to let the other logic work smoothly. Copy the properties since // they will be null'ed on the link destruction. AsyncCall.CallOnEndOfFrame(this, () => { if (isLinked) { source.BreakCurrentLink(LinkActorType.Physics); } }); }
public object GetState(ILinkTarget target, ILinkSource source) { if (target == null || source == null) { return(null); } var link = _links.FirstOrDefault(l => l.Item1.Equals(source) && l.Item2.Equals(target)); return(link == null ? null : link.Item1.GetState()); }
// Получает данные от источника определенного типа public object GetState <T>(ILinkTarget target) { if (target == null) { return(null); } var link = _links.FirstOrDefault(l => l.Item1 is T && l.Item2.Equals(target)); return(link == null ? null : link.Item1.GetState()); }
/// <inheritdoc/> public virtual bool LinkToTarget(LinkActorType actor, ILinkTarget target) { if (StartLinking(GUILinkMode.API, actor)) { if (LinkToTarget(target)) { return(true); } CancelLinking(); } return(false); }
/// <summary>Returns an anchor for the physical joint at the target part.</summary> /// <remarks> /// The anchor will be calculated in the source's part scale, and the target's model scale will /// be ignored. /// </remarks> /// <param name="source">The source of the link.</param> /// <param name="target">The target of the link.</param> /// <returns>The position in the world coordinates.</returns> protected Vector3 GetTargetPhysicalAnchor(ILinkSource source, ILinkTarget target) { var scale = source.nodeTransform.lossyScale; if (Mathf.Abs(scale.x - scale.y) > 1e-05 || Mathf.Abs(scale.x - scale.z) > 1e-05) { HostedDebugLog.Error(this, "Uneven scale on the source part is not supported: {0}", DbgFormatter.Vector(scale)); } return(target.nodeTransform.position + target.nodeTransform.rotation * (anchorAtTarget * scale.x)); }
// linkTarget is the class that knows how to display // the link, and is called to execute the link // linkModifier is the data passed to the linkTarget // helpLinkMod is a linkModifier for the HelpLinkHelper // to display help associated with the link internal static void AddLink(String title, bool isInternal, int order, ILinkTarget linkTarget, Object linkModifier, Object helpLinkMod) { DetailElement de = AddInternal(title, isInternal, order, null); de._isLink = true; de._value = linkTarget.GetLinkName(linkModifier); de._linkTarget = linkTarget; de._linkModifier = linkModifier; de._helpLinkMod = helpLinkMod; }
protected void ShowLink(ILinkTarget target, Object linkModifier) { // Links can sometimes take a while Cursor save = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { target.ShowTarget(linkModifier); } catch (Exception ex) { ErrorDialog.Show(ex, "(bug, please report) Unexpected exception " + "showing link", "Unexpected Exception Showing Link", MessageBoxIcon.Error); } Cursor.Current = save; }