mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 10:42:55 +08:00
Rewrite mania to use the new timing section stuff.
This commit is contained in:
parent
1231d5d35e
commit
8de6bdf340
@ -13,8 +13,9 @@ using osu.Framework.Configuration;
|
|||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Game.Rulesets.Mania.Timing.Drawables;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Game.Rulesets.Mania.Timing;
|
||||||
|
using osu.Game.Rulesets.Mania.Timing.Drawables;
|
||||||
using osu.Game.Rulesets.Timing;
|
using osu.Game.Rulesets.Timing;
|
||||||
using osu.Game.Rulesets.Timing.Drawables;
|
using osu.Game.Rulesets.Timing.Drawables;
|
||||||
|
|
||||||
@ -45,23 +46,11 @@ 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, DrawableTimingSection> createTimingChange = (time, gravity) =>
|
Func<double, bool, DrawableTimingSection> createTimingChange = (time, gravity) => new DrawableManiaTimingSection(new TimingSection
|
||||||
{
|
{
|
||||||
if (gravity)
|
BeatLength = 1000,
|
||||||
{
|
Time = time
|
||||||
return new DrawableManiaGravityTimingChange(new TimingSection
|
}, gravity ? ScrollingAlgorithm.Gravity : ScrollingAlgorithm.Basic);
|
||||||
{
|
|
||||||
BeatLength = 1000,
|
|
||||||
Time = time
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return new DrawableManiaScrollingTimingChange(new TimingSection
|
|
||||||
{
|
|
||||||
BeatLength = 1000,
|
|
||||||
Time = time
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Action<bool> createPlayfieldWithNotes = gravity =>
|
Action<bool> createPlayfieldWithNotes = gravity =>
|
||||||
{
|
{
|
||||||
|
@ -6,13 +6,14 @@ using osu.Game.Rulesets.Mania.Objects;
|
|||||||
using osu.Game.Rulesets.Mania.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.Mania.Timing.Drawables;
|
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Lists;
|
using osu.Framework.Lists;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Mania.Timing;
|
||||||
|
using osu.Game.Rulesets.Mania.Timing.Drawables;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Timing;
|
using osu.Game.Rulesets.Timing;
|
||||||
using osu.Game.Rulesets.Timing.Drawables;
|
using osu.Game.Rulesets.Timing.Drawables;
|
||||||
@ -43,11 +44,11 @@ namespace osu.Game.Rulesets.Mania.Mods
|
|||||||
if (maniaObject == null)
|
if (maniaObject == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column].Add(new DrawableManiaGravityTimingChange(new TimingSection
|
maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column].Add(new DrawableManiaTimingSection(new TimingSection
|
||||||
{
|
{
|
||||||
Time = obj.StartTime,
|
Time = obj.StartTime,
|
||||||
BeatLength = 1000
|
BeatLength = 1000
|
||||||
}));
|
}, ScrollingAlgorithm.Gravity));
|
||||||
}
|
}
|
||||||
|
|
||||||
double lastObjectTime = (maniaHitRenderer.Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? maniaHitRenderer.Objects.LastOrDefault()?.StartTime ?? double.MaxValue;
|
double lastObjectTime = (maniaHitRenderer.Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? maniaHitRenderer.Objects.LastOrDefault()?.StartTime ?? double.MaxValue;
|
||||||
@ -62,11 +63,11 @@ 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 DrawableManiaGravityTimingChange(new TimingSection
|
maniaHitRenderer.BarlineTimingChanges.Add(new DrawableManiaTimingSection(new TimingSection
|
||||||
{
|
{
|
||||||
Time = t,
|
Time = t,
|
||||||
BeatLength = 1000
|
BeatLength = 1000
|
||||||
}));
|
}, ScrollingAlgorithm.Gravity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
// 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.Framework.Graphics;
|
||||||
|
using osu.Game.Rulesets.Timing;
|
||||||
|
using osu.Game.Rulesets.Timing.Drawables;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Timing.Drawables
|
||||||
|
{
|
||||||
|
internal class BasicScrollingHitObjectCollection : HitObjectCollection
|
||||||
|
{
|
||||||
|
private readonly TimingSection timingSection;
|
||||||
|
|
||||||
|
public BasicScrollingHitObjectCollection(TimingSection timingSection)
|
||||||
|
: base(Axes.Y)
|
||||||
|
{
|
||||||
|
this.timingSection = timingSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
Y = (float)(timingSection.Time - Time.Current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,25 +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
|
|
||||||
|
|
||||||
using osu.Game.Rulesets.Timing;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Timing.Drawables
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A basic timing change which scrolls along with a timing change.
|
|
||||||
/// </summary>
|
|
||||||
public class DrawableManiaScrollingTimingChange : DrawableManiaTimingChange
|
|
||||||
{
|
|
||||||
public DrawableManiaScrollingTimingChange(TimingSection timingChange)
|
|
||||||
: base(timingChange)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
Content.Y = (float)(TimingChange.Time - Time.Current);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +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
|
|
||||||
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Game.Rulesets.Timing;
|
|
||||||
using osu.Game.Rulesets.Timing.Drawables;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Timing.Drawables
|
|
||||||
{
|
|
||||||
public abstract class DrawableManiaTimingChange : DrawableTimingSection
|
|
||||||
{
|
|
||||||
protected DrawableManiaTimingChange(TimingSection timingChange)
|
|
||||||
: base(timingChange, Axes.Y)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
|
||||||
{
|
|
||||||
base.UpdateAfterChildren();
|
|
||||||
|
|
||||||
var parent = Parent as TimingSectionCollection;
|
|
||||||
|
|
||||||
if (parent == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// This is very naive and can be improved, but is adequate for now
|
|
||||||
LifetimeStart = TimingChange.Time - parent.TimeSpan;
|
|
||||||
LifetimeEnd = TimingChange.Time + Content.RelativeChildSize.Y * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,46 @@
|
|||||||
|
// 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.Framework.Graphics;
|
||||||
|
using osu.Game.Rulesets.Timing;
|
||||||
|
using osu.Game.Rulesets.Timing.Drawables;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Timing.Drawables
|
||||||
|
{
|
||||||
|
public class DrawableManiaTimingSection : DrawableTimingSection
|
||||||
|
{
|
||||||
|
private readonly ScrollingAlgorithm scrollingAlgorithm;
|
||||||
|
|
||||||
|
public DrawableManiaTimingSection(TimingSection timingSection, ScrollingAlgorithm scrollingAlgorithm)
|
||||||
|
: base(timingSection, Axes.Y)
|
||||||
|
{
|
||||||
|
this.scrollingAlgorithm = scrollingAlgorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateAfterChildren()
|
||||||
|
{
|
||||||
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
|
var parent = Parent as TimingSectionCollection;
|
||||||
|
|
||||||
|
if (parent == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// This is very naive and can be improved, but is adequate for now
|
||||||
|
LifetimeStart = TimingSection.Time - parent.TimeSpan;
|
||||||
|
LifetimeEnd = TimingSection.Time + Content.Height * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override HitObjectCollection CreateHitObjectCollection()
|
||||||
|
{
|
||||||
|
switch (scrollingAlgorithm)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case ScrollingAlgorithm.Basic:
|
||||||
|
return new BasicScrollingHitObjectCollection(TimingSection);
|
||||||
|
case ScrollingAlgorithm.Gravity:
|
||||||
|
return new GravityScrollingHitObjectCollection(TimingSection, () => RelativeChildSize.Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,31 +1,36 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Timing;
|
using osu.Game.Rulesets.Timing;
|
||||||
|
using osu.Game.Rulesets.Timing.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Timing.Drawables
|
namespace osu.Game.Rulesets.Mania.Timing.Drawables
|
||||||
{
|
{
|
||||||
/// <summary>
|
internal class GravityScrollingHitObjectCollection : HitObjectCollection
|
||||||
/// A timing change which scrolls with an increasing velocity, following a form of "gravity".
|
|
||||||
/// </summary>
|
|
||||||
public class DrawableManiaGravityTimingChange : DrawableManiaTimingChange
|
|
||||||
{
|
{
|
||||||
public DrawableManiaGravityTimingChange(TimingSection timingChange)
|
private readonly TimingSection timingSection;
|
||||||
: base(timingChange)
|
private readonly Func<double> timeSpan;
|
||||||
|
|
||||||
|
public GravityScrollingHitObjectCollection(TimingSection timingSection, Func<double> timeSpan)
|
||||||
|
: base(Axes.Y)
|
||||||
{
|
{
|
||||||
|
this.timingSection = timingSection;
|
||||||
|
this.timeSpan = timeSpan;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
// The gravity-adjusted start position
|
// The gravity-adjusted start position
|
||||||
float startY = (float)computeGravityTime(TimingChange.Time);
|
float startPos = (float)computeGravityTime(timingSection.Time);
|
||||||
// The gravity-adjusted end position
|
// The gravity-adjusted end position
|
||||||
float endY = (float)computeGravityTime(TimingChange.Time + Content.RelativeChildSize.Y);
|
float endPos = (float)computeGravityTime(timingSection.Time + RelativeChildSize.Y);
|
||||||
|
|
||||||
Content.Y = startY;
|
Y = startPos;
|
||||||
Content.Height = endY - startY;
|
Height = endPos - startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -40,24 +45,19 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables
|
|||||||
// The sign of the relative time, this is used to apply backwards acceleration leading into startTime
|
// The sign of the relative time, this is used to apply backwards acceleration leading into startTime
|
||||||
double sign = relativeTime < 0 ? -1 : 1;
|
double sign = relativeTime < 0 ? -1 : 1;
|
||||||
|
|
||||||
return timeSpan - acceleration * relativeTime * relativeTime * sign;
|
return timeSpan() - acceleration * relativeTime * relativeTime * sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The time spanned by this container.
|
|
||||||
/// </summary>
|
|
||||||
private double timeSpan => RelativeChildSize.Y;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The acceleration due to "gravity" of the content of this container.
|
/// The acceleration due to "gravity" of the content of this container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private double acceleration => 1 / timeSpan;
|
private double acceleration => 1 / timeSpan();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Computes the current time relative to <paramref name="time"/>, accounting for <see cref="timeSpan"/>.
|
/// Computes the current time relative to <paramref name="time"/>, accounting for <see cref="timeSpan"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="time">The non-offset time.</param>
|
/// <param name="time">The non-offset time.</param>
|
||||||
/// <returns>The current time relative to <paramref name="time"/> - <see cref="timeSpan"/>. </returns>
|
/// <returns>The current time relative to <paramref name="time"/> - <see cref="timeSpan"/>. </returns>
|
||||||
private double relativeTimeAt(double time) => Time.Current - time + timeSpan;
|
private double relativeTimeAt(double time) => Time.Current - time + timeSpan();
|
||||||
}
|
}
|
||||||
}
|
}
|
17
osu.Game.Rulesets.Mania/Timing/ScrollingAlgorithm.cs
Normal file
17
osu.Game.Rulesets.Mania/Timing/ScrollingAlgorithm.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// 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.Mania.Timing
|
||||||
|
{
|
||||||
|
public enum ScrollingAlgorithm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Basic scrolling algorithm based on the timing section time. This is the default algorithm.
|
||||||
|
/// </summary>
|
||||||
|
Basic,
|
||||||
|
/// <summary>
|
||||||
|
/// Emulating a form of gravity where hit objects speed up over time.
|
||||||
|
/// </summary>
|
||||||
|
Gravity
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@ using osu.Game.Rulesets.Mania.Judgements;
|
|||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Mania.Scoring;
|
using osu.Game.Rulesets.Mania.Scoring;
|
||||||
|
using osu.Game.Rulesets.Mania.Timing;
|
||||||
using osu.Game.Rulesets.Mania.Timing.Drawables;
|
using osu.Game.Rulesets.Mania.Timing.Drawables;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
@ -114,9 +115,9 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
timingChanges.ForEach(t =>
|
timingChanges.ForEach(t =>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < PreferredColumns; i++)
|
for (int i = 0; i < PreferredColumns; i++)
|
||||||
HitObjectTimingChanges[i].Add(new DrawableManiaScrollingTimingChange(t));
|
HitObjectTimingChanges[i].Add(new DrawableManiaTimingSection(t, ScrollingAlgorithm.Basic));
|
||||||
|
|
||||||
BarlineTimingChanges.Add(new DrawableManiaScrollingTimingChange(t));
|
BarlineTimingChanges.Add(new DrawableManiaTimingSection(t, ScrollingAlgorithm.Basic));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,9 @@
|
|||||||
<Compile Include="Objects\ManiaHitObject.cs" />
|
<Compile Include="Objects\ManiaHitObject.cs" />
|
||||||
<Compile Include="Objects\Note.cs" />
|
<Compile Include="Objects\Note.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Timing\Drawables\BasicScrollingHitObjectCollection.cs" />
|
||||||
|
<Compile Include="Timing\Drawables\GravityScrollingHitObjectCollection.cs" />
|
||||||
|
<Compile Include="Timing\ScrollingAlgorithm.cs" />
|
||||||
<Compile Include="UI\Column.cs" />
|
<Compile Include="UI\Column.cs" />
|
||||||
<Compile Include="UI\ManiaHitRenderer.cs" />
|
<Compile Include="UI\ManiaHitRenderer.cs" />
|
||||||
<Compile Include="UI\ManiaPlayfield.cs" />
|
<Compile Include="UI\ManiaPlayfield.cs" />
|
||||||
@ -84,9 +87,7 @@
|
|||||||
<Compile Include="Mods\ManiaMod.cs" />
|
<Compile Include="Mods\ManiaMod.cs" />
|
||||||
<Compile Include="Mods\ManiaModGravity.cs" />
|
<Compile Include="Mods\ManiaModGravity.cs" />
|
||||||
<Compile Include="UI\SpecialColumnPosition.cs" />
|
<Compile Include="UI\SpecialColumnPosition.cs" />
|
||||||
<Compile Include="Timing\Drawables\DrawableManiaGravityTimingChange.cs" />
|
<Compile Include="Timing\Drawables\DrawableManiaTimingSection.cs" />
|
||||||
<Compile Include="Timing\Drawables\DrawableManiaTimingChange.cs" />
|
|
||||||
<Compile Include="Timing\Drawables\DrawableManiaScrollingTimingChange.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||||
|
Loading…
Reference in New Issue
Block a user