mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 00:53:19 +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 start_time = 500;
|
||||||
const double duration = 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,
|
TimingPoint = { BeatLength = 1000 }
|
||||||
Time = time
|
|
||||||
}, gravity ? ScrollingAlgorithm.Gravity : ScrollingAlgorithm.Basic);
|
}, gravity ? ScrollingAlgorithm.Gravity : ScrollingAlgorithm.Basic);
|
||||||
|
|
||||||
Action<bool> createPlayfieldWithNotes = gravity =>
|
Action<bool> createPlayfieldWithNotes = gravity =>
|
||||||
|
@ -42,10 +42,9 @@ namespace osu.Game.Rulesets.Mania.Mods
|
|||||||
if (maniaObject == null)
|
if (maniaObject == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column].Add(new ManiaSpeedAdjustmentContainer(new SpeedAdjustment
|
maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column].Add(new ManiaSpeedAdjustmentContainer(new MultiplierControlPoint(obj.StartTime)
|
||||||
{
|
{
|
||||||
Time = obj.StartTime,
|
TimingPoint = { BeatLength = 1000 }
|
||||||
BeatLength = 1000
|
|
||||||
}, ScrollingAlgorithm.Gravity));
|
}, 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)
|
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,
|
TimingPoint = { BeatLength = 1000 }
|
||||||
BeatLength = 1000
|
|
||||||
}, ScrollingAlgorithm.Gravity));
|
}, ScrollingAlgorithm.Gravity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
{
|
{
|
||||||
internal class BasicScrollingDrawableTimingSection : DrawableTimingSection
|
internal class BasicScrollingDrawableTimingSection : DrawableTimingSection
|
||||||
{
|
{
|
||||||
private readonly SpeedAdjustment timingSection;
|
private readonly MultiplierControlPoint timingSection;
|
||||||
|
|
||||||
public BasicScrollingDrawableTimingSection(SpeedAdjustment timingSection)
|
public BasicScrollingDrawableTimingSection(MultiplierControlPoint timingSection)
|
||||||
: base(Axes.Y)
|
: base(Axes.Y)
|
||||||
{
|
{
|
||||||
this.timingSection = timingSection;
|
this.timingSection = timingSection;
|
||||||
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
{
|
{
|
||||||
base.Update();
|
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
|
internal class GravityScrollingDrawableTimingSection : DrawableTimingSection
|
||||||
{
|
{
|
||||||
private readonly SpeedAdjustment timingSection;
|
private readonly MultiplierControlPoint timingSection;
|
||||||
|
|
||||||
public GravityScrollingDrawableTimingSection(SpeedAdjustment timingSection)
|
public GravityScrollingDrawableTimingSection(MultiplierControlPoint timingSection)
|
||||||
: base(Axes.Y)
|
: base(Axes.Y)
|
||||||
{
|
{
|
||||||
this.timingSection = timingSection;
|
this.timingSection = timingSection;
|
||||||
@ -22,9 +22,9 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
// The gravity-adjusted start position
|
// The gravity-adjusted start position
|
||||||
float startPos = (float)computeGravityTime(timingSection.Time);
|
float startPos = (float)computeGravityTime(timingSection.StartTime);
|
||||||
// The gravity-adjusted end position
|
// The gravity-adjusted end position
|
||||||
float endPos = (float)computeGravityTime(timingSection.Time + RelativeChildSize.Y);
|
float endPos = (float)computeGravityTime(timingSection.StartTime + RelativeChildSize.Y);
|
||||||
|
|
||||||
Y = startPos;
|
Y = startPos;
|
||||||
Height = endPos - startPos;
|
Height = endPos - startPos;
|
||||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
{
|
{
|
||||||
private readonly ScrollingAlgorithm scrollingAlgorithm;
|
private readonly ScrollingAlgorithm scrollingAlgorithm;
|
||||||
|
|
||||||
public ManiaSpeedAdjustmentContainer(SpeedAdjustment timingSection, ScrollingAlgorithm scrollingAlgorithm)
|
public ManiaSpeedAdjustmentContainer(MultiplierControlPoint timingSection, ScrollingAlgorithm scrollingAlgorithm)
|
||||||
: base(timingSection, Axes.Y)
|
: base(timingSection, Axes.Y)
|
||||||
{
|
{
|
||||||
this.scrollingAlgorithm = scrollingAlgorithm;
|
this.scrollingAlgorithm = scrollingAlgorithm;
|
||||||
@ -27,8 +27,8 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// This is very naive and can be improved, but is adequate for now
|
// This is very naive and can be improved, but is adequate for now
|
||||||
LifetimeStart = TimingSection.Time - VisibleTimeRange;
|
LifetimeStart = MultiplierControlPoint.StartTime - VisibleTimeRange;
|
||||||
LifetimeEnd = TimingSection.Time + Content.Height * 2;
|
LifetimeEnd = MultiplierControlPoint.StartTime + Content.Height * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DrawableTimingSection CreateTimingSection()
|
protected override DrawableTimingSection CreateTimingSection()
|
||||||
@ -37,9 +37,9 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ScrollingAlgorithm.Basic:
|
case ScrollingAlgorithm.Basic:
|
||||||
return new BasicScrollingDrawableTimingSection(TimingSection);
|
return new BasicScrollingDrawableTimingSection(MultiplierControlPoint);
|
||||||
case ScrollingAlgorithm.Gravity:
|
case ScrollingAlgorithm.Gravity:
|
||||||
return new GravityScrollingDrawableTimingSection(TimingSection);
|
return new GravityScrollingDrawableTimingSection(MultiplierControlPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,11 +90,10 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
if (difficultyPoint != null)
|
if (difficultyPoint != null)
|
||||||
lastSpeedMultiplier = difficultyPoint.SpeedMultiplier;
|
lastSpeedMultiplier = difficultyPoint.SpeedMultiplier;
|
||||||
|
|
||||||
return new SpeedAdjustment
|
return new MultiplierControlPoint(c.Time)
|
||||||
{
|
{
|
||||||
Time = c.Time,
|
TimingPoint = { BeatLength = lastBeatLength },
|
||||||
BeatLength = lastBeatLength,
|
DifficultyPoint = { SpeedMultiplier = lastSpeedMultiplier }
|
||||||
SpeedMultiplier = lastSpeedMultiplier
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -103,11 +102,11 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
// Perform some post processing of the timing changes
|
// Perform some post processing of the timing changes
|
||||||
timingChanges = timingChanges
|
timingChanges = timingChanges
|
||||||
// Collapse sections after the last hit object
|
// Collapse sections after the last hit object
|
||||||
.Where(s => s.Time <= lastObjectTime)
|
.Where(s => s.StartTime <= lastObjectTime)
|
||||||
// Collapse sections with the same start time
|
// 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
|
// 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();
|
.ToList();
|
||||||
|
|
||||||
timingChanges.ForEach(t =>
|
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;
|
var timingChangeY = y as SpeedAdjustmentContainer;
|
||||||
|
|
||||||
// If either of the two drawables are not hit objects, fall back to the base comparer
|
// 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);
|
return base.Compare(x, y);
|
||||||
|
|
||||||
// Compare by start time
|
// 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);
|
return i != 0 ? i : base.Compare(x, y);
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ using OpenTK;
|
|||||||
namespace osu.Game.Rulesets.Timing
|
namespace osu.Game.Rulesets.Timing
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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"/>
|
/// A container for hit objects which applies applies the speed adjustments defined by the <see cref="Timing.MultiplierControlPoint"/> properties
|
||||||
/// properties to its <see cref="Container{T}.Content"/> to affect the <see cref="Drawables.DrawableTimingSection"/> scroll speed.
|
/// to its <see cref="Container{T}.Content"/> to affect the <see cref="DrawableTimingSection"/> scroll speed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class SpeedAdjustmentContainer : Container<DrawableHitObject>
|
public abstract class SpeedAdjustmentContainer : Container<DrawableHitObject>
|
||||||
{
|
{
|
||||||
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
set { visibleTimeRange.BindTo(value); }
|
set { visibleTimeRange.BindTo(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly SpeedAdjustment TimingSection;
|
public readonly MultiplierControlPoint MultiplierControlPoint;
|
||||||
|
|
||||||
protected override Container<DrawableHitObject> Content => content;
|
protected override Container<DrawableHitObject> Content => content;
|
||||||
private Container<DrawableHitObject> content;
|
private Container<DrawableHitObject> content;
|
||||||
@ -35,13 +35,13 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="SpeedAdjustmentContainer"/>.
|
/// Creates a new <see cref="SpeedAdjustmentContainer"/>.
|
||||||
/// </summary>
|
/// </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>
|
/// <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;
|
this.scrollingAxes = scrollingAxes;
|
||||||
|
|
||||||
TimingSection = timingSection;
|
MultiplierControlPoint = multiplierControlPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
DrawableTimingSection timingSection = CreateTimingSection();
|
DrawableTimingSection timingSection = CreateTimingSection();
|
||||||
|
|
||||||
timingSection.VisibleTimeRange.BindTo(VisibleTimeRange);
|
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);
|
AddInternal(content = timingSection);
|
||||||
}
|
}
|
||||||
@ -63,17 +63,17 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
|
|
||||||
protected override void Update()
|
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
|
// 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 ? speedAdjustedSize : 1, (scrollingAxes & Axes.Y) > 0 ? speedAdjustedSize : 1);
|
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);
|
RelativeChildSize = new Vector2((scrollingAxes & Axes.X) > 0 ? (float)VisibleTimeRange : 1, (scrollingAxes & Axes.Y) > 0 ? (float)VisibleTimeRange : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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.
|
/// 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>
|
/// </summary>
|
||||||
public bool CanContain(DrawableHitObject hitObject) => TimingSection.Time <= hitObject.HitObject.StartTime;
|
public bool CanContain(DrawableHitObject hitObject) => MultiplierControlPoint.StartTime <= hitObject.HitObject.StartTime;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the container which handles the movement of a collection of hit objects.
|
/// 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\Scoring\ScoreProcessor.cs" />
|
||||||
<Compile Include="Rulesets\Timing\SpeedAdjustmentContainer.cs" />
|
<Compile Include="Rulesets\Timing\SpeedAdjustmentContainer.cs" />
|
||||||
<Compile Include="Rulesets\Timing\DrawableTimingSection.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="Rulesets\Timing\SpeedAdjustmentCollection.cs" />
|
||||||
<Compile Include="Screens\Menu\MenuSideFlashes.cs" />
|
<Compile Include="Screens\Menu\MenuSideFlashes.cs" />
|
||||||
<Compile Include="Screens\Play\HUD\HealthDisplay.cs" />
|
<Compile Include="Screens\Play\HUD\HealthDisplay.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user