public virtual SpriterKeyFrame getNextFrameFor(
            SpriterAbstractObject @object, SpriterKeyFrame
            currentFrame, int direction)
        {
            SpriterKeyFrame nextFrame = null;
            int             cnt       = 0;
            bool            isBone    = @object is SpriterBone;

            for (int j = (currentFrame.getId() + direction + this.keyframes()) % this.keyframes();
                 nextFrame == null && cnt < this.keyframes(); j = (j + direction + this.keyframes()) %
                                                                  this.keyframes(), cnt++)
            {
                SpriterKeyFrame frame    = this.frames[j];
                bool            contains = (isBone) ? frame.containsBone((SpriterBone
                                                                          )@object) : frame.containsObject((SpriterObject)
                                                                                                           @object);
                if (contains)
                {
                    SpriterAbstractObject objectInFrame;
                    if (isBone)
                    {
                        objectInFrame = frame.getBoneFor((SpriterBone)@object);
                    }
                    else
                    {
                        objectInFrame = frame.getObjectFor((SpriterObject)@object);
                    }
                    if (@object.equals(objectInFrame))
                    {
                        nextFrame = frame;
                    }
                }
            }
            return(nextFrame);
        }