mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 18:32:55 +08:00
Rename SpeedAdjustment -> MultiplierControlPoint + reworking.
This commit is contained in:
parent
4b2669e65d
commit
921350128d
@ -44,10 +44,9 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
const double start_time = 500;
|
||||
const double duration = 500;
|
||||
|
||||
Func<double, bool, SpeedAdjustmentContainer> createTimingChange = (time, gravity) => new ManiaSpeedAdjustmentContainer(new SpeedAdjustment
|
||||
Func<double, bool, SpeedAdjustmentContainer> createTimingChange = (time, gravity) => new ManiaSpeedAdjustmentContainer(new MultiplierControlPoint(time)
|
||||
{
|
||||
BeatLength = 1000,
|
||||
Time = time
|
||||
TimingPoint = { BeatLength = 1000 }
|
||||
}, gravity ? ScrollingAlgorithm.Gravity : ScrollingAlgorithm.Basic);
|
||||
|
||||
Action<bool> createPlayfieldWithNotes = gravity =>
|
||||
|
@ -42,10 +42,9 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
if (maniaObject == null)
|
||||
continue;
|
||||
|
||||
maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column].Add(new ManiaSpeedAdjustmentContainer(new SpeedAdjustment
|
||||
maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column].Add(new ManiaSpeedAdjustmentContainer(new MultiplierControlPoint(obj.StartTime)
|
||||
{
|
||||
Time = obj.StartTime,
|
||||
BeatLength = 1000
|
||||
TimingPoint = { BeatLength = 1000 }
|
||||
}, ScrollingAlgorithm.Gravity));
|
||||
}
|
||||
|
||||
@ -61,10 +60,9 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
|
||||
for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength)
|
||||
{
|
||||
maniaHitRenderer.BarlineTimingChanges.Add(new ManiaSpeedAdjustmentContainer(new SpeedAdjustment
|
||||
maniaHitRenderer.BarlineTimingChanges.Add(new ManiaSpeedAdjustmentContainer(new MultiplierControlPoint(t)
|
||||
{
|
||||
Time = t,
|
||||
BeatLength = 1000
|
||||
TimingPoint = { BeatLength = 1000 }
|
||||
}, ScrollingAlgorithm.Gravity));
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ namespace osu.Game.Rulesets.Mania.Timing
|
||||
{
|
||||
internal class BasicScrollingDrawableTimingSection : DrawableTimingSection
|
||||
{
|
||||
private readonly SpeedAdjustment timingSection;
|
||||
private readonly MultiplierControlPoint timingSection;
|
||||
|
||||
public BasicScrollingDrawableTimingSection(SpeedAdjustment timingSection)
|
||||
public BasicScrollingDrawableTimingSection(MultiplierControlPoint timingSection)
|
||||
: base(Axes.Y)
|
||||
{
|
||||
this.timingSection = timingSection;
|
||||
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Timing
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Y = (float)(timingSection.Time - Time.Current);
|
||||
Y = (float)(timingSection.StartTime - Time.Current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ namespace osu.Game.Rulesets.Mania.Timing
|
||||
{
|
||||
internal class GravityScrollingDrawableTimingSection : DrawableTimingSection
|
||||
{
|
||||
private readonly SpeedAdjustment timingSection;
|
||||
private readonly MultiplierControlPoint timingSection;
|
||||
|
||||
public GravityScrollingDrawableTimingSection(SpeedAdjustment timingSection)
|
||||
public GravityScrollingDrawableTimingSection(MultiplierControlPoint timingSection)
|
||||
: base(Axes.Y)
|
||||
{
|
||||
this.timingSection = timingSection;
|
||||
@ -22,9 +22,9 @@ namespace osu.Game.Rulesets.Mania.Timing
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
// The gravity-adjusted start position
|
||||
float startPos = (float)computeGravityTime(timingSection.Time);
|
||||
float startPos = (float)computeGravityTime(timingSection.StartTime);
|
||||
// The gravity-adjusted end position
|
||||
float endPos = (float)computeGravityTime(timingSection.Time + RelativeChildSize.Y);
|
||||
float endPos = (float)computeGravityTime(timingSection.StartTime + RelativeChildSize.Y);
|
||||
|
||||
Y = startPos;
|
||||
Height = endPos - startPos;
|
||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mania.Timing
|
||||
{
|
||||
private readonly ScrollingAlgorithm scrollingAlgorithm;
|
||||
|
||||
public ManiaSpeedAdjustmentContainer(SpeedAdjustment timingSection, ScrollingAlgorithm scrollingAlgorithm)
|
||||
public ManiaSpeedAdjustmentContainer(MultiplierControlPoint timingSection, ScrollingAlgorithm scrollingAlgorithm)
|
||||
: base(timingSection, Axes.Y)
|
||||
{
|
||||
this.scrollingAlgorithm = scrollingAlgorithm;
|
||||
@ -27,8 +27,8 @@ namespace osu.Game.Rulesets.Mania.Timing
|
||||
return;
|
||||
|
||||
// This is very naive and can be improved, but is adequate for now
|
||||
LifetimeStart = TimingSection.Time - VisibleTimeRange;
|
||||
LifetimeEnd = TimingSection.Time + Content.Height * 2;
|
||||
LifetimeStart = MultiplierControlPoint.StartTime - VisibleTimeRange;
|
||||
LifetimeEnd = MultiplierControlPoint.StartTime + Content.Height * 2;
|
||||
}
|
||||
|
||||
protected override DrawableTimingSection CreateTimingSection()
|
||||
@ -37,9 +37,9 @@ namespace osu.Game.Rulesets.Mania.Timing
|
||||
{
|
||||
default:
|
||||
case ScrollingAlgorithm.Basic:
|
||||
return new BasicScrollingDrawableTimingSection(TimingSection);
|
||||
return new BasicScrollingDrawableTimingSection(MultiplierControlPoint);
|
||||
case ScrollingAlgorithm.Gravity:
|
||||
return new GravityScrollingDrawableTimingSection(TimingSection);
|
||||
return new GravityScrollingDrawableTimingSection(MultiplierControlPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,11 +90,10 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
if (difficultyPoint != null)
|
||||
lastSpeedMultiplier = difficultyPoint.SpeedMultiplier;
|
||||
|
||||
return new SpeedAdjustment
|
||||
return new MultiplierControlPoint(c.Time)
|
||||
{
|
||||
Time = c.Time,
|
||||
BeatLength = lastBeatLength,
|
||||
SpeedMultiplier = lastSpeedMultiplier
|
||||
TimingPoint = { BeatLength = lastBeatLength },
|
||||
DifficultyPoint = { SpeedMultiplier = lastSpeedMultiplier }
|
||||
};
|
||||
});
|
||||
|
||||
@ -103,11 +102,11 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
// Perform some post processing of the timing changes
|
||||
timingChanges = timingChanges
|
||||
// Collapse sections after the last hit object
|
||||
.Where(s => s.Time <= lastObjectTime)
|
||||
.Where(s => s.StartTime <= lastObjectTime)
|
||||
// Collapse sections with the same start time
|
||||
.GroupBy(s => s.Time).Select(g => g.Last()).OrderBy(s => s.Time)
|
||||
.GroupBy(s => s.StartTime).Select(g => g.Last()).OrderBy(s => s.StartTime)
|
||||
// Collapse sections with the same beat length
|
||||
.GroupBy(s => s.BeatLength * s.SpeedMultiplier).Select(g => g.First())
|
||||
.GroupBy(s => s.TimingPoint.BeatLength * s.DifficultyPoint.SpeedMultiplier).Select(g => g.First())
|
||||
.ToList();
|
||||
|
||||
timingChanges.ForEach(t =>
|
||||
|
28
osu.Game/Rulesets/Timing/MultiplierControlPoint.cs
Normal file
28
osu.Game/Rulesets/Timing/MultiplierControlPoint.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
|
||||
namespace osu.Game.Rulesets.Timing
|
||||
{
|
||||
public class MultiplierControlPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// The time in milliseconds at which this control point starts.
|
||||
/// </summary>
|
||||
public readonly double StartTime;
|
||||
|
||||
/// <summary>
|
||||
/// The multiplier which this control point provides.
|
||||
/// </summary>
|
||||
public double Multiplier => 1000 / TimingPoint.BeatLength / DifficultyPoint.SpeedMultiplier;
|
||||
|
||||
public TimingControlPoint TimingPoint = new TimingControlPoint();
|
||||
public DifficultyControlPoint DifficultyPoint = new DifficultyControlPoint();
|
||||
|
||||
public MultiplierControlPoint(double startTime)
|
||||
{
|
||||
StartTime = startTime;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Rulesets.Timing
|
||||
{
|
||||
public class SpeedAdjustment
|
||||
{
|
||||
/// <summary>
|
||||
/// The time in milliseconds at which this timing section starts.
|
||||
/// </summary>
|
||||
public double Time;
|
||||
|
||||
/// <summary>
|
||||
/// The length of one beat in milliseconds.
|
||||
/// </summary>
|
||||
public double BeatLength = 500;
|
||||
|
||||
/// <summary>
|
||||
/// An arbitrary speed multiplier which should be used to when adjusting the visual representation of entities represented by this section.
|
||||
/// This is usually applied in adition to a multiplier based on the <see cref="BeatLength"/> relative to a constant.
|
||||
/// </summary>
|
||||
public double SpeedMultiplier = 1;
|
||||
}
|
||||
}
|
@ -73,11 +73,11 @@ namespace osu.Game.Rulesets.Timing
|
||||
var timingChangeY = y as SpeedAdjustmentContainer;
|
||||
|
||||
// If either of the two drawables are not hit objects, fall back to the base comparer
|
||||
if (timingChangeX?.TimingSection == null || timingChangeY?.TimingSection == null)
|
||||
if (timingChangeX?.MultiplierControlPoint == null || timingChangeY?.MultiplierControlPoint == null)
|
||||
return base.Compare(x, y);
|
||||
|
||||
// Compare by start time
|
||||
int i = timingChangeY.TimingSection.Time.CompareTo(timingChangeX.TimingSection.Time);
|
||||
int i = timingChangeY.MultiplierControlPoint.StartTime.CompareTo(timingChangeX.MultiplierControlPoint.StartTime);
|
||||
|
||||
return i != 0 ? i : base.Compare(x, y);
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ using OpenTK;
|
||||
namespace osu.Game.Rulesets.Timing
|
||||
{
|
||||
/// <summary>
|
||||
/// A container for hit objects which applies applies the speed changes defined by the <see cref="Timing.SpeedAdjustment.BeatLength"/> and <see cref="Timing.SpeedAdjustment.SpeedMultiplier"/>
|
||||
/// properties to its <see cref="Container{T}.Content"/> to affect the <see cref="Drawables.DrawableTimingSection"/> scroll speed.
|
||||
/// A container for hit objects which applies applies the speed adjustments defined by the <see cref="Timing.MultiplierControlPoint"/> properties
|
||||
/// to its <see cref="Container{T}.Content"/> to affect the <see cref="DrawableTimingSection"/> scroll speed.
|
||||
/// </summary>
|
||||
public abstract class SpeedAdjustmentContainer : Container<DrawableHitObject>
|
||||
{
|
||||
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Timing
|
||||
set { visibleTimeRange.BindTo(value); }
|
||||
}
|
||||
|
||||
public readonly SpeedAdjustment TimingSection;
|
||||
public readonly MultiplierControlPoint MultiplierControlPoint;
|
||||
|
||||
protected override Container<DrawableHitObject> Content => content;
|
||||
private Container<DrawableHitObject> content;
|
||||
@ -35,13 +35,13 @@ namespace osu.Game.Rulesets.Timing
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="SpeedAdjustmentContainer"/>.
|
||||
/// </summary>
|
||||
/// <param name="timingSection">The encapsulated timing section that provides the speed changes.</param>
|
||||
/// <param name="multiplierControlPoint">The multiplier control point that provides the speed adjustments for this container.</param>
|
||||
/// <param name="scrollingAxes">The axes through which this drawable timing section scrolls through.</param>
|
||||
protected SpeedAdjustmentContainer(SpeedAdjustment timingSection, Axes scrollingAxes)
|
||||
protected SpeedAdjustmentContainer(MultiplierControlPoint multiplierControlPoint, Axes scrollingAxes)
|
||||
{
|
||||
this.scrollingAxes = scrollingAxes;
|
||||
|
||||
TimingSection = timingSection;
|
||||
MultiplierControlPoint = multiplierControlPoint;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Timing
|
||||
DrawableTimingSection timingSection = CreateTimingSection();
|
||||
|
||||
timingSection.VisibleTimeRange.BindTo(VisibleTimeRange);
|
||||
timingSection.RelativeChildOffset = new Vector2((scrollingAxes & Axes.X) > 0 ? (float)TimingSection.Time : 0, (scrollingAxes & Axes.Y) > 0 ? (float)TimingSection.Time : 0);
|
||||
timingSection.RelativeChildOffset = new Vector2((scrollingAxes & Axes.X) > 0 ? (float)MultiplierControlPoint.StartTime : 0, (scrollingAxes & Axes.Y) > 0 ? (float)MultiplierControlPoint.StartTime : 0);
|
||||
|
||||
AddInternal(content = timingSection);
|
||||
}
|
||||
@ -63,17 +63,17 @@ namespace osu.Game.Rulesets.Timing
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
float speedAdjustedSize = (float)(1000 / TimingSection.BeatLength / TimingSection.SpeedMultiplier);
|
||||
float multiplier = (float)MultiplierControlPoint.Multiplier;
|
||||
|
||||
// The speed adjustment happens by modifying our size while maintaining the visible time range as the relatve size for our children
|
||||
Size = new Vector2((scrollingAxes & Axes.X) > 0 ? speedAdjustedSize : 1, (scrollingAxes & Axes.Y) > 0 ? speedAdjustedSize : 1);
|
||||
// The speed adjustment happens by modifying our size by the multiplier while maintaining the visible time range as the relatve size for our children
|
||||
Size = new Vector2((scrollingAxes & Axes.X) > 0 ? multiplier : 1, (scrollingAxes & Axes.Y) > 0 ? multiplier : 1);
|
||||
RelativeChildSize = new Vector2((scrollingAxes & Axes.X) > 0 ? (float)VisibleTimeRange : 1, (scrollingAxes & Axes.Y) > 0 ? (float)VisibleTimeRange : 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether this speed adjustment can contain a hit object. This is true if the hit object occurs after this speed adjustment with respect to time.
|
||||
/// </summary>
|
||||
public bool CanContain(DrawableHitObject hitObject) => TimingSection.Time <= hitObject.HitObject.StartTime;
|
||||
public bool CanContain(DrawableHitObject hitObject) => MultiplierControlPoint.StartTime <= hitObject.HitObject.StartTime;
|
||||
|
||||
/// <summary>
|
||||
/// Creates the container which handles the movement of a collection of hit objects.
|
||||
|
@ -197,7 +197,7 @@
|
||||
<Compile Include="Rulesets\Scoring\ScoreProcessor.cs" />
|
||||
<Compile Include="Rulesets\Timing\SpeedAdjustmentContainer.cs" />
|
||||
<Compile Include="Rulesets\Timing\DrawableTimingSection.cs" />
|
||||
<Compile Include="Rulesets\Timing\SpeedAdjustment.cs" />
|
||||
<Compile Include="Rulesets\Timing\MultiplierControlPoint.cs" />
|
||||
<Compile Include="Rulesets\Timing\SpeedAdjustmentCollection.cs" />
|
||||
<Compile Include="Screens\Menu\MenuSideFlashes.cs" />
|
||||
<Compile Include="Screens\Play\HUD\HealthDisplay.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user