1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 08:13:31 +08:00

Create connections from HitObjects instead of DrawableHitObjects.

This commit is contained in:
Damnae 2017-02-12 07:29:36 +01:00
parent 4162ef72d4
commit d7be9539d1
4 changed files with 22 additions and 25 deletions

View File

@ -2,17 +2,18 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Containers;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Objects;
using System.Collections.Generic;
namespace osu.Game.Modes.Osu.Objects.Drawables.Connections
{
public abstract class HitObjectConnection : Container
public abstract class ConnectionRenderer<T> : Container
where T : HitObject
{
/// <summary>
/// Create drawables inside this container, connecting hitobjects visually, for example with follow points.
/// Create drawables inside this container, connecting hit objects visually, for example with follow points.
/// </summary>
/// <param name="drawableHitObjects">The drawables hit objects to create connections for</param>
public abstract void AddConnections(IEnumerable<DrawableHitObject> drawableHitObjects);
/// <param name="hitObjects">Hit objects to create connections for</param>
public abstract void AddConnections(IEnumerable<T> hitObjects);
}
}

View File

@ -2,15 +2,13 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Osu.Objects.Drawables.Connections;
using System;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Modes.Osu.Objects.Drawables
{
public class FollowPointConnection : HitObjectConnection
public class FollowPointRenderer : ConnectionRenderer<OsuHitObject>
{
/// <summary>
/// Determines how much space there is between points.
@ -22,18 +20,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
/// </summary>
public int PreEmpt = 800;
public override void AddConnections(IEnumerable<DrawableHitObject> drawableHitObjects)
public override void AddConnections(IEnumerable<OsuHitObject> hitObjects)
{
var hitObjects = new List<OsuHitObject>(drawableHitObjects
.Select(d => (OsuHitObject)d.HitObject)
.OrderBy(h => h.StartTime));
for (int i = 1; i <= hitObjects.Count - 1; i++)
OsuHitObject prevHitObject = null;
foreach (var currHitObject in hitObjects)
{
var prevHitObject = hitObjects[i - 1];
var currHitObject = hitObjects[i];
if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner))
if (prevHitObject != null && !currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner))
{
Vector2 startPosition = prevHitObject.EndPosition;
Vector2 endPosition = currHitObject.Position;
@ -63,6 +55,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
});
}
}
prevHitObject = currHitObject;
}
}
}

View File

@ -9,6 +9,7 @@ using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.Objects.Drawables;
using osu.Game.Modes.Osu.Objects.Drawables.Connections;
using osu.Game.Modes.UI;
using System.Linq;
namespace osu.Game.Modes.Osu.UI
{
@ -16,7 +17,7 @@ namespace osu.Game.Modes.Osu.UI
{
private Container approachCircles;
private Container judgementLayer;
private HitObjectConnection hitObjectConnection;
private ConnectionRenderer<OsuHitObject> connectionLayer;
public override Vector2 Size
{
@ -38,15 +39,15 @@ namespace osu.Game.Modes.Osu.UI
Add(new Drawable[]
{
hitObjectConnection = new FollowPointConnection
connectionLayer = new FollowPointRenderer
{
RelativeSizeAxes = Axes.Both,
Depth = 1,
Depth = 2,
},
judgementLayer = new Container
{
RelativeSizeAxes = Axes.Both,
Depth = 0,
Depth = 1,
},
approachCircles = new Container
{
@ -72,7 +73,9 @@ namespace osu.Game.Modes.Osu.UI
public override void PostProcess()
{
hitObjectConnection.AddConnections(HitObjects.Children);
connectionLayer.AddConnections(HitObjects.Children
.Select(d => (OsuHitObject)d.HitObject)
.OrderBy(h => h.StartTime));
}
private void judgement(DrawableHitObject h, JudgementInfo j)

View File

@ -44,8 +44,8 @@
<Compile Include="Objects\BezierApproximator.cs" />
<Compile Include="Objects\CircularArcApproximator.cs" />
<Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" />
<Compile Include="Objects\Drawables\Connections\HitObjectConnection.cs" />
<Compile Include="Objects\Drawables\Connections\FollowPointConnection.cs" />
<Compile Include="Objects\Drawables\Connections\ConnectionRenderer.cs" />
<Compile Include="Objects\Drawables\Connections\FollowPointRenderer.cs" />
<Compile Include="Objects\Drawables\Pieces\ApproachCircle.cs" />
<Compile Include="Objects\Drawables\Pieces\CirclePiece.cs" />
<Compile Include="Objects\Drawables\DrawableSlider.cs" />