1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 04:02:59 +08:00

Merge pull request #10692 from smoogipoo/followpointrenderer-hitobject

This commit is contained in:
Dean Herbert 2020-11-05 16:39:05 +09:00 committed by GitHub
commit 4a4fa96fef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 39 deletions

View File

@ -171,7 +171,7 @@ namespace osu.Game.Rulesets.Osu.Tests
} }
hitObjectContainer.Add(drawableObject); hitObjectContainer.Add(drawableObject);
followPointRenderer.AddFollowPoints(drawableObject); followPointRenderer.AddFollowPoints(objects[i]);
} }
}); });
} }
@ -180,10 +180,10 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
AddStep("remove hitobject", () => AddStep("remove hitobject", () =>
{ {
var drawableObject = getFunc?.Invoke(); var drawableObject = getFunc.Invoke();
hitObjectContainer.Remove(drawableObject); 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 expectedStart = getObject(i);
DrawableOsuHitObject expectedEnd = i < hitObjectContainer.Count - 1 ? getObject(i + 1) : null; 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}."); 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}."); throw new AssertionException($"Object {(expectedEnd == null ? "null" : i.ToString())} expected to be the end of group {i}.");
} }

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Diagnostics;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; 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. /// The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will exit from.
/// </summary> /// </summary>
[NotNull] [NotNull]
public readonly DrawableOsuHitObject Start; public readonly OsuHitObject Start;
/// <summary> /// <summary>
/// Creates a new <see cref="FollowPointConnection"/>. /// Creates a new <see cref="FollowPointConnection"/>.
/// </summary> /// </summary>
/// <param name="start">The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will exit from.</param> /// <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; Start = start;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
StartTime.BindTo(Start.HitObject.StartTimeBindable); StartTime.BindTo(start.StartTimeBindable);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -52,13 +53,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
bindEvents(Start); bindEvents(Start);
} }
private DrawableOsuHitObject end; private OsuHitObject end;
/// <summary> /// <summary>
/// The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will enter. /// The <see cref="DrawableOsuHitObject"/> which <see cref="FollowPoint"/>s will enter.
/// </summary> /// </summary>
[CanBeNull] [CanBeNull]
public DrawableOsuHitObject End public OsuHitObject End
{ {
get => end; get => end;
set 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()); obj.PositionBindable.BindValueChanged(_ => scheduleRefresh());
drawableObject.HitObject.DefaultsApplied += _ => scheduleRefresh(); obj.DefaultsApplied += _ => scheduleRefresh();
} }
private void scheduleRefresh() private void scheduleRefresh()
@ -88,23 +89,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
private void refresh() private void refresh()
{ {
OsuHitObject osuStart = Start.HitObject; double startTime = Start.GetEndTime();
double startTime = osuStart.GetEndTime();
LifetimeStart = startTime; LifetimeStart = startTime;
OsuHitObject osuEnd = End?.HitObject; if (End == null || End.NewCombo || Start is Spinner || End is Spinner)
if (osuEnd == null || osuEnd.NewCombo || osuStart is Spinner || osuEnd is Spinner)
{ {
// ensure we always set a lifetime for full LifetimeManagementContainer benefits // ensure we always set a lifetime for full LifetimeManagementContainer benefits
LifetimeEnd = LifetimeStart; LifetimeEnd = LifetimeStart;
return; return;
} }
Vector2 startPosition = osuStart.StackedEndPosition; Vector2 startPosition = Start.StackedEndPosition;
Vector2 endPosition = osuEnd.StackedPosition; Vector2 endPosition = End.StackedPosition;
double endTime = osuEnd.StartTime; double endTime = End.StartTime;
Vector2 distanceVector = endPosition - startPosition; Vector2 distanceVector = endPosition - startPosition;
int distance = (int)distanceVector.Length; int distance = (int)distanceVector.Length;
@ -130,10 +128,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
AddInternal(fp = new FollowPoint()); AddInternal(fp = new FollowPoint());
Debug.Assert(End != null);
fp.Position = pointStartPosition; fp.Position = pointStartPosition;
fp.Rotation = rotation; fp.Rotation = rotation;
fp.Alpha = 0; fp.Alpha = 0;
fp.Scale = new Vector2(1.5f * osuEnd.Scale); fp.Scale = new Vector2(1.5f * End.Scale);
firstTransformStartTime ??= fadeInTime; firstTransformStartTime ??= fadeInTime;
@ -141,12 +141,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
using (fp.BeginAbsoluteSequence(fadeInTime)) using (fp.BeginAbsoluteSequence(fadeInTime))
{ {
fp.FadeIn(osuEnd.TimeFadeIn); fp.FadeIn(End.TimeFadeIn);
fp.ScaleTo(osuEnd.Scale, osuEnd.TimeFadeIn, Easing.Out); fp.ScaleTo(End.Scale, End.TimeFadeIn, Easing.Out);
fp.MoveTo(pointEndPosition, osuEnd.TimeFadeIn, Easing.Out); fp.MoveTo(pointEndPosition, End.TimeFadeIn, Easing.Out);
fp.Delay(fadeOutTime - fadeInTime).FadeOut(osuEnd.TimeFadeIn); fp.Delay(fadeOutTime - fadeInTime).FadeOut(End.TimeFadeIn);
finalTransformEndTime = fadeOutTime + osuEnd.TimeFadeIn; finalTransformEndTime = fadeOutTime + End.TimeFadeIn;
} }
point++; point++;

View File

@ -24,19 +24,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
public override bool RemoveCompletedTransforms => false; public override bool RemoveCompletedTransforms => false;
/// <summary> /// <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"/>. /// This includes <see cref="FollowPoint"/>s leading into <paramref name="hitObject"/>, and <see cref="FollowPoint"/>s exiting <paramref name="hitObject"/>.
/// </summary> /// </summary>
/// <param name="hitObject">The <see cref="DrawableOsuHitObject"/> to add <see cref="FollowPoint"/>s for.</param> /// <param name="hitObject">The <see cref="OsuHitObject"/> to add <see cref="FollowPoint"/>s for.</param>
public void AddFollowPoints(DrawableOsuHitObject hitObject) public void AddFollowPoints(OsuHitObject hitObject)
=> addConnection(new FollowPointConnection(hitObject).With(g => g.StartTime.BindValueChanged(_ => onStartTimeChanged(g)))); => addConnection(new FollowPointConnection(hitObject).With(g => g.StartTime.BindValueChanged(_ => onStartTimeChanged(g))));
/// <summary> /// <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"/>. /// This includes <see cref="FollowPoint"/>s leading into <paramref name="hitObject"/>, and <see cref="FollowPoint"/>s exiting <paramref name="hitObject"/>.
/// </summary> /// </summary>
/// <param name="hitObject">The <see cref="DrawableOsuHitObject"/> to remove <see cref="FollowPoint"/>s for.</param> /// <param name="hitObject">The <see cref="OsuHitObject"/> to remove <see cref="FollowPoint"/>s for.</param>
public void RemoveFollowPoints(DrawableOsuHitObject hitObject) => removeGroup(connections.Single(g => g.Start == hitObject)); public void RemoveFollowPoints(OsuHitObject hitObject) => removeGroup(connections.Single(g => g.Start == hitObject));
/// <summary> /// <summary>
/// Adds a <see cref="FollowPointConnection"/> to this <see cref="FollowPointRenderer"/>. /// Adds a <see cref="FollowPointConnection"/> to this <see cref="FollowPointRenderer"/>.

View File

@ -4,12 +4,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Pooling; using osu.Framework.Graphics.Pooling;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Configuration;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Connections; using osu.Game.Rulesets.Osu.Objects.Drawables.Connections;
using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Osu.Scoring;
@ -17,9 +20,6 @@ using osu.Game.Rulesets.Osu.UI.Cursor;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Rulesets.Osu.Configuration;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Osu.UI namespace osu.Game.Rulesets.Osu.UI
@ -95,6 +95,8 @@ namespace osu.Game.Rulesets.Osu.UI
public override void Add(DrawableHitObject h) public override void Add(DrawableHitObject h)
{ {
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
h.OnNewResult += onNewResult; h.OnNewResult += onNewResult;
h.OnLoadComplete += d => h.OnLoadComplete += d =>
{ {
@ -107,18 +109,19 @@ namespace osu.Game.Rulesets.Osu.UI
base.Add(h); base.Add(h);
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
osuHitObject.CheckHittable = hitPolicy.IsHittable; osuHitObject.CheckHittable = hitPolicy.IsHittable;
followPoints.AddFollowPoints(osuHitObject); followPoints.AddFollowPoints(osuHitObject.HitObject);
} }
public override bool Remove(DrawableHitObject h) public override bool Remove(DrawableHitObject h)
{ {
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
bool result = base.Remove(h); bool result = base.Remove(h);
if (result) if (result)
followPoints.RemoveFollowPoints((DrawableOsuHitObject)h); followPoints.RemoveFollowPoints(osuHitObject.HitObject);
return result; return result;
} }