1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 11:42:56 +08:00

Migrate Rulesets.Osu to the new judgement system

This commit is contained in:
smoogipoo 2018-08-01 21:46:22 +09:00
parent d51d0e8547
commit 462f1033c0
11 changed files with 58 additions and 39 deletions

View File

@ -5,12 +5,10 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using OpenTK; using OpenTK;
using osu.Game.Rulesets.Osu.Judgements;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
@ -101,11 +99,7 @@ namespace osu.Game.Rulesets.Osu.Tests
if (auto && !userTriggered && timeOffset > 0) if (auto && !userTriggered && timeOffset > 0)
{ {
// force success // force success
AddJudgement(new OsuJudgement ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Great);
{
Result = HitResult.Great
});
State.Value = ArmedState.Hit;
} }
else else
base.CheckForJudgements(userTriggered, timeOffset); base.CheckForJudgements(userTriggered, timeOffset);

View File

@ -6,7 +6,6 @@ using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK; using OpenTK;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -82,7 +81,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
if (!userTriggered) if (!userTriggered)
{ {
if (!HitObject.HitWindows.CanBeHit(timeOffset)) if (!HitObject.HitWindows.CanBeHit(timeOffset))
AddJudgement(new OsuJudgement { Result = HitResult.Miss }); ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Miss);
return; return;
} }
@ -90,10 +90,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
if (result == HitResult.None) if (result == HitResult.None)
return; return;
AddJudgement(new OsuJudgement ApplyJudgement(HitObject.Judgement, j => j.Result = result);
{
Result = result,
});
} }
protected override void UpdatePreemptState() protected override void UpdatePreemptState()

View File

@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
UpdatePreemptState(); UpdatePreemptState();
var judgementOffset = Math.Min(HitObject.HitWindows.HalfWindowFor(HitResult.Miss), Judgements.FirstOrDefault()?.TimeOffset ?? 0); var judgementOffset = Math.Min(HitObject.HitWindows.HalfWindowFor(HitResult.Miss), HitObject.Judgements.FirstOrDefault()?.TimeOffset ?? 0);
using (BeginDelayedSequence(HitObject.TimePreempt + judgementOffset, true)) using (BeginDelayedSequence(HitObject.TimePreempt + judgementOffset, true))
UpdateCurrentState(state); UpdateCurrentState(state);

View File

@ -8,7 +8,6 @@ using osu.Framework.MathUtils;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using OpenTK; using OpenTK;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -45,7 +44,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void CheckForJudgements(bool userTriggered, double timeOffset) protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{ {
if (repeatPoint.StartTime <= Time.Current) if (repeatPoint.StartTime <= Time.Current)
AddJudgement(new OsuJudgement { Result = drawableSlider.Tracking ? HitResult.Great : HitResult.Miss }); ApplyJudgement(HitObject.Judgement, j => j.Result = drawableSlider.Tracking ? HitResult.Great : HitResult.Miss);
} }
protected override void UpdatePreemptState() protected override void UpdatePreemptState()

View File

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -134,21 +133,25 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void CheckForJudgements(bool userTriggered, double timeOffset) protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{ {
if (!userTriggered && Time.Current >= slider.EndTime) if (userTriggered || Time.Current < slider.EndTime)
return;
ApplyJudgement(HitObject.Judgement, j =>
{ {
var judgementsCount = NestedHitObjects.Count(); var judgementsCount = NestedHitObjects.Count();
var judgementsHit = NestedHitObjects.Count(h => h.IsHit); var judgementsHit = NestedHitObjects.Count(h => h.IsHit);
var hitFraction = (double)judgementsHit / judgementsCount; var hitFraction = (double)judgementsHit / judgementsCount;
if (hitFraction == 1 && HeadCircle.Judgements.Any(j => j.Result == HitResult.Great))
AddJudgement(new OsuJudgement { Result = HitResult.Great }); if (hitFraction == 1 && HeadCircle.HitObject.Judgement.Result == HitResult.Great)
else if (hitFraction >= 0.5 && HeadCircle.Judgements.Any(j => j.Result >= HitResult.Good)) j.Result = HitResult.Great;
AddJudgement(new OsuJudgement { Result = HitResult.Good }); else if (hitFraction >= 0.5 && HeadCircle.HitObject.Judgement.Result >= HitResult.Good)
j.Result = HitResult.Good;
else if (hitFraction > 0) else if (hitFraction > 0)
AddJudgement(new OsuJudgement { Result = HitResult.Meh }); j.Result = HitResult.Meh;
else else
AddJudgement(new OsuJudgement { Result = HitResult.Miss }); j.Result = HitResult.Miss;
} });
} }
protected override void UpdateCurrentState(ArmedState state) protected override void UpdateCurrentState(ArmedState state)

