Example #1
0
        /// <summary>Get a view of an outgoing attachment point for a given animation at frame 0</summary>
        /// <param name="animationContext">The context to select the animation (frame 0 is used)</param>
        /// <param name="outgoingAttachmentContext">The context to select the outgoing attachment point</param>
        public OutgoingAttachmentView GetOutgoingAttachment(string animationContext, string outgoingAttachmentContext,
                                                            List <OutgoingAttachmentAttempt> trackOutgoingAttachments)
        {
            var animation          = animationSet[animationContext];
            var animationFrame     = animation.Frames[0];
            var outgoingAttachment = animationFrame.outgoingAttachments.Get(outgoingAttachmentContext);

            var result = new OutgoingAttachmentView(outgoingAttachment,
                                                    position + currentAnimation.PositionDeltaThisTick(), facingLeft);

            if (trackOutgoingAttachments != null)
            {
                trackOutgoingAttachments.Add(new OutgoingAttachmentAttempt(animation, result));
            }

#if DEBUG
            if (!result.IsValid)
            {
                Debug.WriteLine("MISSING OUTGOING ATTACHMENT: AnimationSet = \"" + animationSet.friendlyName + "\", Animation Context = \"" + animationContext.ToString()
                                + "\", Found Animation = \"" + animation.friendlyName + "\", Outgoing Attachment Context = \"" + outgoingAttachmentContext.ToString() + "\"");
            }
#endif

            return(result);
        }
Example #2
0
 public IncomingAttachmentAttempt(OutgoingAttachmentView outgoingAttachmentView, Animation animation, Position incomingAttachment, bool inRange)
 {
     this.outgoingAttachmentView = outgoingAttachmentView;
     this.animation          = animation;
     this.incomingAttachment = incomingAttachment;
     this.inRange            = inRange;
 }
Example #3
0
        /// <summary>
        /// Get the world position of an matching incoming attachment point, for an outgoing attachment point, if a valid one exists.
        /// Does NOT consider if the attachment point is in-range! (Probably prefer <see cref="Character.GrabRangeHelper"/>)
        /// </summary>
        public bool GetIncomingAttachment(ref OutgoingAttachmentView outgoingAttachmentView, out Position incomingAttachment, List <IncomingAttachmentAttempt> trackIncomingAttachments)
        {
            if (!outgoingAttachmentView.IsValid)
            {
                incomingAttachment = this.position;
                return(false);
            }

            var animationContext  = outgoingAttachmentView.attachment.targetAnimationContext.MaybeFlip(outgoingAttachmentView.facingLeft != facingLeft);
            var attachmentContext = outgoingAttachmentView.attachment.targetAttachmentContext.MaybeFlip(outgoingAttachmentView.facingLeft != facingLeft);

            var animation      = animationSet[animationContext];
            var animationFrame = animation.Frames[0];

            if (animationFrame.incomingAttachments.TryGetBestValue(attachmentContext, out incomingAttachment))
            {
                // Transform to world space:
                if (facingLeft)
                {
                    incomingAttachment.X = -incomingAttachment.X; // FlipX
                }
                incomingAttachment += position;

                if (trackIncomingAttachments != null)
                {
                    bool inRange = outgoingAttachmentView.attachRange.Contains(incomingAttachment);
                    trackIncomingAttachments.Add(new IncomingAttachmentAttempt(outgoingAttachmentView, animation, incomingAttachment, inRange));
                }

                return(true);
            }

            return(false);
        }
Example #4
0
 public OutgoingAttachmentAttempt(Animation animation, OutgoingAttachmentView outgoingAttachmentView)
 {
     this.animation = animation;
     this.outgoingAttachmentView = outgoingAttachmentView;
 }