From e7c0e9834f41f5f52fb3b331a02c4742c84bf342 Mon Sep 17 00:00:00 2001 From: ekrctb Date: Wed, 2 Dec 2020 16:53:01 +0900 Subject: [PATCH] Introduce RandomSeed in catch DHO --- .../Drawables/DrawableCatchHitObject.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs index 1faa6a5b0f..eb5f9451b1 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs @@ -3,10 +3,13 @@ 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 { @@ -20,12 +23,32 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables protected override float SamplePlaybackPosition => HitObject.X / CatchPlayfield.WIDTH; + /// + /// The seed value used for visual randomness such as fruit rotation. + /// By default, truncated to an integer is used. + /// + public Bindable RandomSeed = new Bindable(); + protected DrawableCatchHitObject([CanBeNull] CatchHitObject hitObject) : base(hitObject) { Anchor = Anchor.BottomLeft; } + [BackgroundDependencyLoader] + private void load() + { + StartTimeBindable.BindValueChanged(change => + { + RandomSeed.Value = (int)change.NewValue; + }, true); + } + + /// + /// Get a random number in range [0,1) based on seed . + /// + public float RandomSingle(int series) => StatelessRNG.NextSingle(RandomSeed.Value, series); + protected override void OnApply() { base.OnApply();