View File

@ -2,7 +2,6 @@
// 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 osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Osu.Objects.Drawables namespace osu.Game.Rulesets.Osu.Objects.Drawables
@ -16,7 +15,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public bool Tracking { get; set; } public bool Tracking { get; set; }
public DrawableSliderTail(Slider slider, HitCircle hitCircle) public DrawableSliderTail(Slider slider, SliderTailCircle hitCircle)
: base(hitCircle) : base(hitCircle)
{ {
Origin = Anchor.Centre; Origin = Anchor.Centre;
@ -32,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void CheckForJudgements(bool userTriggered, double timeOffset) protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{ {
if (!userTriggered && timeOffset >= 0) if (!userTriggered && timeOffset >= 0)
AddJudgement(new OsuSliderTailJudgement { Result = Tracking ? HitResult.Great : HitResult.Miss }); ApplyJudgement(HitObject.Judgement, j => j.Result = Tracking ? HitResult.Great : HitResult.Miss);
} }
} }
} }

View File

@ -6,7 +6,6 @@ using osu.Game.Rulesets.Objects.Drawables;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -51,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void CheckForJudgements(bool userTriggered, double timeOffset) protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{ {
if (timeOffset >= 0) if (timeOffset >= 0)
AddJudgement(new OsuJudgement { Result = Tracking ? HitResult.Great : HitResult.Miss }); ApplyJudgement(HitObject.Judgement, j => j.Result = Tracking ? HitResult.Great : HitResult.Miss);
} }
protected override void UpdatePreemptState() protected override void UpdatePreemptState()

View File

@ -11,7 +11,6 @@ using OpenTK.Graphics;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -136,17 +135,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
glow.FadeColour(completeColour, duration); glow.FadeColour(completeColour, duration);
} }
if (!userTriggered && Time.Current >= Spinner.EndTime) if (userTriggered || Time.Current < Spinner.EndTime)
return;
ApplyJudgement(HitObject.Judgement, j =>
{ {
if (Progress >= 1) if (Progress >= 1)
AddJudgement(new OsuJudgement { Result = HitResult.Great }); j.Result = HitResult.Great;
else if (Progress > .9) else if (Progress > .9)
AddJudgement(new OsuJudgement { Result = HitResult.Good }); j.Result = HitResult.Good;
else if (Progress > .75) else if (Progress > .75)
AddJudgement(new OsuJudgement { Result = HitResult.Meh }); j.Result = HitResult.Meh;
else if (Time.Current >= Spinner.EndTime) else if (Time.Current >= Spinner.EndTime)
AddJudgement(new OsuJudgement { Result = HitResult.Miss }); j.Result = HitResult.Miss;
} });
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -2,12 +2,15 @@
// 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 osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using OpenTK; using OpenTK;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit.Types; using osu.Game.Rulesets.Edit.Types;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements;
namespace osu.Game.Rulesets.Osu.Objects namespace osu.Game.Rulesets.Osu.Objects
{ {
@ -73,5 +76,11 @@ namespace osu.Game.Rulesets.Osu.Objects
public virtual void OffsetPosition(Vector2 offset) => Position += offset; public virtual void OffsetPosition(Vector2 offset) => Position += offset;
protected override HitWindows CreateHitWindows() => new OsuHitWindows(); protected override HitWindows CreateHitWindows() => new OsuHitWindows();
public OsuJudgement Judgement { get; private set; }
protected override IEnumerable<Judgement> CreateJudgements() => new[] { Judgement = CreateJudgement() };
protected virtual OsuJudgement CreateJudgement() => new OsuJudgement();
} }
} }

View File

@ -94,7 +94,7 @@ namespace osu.Game.Rulesets.Osu.Objects
public double TickDistance; public double TickDistance;
public HitCircle HeadCircle; public HitCircle HeadCircle;
public HitCircle TailCircle; public SliderTailCircle TailCircle;
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
@ -133,7 +133,7 @@ namespace osu.Game.Rulesets.Osu.Objects
ComboIndex = ComboIndex, ComboIndex = ComboIndex,
}; };
TailCircle = new SliderCircle(this) TailCircle = new SliderTailCircle(this)
{ {
StartTime = EndTime, StartTime = EndTime,
Position = EndPosition, Position = EndPosition,

View File

@ -0,0 +1,17 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Osu.Judgements;
namespace osu.Game.Rulesets.Osu.Objects
{
public class SliderTailCircle : SliderCircle
{
public SliderTailCircle(Slider slider)
: base(slider)
{
}
protected override OsuJudgement CreateJudgement() => new OsuSliderTailJudgement();
}
}