mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 19:12:56 +08:00
Fix multiple invocations by using a separate variable
This commit is contained in:
parent
fdc6a3958d
commit
38a2b9d92b
@ -11,7 +11,6 @@ using osu.Game.Rulesets.Objects.Types;
|
|||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Game.Rulesets.Catch.MathUtils;
|
using osu.Game.Rulesets.Catch.MathUtils;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Beatmaps
|
namespace osu.Game.Rulesets.Catch.Beatmaps
|
||||||
{
|
{
|
||||||
@ -50,8 +49,10 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
|||||||
float? lastPosition = null;
|
float? lastPosition = null;
|
||||||
double lastStartTime = 0;
|
double lastStartTime = 0;
|
||||||
|
|
||||||
foreach (var obj in beatmap.HitObjects)
|
foreach (var obj in beatmap.HitObjects.OfType<CatchHitObject>())
|
||||||
{
|
{
|
||||||
|
obj.XOffset = 0;
|
||||||
|
|
||||||
switch (obj)
|
switch (obj)
|
||||||
{
|
{
|
||||||
case Fruit fruit:
|
case Fruit fruit:
|
||||||
@ -62,7 +63,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
|||||||
case BananaShower bananaShower:
|
case BananaShower bananaShower:
|
||||||
foreach (var banana in bananaShower.NestedHitObjects.OfType<Banana>())
|
foreach (var banana in bananaShower.NestedHitObjects.OfType<Banana>())
|
||||||
{
|
{
|
||||||
banana.X = (float)rng.NextDouble();
|
banana.XOffset = (float)rng.NextDouble();
|
||||||
rng.Next(); // osu!stable retrieved a random banana type
|
rng.Next(); // osu!stable retrieved a random banana type
|
||||||
rng.Next(); // osu!stable retrieved a random banana rotation
|
rng.Next(); // osu!stable retrieved a random banana rotation
|
||||||
rng.Next(); // osu!stable retrieved a random banana colour
|
rng.Next(); // osu!stable retrieved a random banana colour
|
||||||
@ -75,10 +76,9 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
|||||||
{
|
{
|
||||||
var hitObject = (CatchHitObject)nested;
|
var hitObject = (CatchHitObject)nested;
|
||||||
if (hitObject is TinyDroplet)
|
if (hitObject is TinyDroplet)
|
||||||
hitObject.X += rng.Next(-20, 20) / CatchPlayfield.BASE_WIDTH;
|
hitObject.XOffset = MathHelper.Clamp(rng.Next(-20, 20) / CatchPlayfield.BASE_WIDTH, -hitObject.X, 1 - hitObject.X);
|
||||||
else if (hitObject is Droplet)
|
else if (hitObject is Droplet)
|
||||||
rng.Next(); // osu!stable retrieved a random droplet rotation
|
rng.Next(); // osu!stable retrieved a random droplet rotation
|
||||||
hitObject.X = MathHelper.Clamp(hitObject.X, 0, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyHardRockOffset(HitObject hitObject, ref float? lastPosition, ref double lastStartTime, FastRandom rng)
|
private static void applyHardRockOffset(CatchHitObject hitObject, ref float? lastPosition, ref double lastStartTime, FastRandom rng)
|
||||||
{
|
{
|
||||||
if (hitObject is JuiceStream stream)
|
if (hitObject is JuiceStream stream)
|
||||||
{
|
{
|
||||||
@ -98,42 +98,40 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
|||||||
if (!(hitObject is Fruit))
|
if (!(hitObject is Fruit))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var catchObject = (CatchHitObject)hitObject;
|
float offsetPosition = hitObject.X;
|
||||||
|
|
||||||
float position = catchObject.X;
|
|
||||||
double startTime = hitObject.StartTime;
|
double startTime = hitObject.StartTime;
|
||||||
|
|
||||||
if (lastPosition == null)
|
if (lastPosition == null)
|
||||||
{
|
{
|
||||||
lastPosition = position;
|
lastPosition = offsetPosition;
|
||||||
lastStartTime = startTime;
|
lastStartTime = startTime;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float positionDiff = position - lastPosition.Value;
|
float positionDiff = offsetPosition - lastPosition.Value;
|
||||||
double timeDiff = startTime - lastStartTime;
|
double timeDiff = startTime - lastStartTime;
|
||||||
|
|
||||||
if (timeDiff > 1000)
|
if (timeDiff > 1000)
|
||||||
{
|
{
|
||||||
lastPosition = position;
|
lastPosition = offsetPosition;
|
||||||
lastStartTime = startTime;
|
lastStartTime = startTime;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (positionDiff == 0)
|
if (positionDiff == 0)
|
||||||
{
|
{
|
||||||
applyRandomOffset(ref position, timeDiff / 4d, rng);
|
applyRandomOffset(ref offsetPosition, timeDiff / 4d, rng);
|
||||||
catchObject.X = position;
|
hitObject.XOffset = hitObject.X - offsetPosition;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.Abs(positionDiff * CatchPlayfield.BASE_WIDTH) < timeDiff / 3d)
|
if (Math.Abs(positionDiff * CatchPlayfield.BASE_WIDTH) < timeDiff / 3d)
|
||||||
applyOffset(ref position, positionDiff);
|
applyOffset(ref offsetPosition, positionDiff);
|
||||||
|
|
||||||
catchObject.X = position;
|
hitObject.XOffset = hitObject.X - offsetPosition;
|
||||||
|
|
||||||
lastPosition = position;
|
lastPosition = offsetPosition;
|
||||||
lastStartTime = startTime;
|
lastStartTime = startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
|
||||||
@ -12,7 +13,18 @@ namespace osu.Game.Rulesets.Catch.Objects
|
|||||||
{
|
{
|
||||||
public const double OBJECT_RADIUS = 44;
|
public const double OBJECT_RADIUS = 44;
|
||||||
|
|
||||||
public float X { get; set; }
|
private float x;
|
||||||
|
|
||||||
|
public float X
|
||||||
|
{
|
||||||
|
get => x + XOffset;
|
||||||
|
set => x = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A random offset applied to <see cref="X"/>, set by the <see cref="CatchBeatmapProcessor"/>.
|
||||||
|
/// </summary>
|
||||||
|
internal float XOffset { get; set; }
|
||||||
|
|
||||||
public double TimePreempt = 1000;
|
public double TimePreempt = 1000;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user