From 8e20f90ed5b836c79e4fd591f6d6a3c5d741d7cc Mon Sep 17 00:00:00 2001 From: ekrctb Date: Fri, 4 Jun 2021 19:54:46 +0900 Subject: [PATCH] Use seeded RNG for catch explosion animation The animation is always the same when a replay is rewound or a beatmap is played multiple times. --- osu.Game.Rulesets.Catch/UI/Catcher.cs | 2 +- osu.Game.Rulesets.Catch/UI/HitExplosion.cs | 9 +++++---- osu.Game.Rulesets.Catch/UI/HitExplosionEntry.cs | 4 +++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/Catcher.cs b/osu.Game.Rulesets.Catch/UI/Catcher.cs index 75ed4c3c0f..1c29e8b20c 100644 --- a/osu.Game.Rulesets.Catch/UI/Catcher.cs +++ b/osu.Game.Rulesets.Catch/UI/Catcher.cs @@ -506,7 +506,7 @@ namespace osu.Game.Rulesets.Catch.UI } private void addLighting(CatchHitObject hitObject, float x, Color4 colour) => - hitExplosionContainer.Add(new HitExplosionEntry(Time.Current, x, hitObject.Scale, colour)); + hitExplosionContainer.Add(new HitExplosionEntry(Time.Current, x, hitObject.Scale, colour, hitObject.RandomSeed)); private CaughtObject getCaughtObject(PalpableCatchHitObject source) { diff --git a/osu.Game.Rulesets.Catch/UI/HitExplosion.cs b/osu.Game.Rulesets.Catch/UI/HitExplosion.cs index c1effa939e..d9ab428231 100644 --- a/osu.Game.Rulesets.Catch/UI/HitExplosion.cs +++ b/osu.Game.Rulesets.Catch/UI/HitExplosion.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; using osu.Framework.Utils; using osu.Game.Rulesets.Objects.Pooling; +using osu.Game.Utils; using osuTK; using osuTK.Graphics; @@ -74,10 +75,10 @@ namespace osu.Game.Rulesets.Catch.UI setColour(entry.ObjectColour); using (BeginAbsoluteSequence(entry.LifetimeStart)) - applyTransforms(); + applyTransforms(entry.RNGSeed); } - private void applyTransforms() + private void applyTransforms(int randomSeed) { ClearTransforms(true); @@ -90,8 +91,8 @@ namespace osu.Game.Rulesets.Catch.UI .FadeOut(duration * 2); const float angle_variangle = 15; // should be less than 45 - directionalGlow1.Rotation = RNG.NextSingle(-angle_variangle, angle_variangle); - directionalGlow2.Rotation = RNG.NextSingle(-angle_variangle, angle_variangle); + directionalGlow1.Rotation = StatelessRNG.NextSingle(-angle_variangle, angle_variangle, randomSeed, 4); + directionalGlow2.Rotation = StatelessRNG.NextSingle(-angle_variangle, angle_variangle, randomSeed, 5); this.FadeInFromZero(50).Then().FadeOut(duration, Easing.Out).Expire(); } diff --git a/osu.Game.Rulesets.Catch/UI/HitExplosionEntry.cs b/osu.Game.Rulesets.Catch/UI/HitExplosionEntry.cs index d0dfdfcafd..b142962a8a 100644 --- a/osu.Game.Rulesets.Catch/UI/HitExplosionEntry.cs +++ b/osu.Game.Rulesets.Catch/UI/HitExplosionEntry.cs @@ -11,13 +11,15 @@ namespace osu.Game.Rulesets.Catch.UI public readonly float Position; public readonly float Scale; public readonly Color4 ObjectColour; + public readonly int RNGSeed; - public HitExplosionEntry(double startTime, float position, float scale, Color4 objectColour) + public HitExplosionEntry(double startTime, float position, float scale, Color4 objectColour, int rngSeed) { LifetimeStart = startTime; Position = position; Scale = scale; ObjectColour = objectColour; + RNGSeed = rngSeed; } } }