<commit_before>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using JetBrains.Annotations;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects.Drawables;

namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
    public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
    {
        public readonly Bindable<float> XBindable = new Bindable<float>();

        protected override double InitialLifetimeOffset => HitObject.TimePreempt;

        public float DisplayRadius => DrawSize.X / 2 * Scale.X * HitObject.Scale;

        protected override float SamplePlaybackPosition => HitObject.X / CatchPlayfield.WIDTH;

        protected DrawableCatchHitObject([CanBeNull] CatchHitObject hitObject)
            : base(hitObject)
        {
            Anchor = Anchor.BottomLeft;
        }

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

            XBindable.BindTo(HitObject.XBindable);
        }
<commit_msg>Introduce RandomSeed in catch DHO<commit_after>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Utils;

namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
    public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
    {
        public readonly Bindable<float> XBindable = new Bindable<float>();

        protected override double InitialLifetimeOffset => HitObject.TimePreempt;

        public float DisplayRadius => DrawSize.X / 2 * Scale.X * HitObject.Scale;

        protected override float SamplePlaybackPosition => HitObject.X / CatchPlayfield.WIDTH;

        /// <summary>
        /// The seed value used for visual randomness such as fruit rotation.
        /// By default, <see cref="HitObject.StartTime"/> truncated to an integer is used.
        /// </summary>
        public Bindable<int> RandomSeed = new Bindable<int>();

        protected DrawableCatchHitObject([CanBeNull] CatchHitObject hitObject)
            : base(hitObject)
        {
            Anchor = Anchor.BottomLeft;
        }

        [BackgroundDependencyLoader]
        private void load()
        {
            StartTimeBindable.BindValueChanged(change =>
            {
                RandomSeed.Value = (int)change.NewValue;
            }, true);
        }

        /// <summary>
        /// Get a random number in range [0,1) based on seed <see cref="RandomSeed"/>.
        /// </summary>
        public float RandomSingle(int series) => StatelessRNG.NextSingle(RandomSeed.Value, series);

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

            XBindable.BindTo(HitObject.XBindable);
        }

{'fraction_non_alphanumeric': 0.09396825396825396, 'fraction_numerical': 0.0012698412698412698, 'mean_word_length': 2.751190476190476, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 29, 'https://': 0, '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': '1219132', 'n_tokens_mistral': 902, 'n_tokens_neox': 876, 'n_words': 226}