mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add the concept of nested DrawableHitObjects.
- Applies to Slider Ticks and start circle. repeat/endpoints still need addressing. - Removed SliderTicksLayer abstraction for now.
This commit is contained in:
@ -37,7 +37,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
playbackSpeed.ValueChanged += delegate { rateAdjustClock.Rate = playbackSpeed.Value; };
|
playbackSpeed.ValueChanged += delegate { rateAdjustClock.Rate = playbackSpeed.Value; };
|
||||||
}
|
}
|
||||||
|
|
||||||
HitObjectType mode = HitObjectType.Spinner;
|
HitObjectType mode = HitObjectType.Slider;
|
||||||
|
|
||||||
BindableNumber<double> playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 };
|
BindableNumber<double> playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 };
|
||||||
private Container playfieldContainer;
|
private Container playfieldContainer;
|
||||||
|
@ -73,5 +73,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
Hit100,
|
Hit100,
|
||||||
[Description(@"300")]
|
[Description(@"300")]
|
||||||
Hit300,
|
Hit300,
|
||||||
|
[Description(@"10")]
|
||||||
|
SliderTick
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using osu.Game.Modes.Objects.Drawables;
|
|||||||
using osu.Game.Modes.Osu.Objects.Drawables.Pieces;
|
using osu.Game.Modes.Osu.Objects.Drawables.Pieces;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Osu.Objects.Drawables
|
namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -18,11 +19,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
|
|
||||||
private List<ISliderProgress> components = new List<ISliderProgress>();
|
private List<ISliderProgress> components = new List<ISliderProgress>();
|
||||||
|
|
||||||
|
private Container<DrawableSliderTick> ticks;
|
||||||
|
|
||||||
SliderBody body;
|
SliderBody body;
|
||||||
SliderBall ball;
|
SliderBall ball;
|
||||||
|
|
||||||
SliderBouncer bouncer1, bouncer2;
|
SliderBouncer bouncer1, bouncer2;
|
||||||
SliderTicksRenderer ticks;
|
|
||||||
|
|
||||||
public DrawableSlider(Slider s) : base(s)
|
public DrawableSlider(Slider s) : base(s)
|
||||||
{
|
{
|
||||||
@ -35,13 +37,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
Position = s.StackedPosition,
|
Position = s.StackedPosition,
|
||||||
PathWidth = s.Scale * 64,
|
PathWidth = s.Scale * 64,
|
||||||
},
|
},
|
||||||
ticks = new SliderTicksRenderer
|
ticks = new Container<DrawableSliderTick>(),
|
||||||
{
|
|
||||||
Position = s.StackedPosition,
|
|
||||||
StartTime = s.StartTime,
|
|
||||||
RepeatDuration = s.Curve.Length / s.Velocity,
|
|
||||||
Ticks = s.Ticks,
|
|
||||||
},
|
|
||||||
bouncer1 = new SliderBouncer(s, false)
|
bouncer1 = new SliderBouncer(s, false)
|
||||||
{
|
{
|
||||||
Position = s.Curve.PositionAt(1),
|
Position = s.Curve.PositionAt(1),
|
||||||
@ -72,6 +68,26 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
components.Add(ball);
|
components.Add(ball);
|
||||||
components.Add(bouncer1);
|
components.Add(bouncer1);
|
||||||
components.Add(bouncer2);
|
components.Add(bouncer2);
|
||||||
|
|
||||||
|
AddNested(initialCircle);
|
||||||
|
|
||||||
|
var repeatDuration = s.Curve.Length / s.Velocity;
|
||||||
|
foreach (var tick in s.Ticks)
|
||||||
|
{
|
||||||
|
var repeatStartTime = s.StartTime + tick.RepeatIndex * repeatDuration;
|
||||||
|
var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2);
|
||||||
|
var fadeOutTime = repeatStartTime + repeatDuration;
|
||||||
|
|
||||||
|
var drawableTick = new DrawableSliderTick(tick)
|
||||||
|
{
|
||||||
|
FadeInTime = fadeInTime,
|
||||||
|
FadeOutTime = fadeOutTime,
|
||||||
|
Position = tick.Position,
|
||||||
|
};
|
||||||
|
|
||||||
|
ticks.Add(drawableTick);
|
||||||
|
AddNested(drawableTick);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since the DrawableSlider itself is just a container without a size we need to
|
// Since the DrawableSlider itself is just a container without a size we need to
|
||||||
@ -105,8 +121,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
if (initialCircle.Judgement?.Result != HitResult.Hit)
|
if (initialCircle.Judgement?.Result != HitResult.Hit)
|
||||||
initialCircle.Position = slider.Curve.PositionAt(progress);
|
initialCircle.Position = slider.Curve.PositionAt(progress);
|
||||||
|
|
||||||
components.ForEach(c => c.UpdateProgress(progress, repeat));
|
foreach (var c in components) c.UpdateProgress(progress, repeat);
|
||||||
ticks.ShouldHit = ball.Tracking;
|
foreach (var t in ticks.Children) t.Tracking = ball.Tracking;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CheckJudgement(bool userTriggered)
|
protected override void CheckJudgement(bool userTriggered)
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
public double FadeInTime;
|
public double FadeInTime;
|
||||||
public double FadeOutTime;
|
public double FadeOutTime;
|
||||||
|
|
||||||
public bool ShouldHit;
|
public bool Tracking;
|
||||||
|
|
||||||
public override bool RemoveWhenNotAlive => false;
|
public override bool RemoveWhenNotAlive => false;
|
||||||
|
|
||||||
@ -35,7 +35,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
Masking = true;
|
Masking = true;
|
||||||
CornerRadius = Size.X / 2;
|
CornerRadius = Size.X / 2;
|
||||||
|
|
||||||
Anchor = Anchor.Centre;
|
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
BorderThickness = 2;
|
BorderThickness = 2;
|
||||||
@ -70,8 +69,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
|
|
||||||
protected override void CheckJudgement(bool userTriggered)
|
protected override void CheckJudgement(bool userTriggered)
|
||||||
{
|
{
|
||||||
|
var j = Judgement as OsuJudgementInfo;
|
||||||
|
|
||||||
if (Judgement.TimeOffset >= 0)
|
if (Judgement.TimeOffset >= 0)
|
||||||
Judgement.Result = ShouldHit ? HitResult.Hit : HitResult.Miss;
|
{
|
||||||
|
j.Result = Tracking ? HitResult.Hit : HitResult.Miss;
|
||||||
|
j.Score = Tracking ? OsuScoreResult.SliderTick : OsuScoreResult.Miss;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdatePreemptState()
|
protected override void UpdatePreemptState()
|
||||||
|
@ -1,96 +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.Allocation;
|
|
||||||
using osu.Framework.Caching;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
|
||||||
{
|
|
||||||
public class SliderTicksRenderer : Container<DrawableSliderTick>
|
|
||||||
{
|
|
||||||
private Cached drawableTicks = new Cached();
|
|
||||||
|
|
||||||
private double startTime;
|
|
||||||
public double StartTime
|
|
||||||
{
|
|
||||||
get { return startTime; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
startTime = value;
|
|
||||||
drawableTicks.Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double repeatDuration;
|
|
||||||
public double RepeatDuration
|
|
||||||
{
|
|
||||||
get { return repeatDuration; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
repeatDuration = value;
|
|
||||||
drawableTicks.Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<SliderTick> ticks;
|
|
||||||
public IEnumerable<SliderTick> Ticks
|
|
||||||
{
|
|
||||||
get { return ticks; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
ticks = value;
|
|
||||||
drawableTicks.Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ShouldHit
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
foreach (var tick in Children)
|
|
||||||
tick.ShouldHit = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
updateDrawableTicks();
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
updateDrawableTicks();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDrawableTicks()
|
|
||||||
{
|
|
||||||
if (drawableTicks.EnsureValid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
drawableTicks.Refresh(delegate
|
|
||||||
{
|
|
||||||
Clear();
|
|
||||||
if (ticks == null || repeatDuration == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var tick in ticks)
|
|
||||||
{
|
|
||||||
var repeatStartTime = startTime + tick.RepeatIndex * repeatDuration;
|
|
||||||
var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? DrawableOsuHitObject.TIME_FADEIN : DrawableOsuHitObject.TIME_FADEIN / 2);
|
|
||||||
var fadeOutTime = repeatStartTime + repeatDuration;
|
|
||||||
|
|
||||||
Add(new DrawableSliderTick(tick)
|
|
||||||
{
|
|
||||||
FadeInTime = fadeInTime,
|
|
||||||
FadeOutTime = fadeOutTime,
|
|
||||||
Position = tick.Position,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -96,7 +96,7 @@ namespace osu.Game.Modes.Osu.Objects
|
|||||||
{
|
{
|
||||||
RepeatIndex = repeat,
|
RepeatIndex = repeat,
|
||||||
StartTime = repeatStartTime + timeProgress * repeatDuration,
|
StartTime = repeatStartTime + timeProgress * repeatDuration,
|
||||||
Position = Curve.PositionAt(distanceProgress) - StackedPosition,
|
Position = Curve.PositionAt(distanceProgress),
|
||||||
StackHeight = StackHeight,
|
StackHeight = StackHeight,
|
||||||
Scale = Scale,
|
Scale = Scale,
|
||||||
Colour = Colour,
|
Colour = Colour,
|
||||||
|
@ -53,6 +53,10 @@ namespace osu.Game.Modes.Osu
|
|||||||
score += 300;
|
score += 300;
|
||||||
maxScore += 300;
|
maxScore += 300;
|
||||||
break;
|
break;
|
||||||
|
case OsuScoreResult.SliderTick:
|
||||||
|
score += 10;
|
||||||
|
maxScore += 10;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
<Compile Include="Objects\CircularArcApproximator.cs" />
|
<Compile Include="Objects\CircularArcApproximator.cs" />
|
||||||
<Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" />
|
<Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" />
|
||||||
<Compile Include="Objects\Drawables\Connections\ConnectionRenderer.cs" />
|
<Compile Include="Objects\Drawables\Connections\ConnectionRenderer.cs" />
|
||||||
<Compile Include="Objects\Drawables\SliderTicksLayer.cs" />
|
|
||||||
<Compile Include="Objects\Drawables\Connections\FollowPointRenderer.cs" />
|
<Compile Include="Objects\Drawables\Connections\FollowPointRenderer.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\ApproachCircle.cs" />
|
<Compile Include="Objects\Drawables\Pieces\ApproachCircle.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\SpinnerBackground.cs" />
|
<Compile Include="Objects\Drawables\Pieces\SpinnerBackground.cs" />
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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 System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
@ -23,8 +24,6 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
|
|
||||||
public bool Interactive = true;
|
public bool Interactive = true;
|
||||||
|
|
||||||
public Container<DrawableHitObject> ChildObjects;
|
|
||||||
|
|
||||||
public JudgementInfo Judgement;
|
public JudgementInfo Judgement;
|
||||||
|
|
||||||
public abstract JudgementInfo CreateJudgementInfo();
|
public abstract JudgementInfo CreateJudgementInfo();
|
||||||
@ -85,6 +84,19 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
Expire(true);
|
Expire(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<DrawableHitObject> nestedHitObjects;
|
||||||
|
|
||||||
|
protected IEnumerable<DrawableHitObject> NestedHitObjects => nestedHitObjects;
|
||||||
|
|
||||||
|
protected void AddNested(DrawableHitObject h)
|
||||||
|
{
|
||||||
|
if (nestedHitObjects == null)
|
||||||
|
nestedHitObjects = new List<DrawableHitObject>();
|
||||||
|
|
||||||
|
h.OnJudgement += (d, j) => { OnJudgement?.Invoke(d, j); } ;
|
||||||
|
nestedHitObjects.Add(h);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process a hit of this hitobject. Carries out judgement.
|
/// Process a hit of this hitobject. Carries out judgement.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -119,7 +131,11 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
|
|
||||||
protected virtual void CheckJudgement(bool userTriggered)
|
protected virtual void CheckJudgement(bool userTriggered)
|
||||||
{
|
{
|
||||||
//todo: consider making abstract.
|
if (NestedHitObjects != null)
|
||||||
|
{
|
||||||
|
foreach (var d in NestedHitObjects)
|
||||||
|
d.CheckJudgement(userTriggered);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
|
Reference in New Issue
Block a user