public static (RailTrack, double, bool) GetAheadTrack(this RailTrack current, double currentCarSpan, bool direction, double aheadDistance)
        {
            aheadDistance -= direction ? current.logicTrack.length - currentCarSpan : currentCarSpan;

            while (aheadDistance >= 0.0f)
            {
                RailTrack nextTrack = current.GetNextTrack(direction);

                if (nextTrack == null)
                {
                    break;
                }

                direction = nextTrack.GetDirectionFromPrev(current);

                current = nextTrack;

                aheadDistance -= current.logicTrack.length;
            }

            double span = direction ? current.logicTrack.length + aheadDistance : -aheadDistance;

            if (span > current.logicTrack.length)
            {
                span = current.logicTrack.length;
            }

            return(current, span, direction);
        }