<commit_before>// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

namespace osu.Game.Rulesets.Mania.Timing.Drawables
{
    public class DrawableGravityTimingChange : DrawableManiaTimingChange
    {
        public DrawableGravityTimingChange(TimingChange timingChange)
            : base(timingChange)
        {
        }

        protected override void Update()
        {
            base.Update();

            // The gravity-adjusted start position
            float startY = (float)computeGravityTime(TimingChange.Time);
            // The gravity-adjusted end position
            float endY = (float)computeGravityTime(TimingChange.Time + Content.RelativeCoordinateSpace.Y);

            Content.Y = startY;
            Content.Height = endY - startY;
        }

        /// <summary>
        /// Applies gravity to a time value based on the current time.
        /// </summary>
        /// <param name="time">The time value gravity should be applied to.</param>
        /// <returns>The time after gravity is applied to <paramref name="time"/>.</returns>
        private double computeGravityTime(double time)
        {
            double relativeTime = relativeTimeAt(time);

            // The sign of the relative time, this is used to apply backwards acceleration leading into startTime
            double sign = relativeTime < 0 ? -1 : 1;

            return timeSpan - acceleration * relativeTime * relativeTime * sign;
        }

        /// <summary>
        /// The time spanned by this container.
        /// </summary>
        private double timeSpan => RelativeCoordinateSpace.Y;

        /// <summary>
        /// The acceleration due to "gravity" of the content of this container.
        /// </summary>
        private double acceleration => timeSpan / travelTime / travelTime;

        /// <summary>
        /// The travel time, after beat length adjustments.
        /// </summary>
        private double travelTime => timeSpan / TimingChange.SpeedMultiplier;

        /// <summary>
        /// Computes the current time relative to <paramref name="time"/>, accounting for <see cref="travelTime"/>.
        /// </summary>
        /// <param name="time">The non-offset time.</param>
        /// <returns>The current time relative to <paramref name="time"/> - <see cref="travelTime"/>. </returns>
        private double relativeTimeAt(double time) => Time.Current - time + travelTime;
    }
}<commit_msg>Simplify gravity.<commit_after>// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

namespace osu.Game.Rulesets.Mania.Timing.Drawables
{
    public class DrawableGravityTimingChange : DrawableManiaTimingChange
    {
        public DrawableGravityTimingChange(TimingChange timingChange)
            : base(timingChange)
        {
        }

        protected override void Update()
        {
            base.Update();

            // The gravity-adjusted start position
            float startY = (float)computeGravityTime(TimingChange.Time);
            // The gravity-adjusted end position
            float endY = (float)computeGravityTime(TimingChange.Time + Content.RelativeCoordinateSpace.Y);

            Content.Y = startY;
            Content.Height = endY - startY;
        }

        /// <summary>
        /// Applies gravity to a time value based on the current time.
        /// </summary>
        /// <param name="time">The time value gravity should be applied to.</param>
        /// <returns>The time after gravity is applied to <paramref name="time"/>.</returns>
        private double computeGravityTime(double time)
        {
            double relativeTime = relativeTimeAt(time);

            // The sign of the relative time, this is used to apply backwards acceleration leading into startTime
            double sign = relativeTime < 0 ? -1 : 1;

            return timeSpan - acceleration * relativeTime * relativeTime * sign;
        }

        /// <summary>
        /// The time spanned by this container.
        /// </summary>
        private double timeSpan => RelativeCoordinateSpace.Y;

        /// <summary>
        /// The acceleration due to "gravity" of the content of this container.
        /// </summary>
        private double acceleration => 1 / timeSpan;

        /// <summary>
        /// Computes the current time relative to <paramref name="time"/>, accounting for <see cref="travelTime"/>.
        /// </summary>
        /// <param name="time">The non-offset time.</param>
        /// <returns>The current time relative to <paramref name="time"/> - <see cref="travelTime"/>. </returns>
        private double relativeTimeAt(double time) => Time.Current - time + timeSpan;
    }
}
{'fraction_non_alphanumeric': 0.11026065370293753, 'fraction_numerical': 0.004757964418700869, 'mean_word_length': 2.129449838187702, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 58, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6441478', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1205, 'n_words': 376}