mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Introduce RandomSeed in catch DHO
This commit is contained in:
parent
297283491a
commit
e7c0e9834f
@ -3,10 +3,13 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
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;
|
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)
|
protected DrawableCatchHitObject([CanBeNull] CatchHitObject hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft;
|
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()
|
protected override void OnApply()
|
||||||
{
|
{
|
||||||
base.OnApply();
|
base.OnApply();
|
||||||
|
Loading…
Reference in New Issue
Block a user