mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Make FollowPointRenderer use hitobject models
This commit is contained in:
parent
a386765a9d
commit
9c1c9945af
@ -171,7 +171,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
}
|
||||
|
||||
hitObjectContainer.Add(drawableObject);
|
||||
followPointRenderer.AddFollowPoints(drawableObject);
|
||||
followPointRenderer.AddFollowPoints(objects[i]);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -180,10 +180,10 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
AddStep("remove hitobject", () =>
|
||||
{
|
||||
var drawableObject = getFunc?.Invoke();
|
||||
var drawableObject = getFunc.Invoke();
|
||||
|
||||
hitObjectContainer.Remove(drawableObject);
|
||||
followPointRenderer.RemoveFollowPoints(drawableObject);
|
||||
followPointRenderer.RemoveFollowPoints(drawableObject.HitObject);
|
||||
});
|
||||
}
|
||||
|
||||
@ -215,10 +215,10 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
DrawableOsuHitObject expectedStart = getObject(i);
|
||||
DrawableOsuHitObject expectedEnd = i < hitObjectContainer.Count - 1 ? getObject(i + 1) : null;
|
||||
|
||||
if (getGroup(i).Start != expectedStart)
|
||||
if (getGroup(i).Start != expectedStart.HitObject)
|
||||
throw new AssertionException($"Object {i} expected to be the start of group {i}.");
|
||||
|
||||
if (getGroup(i).End != expectedEnd)
|
||||
if (getGroup(i).End != expectedEnd?.HitObject)
|
||||
throw new AssertionException($"Object {(expectedEnd == null ? "null" : i.ToString())} expected to be the end of group {i}.");
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -31,19 +32,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
/// The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will exit from.
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public readonly DrawableOsuHitObject Start;
|
||||
public readonly OsuHitObject Start;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FollowPointConnection"/>.
|
||||
/// </summary>
|
||||
/// <param name="start">The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will exit from.</param>
|
||||
public FollowPointConnection([NotNull] DrawableOsuHitObject start)
|
||||
public FollowPointConnection([NotNull] OsuHitObject start)
|
||||
{
|
||||
Start = start;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
StartTime.BindTo(Start.HitObject.StartTimeBindable);
|
||||
StartTime.BindTo(start.StartTimeBindable);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -52,13 +53,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
bindEvents(Start);
|
||||
}
|
||||
|
||||
private DrawableOsuHitObject end;
|
||||
private OsuHitObject end;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will enter.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public DrawableOsuHitObject End
|
||||
public OsuHitObject End
|
||||
{
|
||||
get => end;
|
||||
set
|
||||
@ -75,10 +76,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
}
|
||||
}
|
||||
|
||||
private void bindEvents(DrawableOsuHitObject drawableObject)
|
||||
private void bindEvents(OsuHitObject obj)
|
||||
{
|
||||
drawableObject.HitObject.PositionBindable.BindValueChanged(_ => scheduleRefresh());
|
||||
drawableObject.HitObject.DefaultsApplied += _ => scheduleRefresh();
|
||||
obj.PositionBindable.BindValueChanged(_ => scheduleRefresh());
|
||||
obj.DefaultsApplied += _ => scheduleRefresh();
|
||||
}
|
||||
|
||||
private void scheduleRefresh()
|
||||
@ -88,23 +89,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
|
||||
private void refresh()
|
||||
{
|
||||
OsuHitObject osuStart = Start.HitObject;
|
||||
double startTime = osuStart.GetEndTime();
|
||||
double startTime = Start.GetEndTime();
|
||||
|
||||
LifetimeStart = startTime;
|
||||
|
||||
OsuHitObject osuEnd = End?.HitObject;
|
||||
|
||||
if (osuEnd == null || osuEnd.NewCombo || osuStart is Spinner || osuEnd is Spinner)
|
||||
if (End == null || End.NewCombo || Start is Spinner || End is Spinner)
|
||||
{
|
||||
// ensure we always set a lifetime for full LifetimeManagementContainer benefits
|
||||
LifetimeEnd = LifetimeStart;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 startPosition = osuStart.StackedEndPosition;
|
||||
Vector2 endPosition = osuEnd.StackedPosition;
|
||||
double endTime = osuEnd.StartTime;
|
||||
Vector2 startPosition = Start.StackedEndPosition;
|
||||
Vector2 endPosition = End.StackedPosition;
|
||||
double endTime = End.StartTime;
|
||||
|
||||
Vector2 distanceVector = endPosition - startPosition;
|
||||
int distance = (int)distanceVector.Length;
|
||||
@ -130,10 +128,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
|
||||
AddInternal(fp = new FollowPoint());
|
||||
|
||||
Debug.Assert(End != null);
|
||||
|
||||
fp.Position = pointStartPosition;
|
||||
fp.Rotation = rotation;
|
||||
fp.Alpha = 0;
|
||||
fp.Scale = new Vector2(1.5f * osuEnd.Scale);
|
||||
fp.Scale = new Vector2(1.5f * End.Scale);
|
||||
|
||||
firstTransformStartTime ??= fadeInTime;
|
||||
|
||||
@ -141,12 +141,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
|
||||
using (fp.BeginAbsoluteSequence(fadeInTime))
|
||||
{
|
||||
fp.FadeIn(osuEnd.TimeFadeIn);
|
||||
fp.ScaleTo(osuEnd.Scale, osuEnd.TimeFadeIn, Easing.Out);
|
||||
fp.MoveTo(pointEndPosition, osuEnd.TimeFadeIn, Easing.Out);
|
||||
fp.Delay(fadeOutTime - fadeInTime).FadeOut(osuEnd.TimeFadeIn);
|
||||
fp.FadeIn(End.TimeFadeIn);
|
||||
fp.ScaleTo(End.Scale, End.TimeFadeIn, Easing.Out);
|
||||
fp.MoveTo(pointEndPosition, End.TimeFadeIn, Easing.Out);
|
||||
fp.Delay(fadeOutTime - fadeInTime).FadeOut(End.TimeFadeIn);
|
||||
|
||||
finalTransformEndTime = fadeOutTime + osuEnd.TimeFadeIn;
|
||||
finalTransformEndTime = fadeOutTime + End.TimeFadeIn;
|
||||
}
|
||||
|
||||
point++;
|
||||
|
@ -24,19 +24,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
public override bool RemoveCompletedTransforms => false;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the <see cref="FollowPoint"/>s around a <see cref="DrawableOsuHitObject"/>.
|
||||
/// Adds the <see cref="FollowPoint"/>s around an <see cref="OsuHitObject"/>.
|
||||
/// This includes <see cref="FollowPoint"/>s leading into <paramref name="hitObject"/>, and <see cref="FollowPoint"/>s exiting <paramref name="hitObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableOsuHitObject"/> to add <see cref="FollowPoint"/>s for.</param>
|
||||
public void AddFollowPoints(DrawableOsuHitObject hitObject)
|
||||
/// <param name="hitObject">The <see cref="OsuHitObject"/> to add <see cref="FollowPoint"/>s for.</param>
|
||||
public void AddFollowPoints(OsuHitObject hitObject)
|
||||
=> addConnection(new FollowPointConnection(hitObject).With(g => g.StartTime.BindValueChanged(_ => onStartTimeChanged(g))));
|
||||
|
||||
/// <summary>
|
||||
/// Removes the <see cref="FollowPoint"/>s around a <see cref="DrawableOsuHitObject"/>.
|
||||
/// Removes the <see cref="FollowPoint"/>s around an <see cref="OsuHitObject"/>.
|
||||
/// This includes <see cref="FollowPoint"/>s leading into <paramref name="hitObject"/>, and <see cref="FollowPoint"/>s exiting <paramref name="hitObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableOsuHitObject"/> to remove <see cref="FollowPoint"/>s for.</param>
|
||||
public void RemoveFollowPoints(DrawableOsuHitObject hitObject) => removeGroup(connections.Single(g => g.Start == hitObject));
|
||||
/// <param name="hitObject">The <see cref="OsuHitObject"/> to remove <see cref="FollowPoint"/>s for.</param>
|
||||
public void RemoveFollowPoints(OsuHitObject hitObject) => removeGroup(connections.Single(g => g.Start == hitObject));
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="FollowPointConnection"/> to this <see cref="FollowPointRenderer"/>.
|
||||
|
@ -20,6 +20,7 @@ using osu.Game.Skinning;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets.Osu.Configuration;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
@ -110,7 +111,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
|
||||
osuHitObject.CheckHittable = hitPolicy.IsHittable;
|
||||
|
||||
followPoints.AddFollowPoints(osuHitObject);
|
||||
followPoints.AddFollowPoints((OsuHitObject)h.HitObject);
|
||||
}
|
||||
|
||||
public override bool Remove(DrawableHitObject h)
|
||||
@ -118,7 +119,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
bool result = base.Remove(h);
|
||||
|
||||
if (result)
|
||||
followPoints.RemoveFollowPoints((DrawableOsuHitObject)h);
|
||||
followPoints.RemoveFollowPoints((OsuHitObject)h.HitObject);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user