Make Rulesets.Mania use the new judgement result structure

This commit is contained in:
smoogipoo 2018-08-02 20:36:54 +09:00
parent 4548d2c87f
commit 807794d512
12 changed files with 39 additions and 85 deletions

View File

@ -1,27 +0,0 @@
// 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.Scoring;
namespace osu.Game.Rulesets.Mania.Judgements
{
public class HoldNoteTailJudgement : ManiaJudgement
{
/// <summary>
/// Whether the hold note has been released too early and shouldn't give full score for the release.
/// </summary>
public bool HasBroken;
protected override int NumericResultFor(HitResult result)
{
switch (result)
{
default:
return base.NumericResultFor(result);
case HitResult.Great:
case HitResult.Perfect:
return base.NumericResultFor(HasBroken ? HitResult.Good : result);
}
}
}
}

View File

@ -7,7 +7,6 @@
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using OpenTK.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mania.Judgements;
using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI.Scrolling;
@ -100,7 +99,7 @@ public override Color4 AccentColour
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{
if (tail.AllJudged)
ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Perfect);
ApplyResult(Results.Single(), r => r.Type = HitResult.Perfect);
}
protected override void Update()
@ -166,7 +165,7 @@ public override bool OnPressed(ManiaAction action)
return false;
// If the key has been released too early, the user should not receive full score for the release
if (HitObject.Judgement.Result == HitResult.Miss)
if (Results.Single().Type == HitResult.Miss)
holdNote.hasBroken = true;
// The head note also handles early hits before the body, but we want accurate early hits to count as the body being held
@ -205,13 +204,7 @@ protected override void CheckForJudgements(bool userTriggered, double timeOffset
if (!userTriggered)
{
if (!HitObject.HitWindows.CanBeHit(timeOffset))
{
ApplyJudgement(holdNote.HitObject.Tail.Judgement, j =>
{
j.Result = HitResult.Miss;
((HoldNoteTailJudgement)j).HasBroken = holdNote.hasBroken;
});
}
ApplyResult(Results.Single(), r => r.Type = HitResult.Miss);
return;
}
@ -220,10 +213,12 @@ protected override void CheckForJudgements(bool userTriggered, double timeOffset
if (result == HitResult.None)
return;
ApplyJudgement(holdNote.HitObject.Tail.Judgement, j =>
ApplyResult(Results.Single(), r =>
{
j.Result = result;
((HoldNoteTailJudgement)j).HasBroken = holdNote.hasBroken;
if (holdNote.hasBroken && (result == HitResult.Perfect || result == HitResult.Perfect))
result = HitResult.Good;
r.Type = result;
});
}

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
@ -79,9 +80,9 @@ protected override void CheckForJudgements(bool userTriggered, double timeOffset
var startTime = HoldStartTime?.Invoke();
if (startTime == null || startTime > HitObject.StartTime)
ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Miss);
ApplyResult(Results.Single(), r => r.Type = HitResult.Miss);
else
ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Perfect);
ApplyResult(Results.Single(), r => r.Type = HitResult.Perfect);
}
}
}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Extensions.Color4Extensions;
using OpenTK.Graphics;
using osu.Framework.Graphics;
@ -60,7 +61,7 @@ protected override void CheckForJudgements(bool userTriggered, double timeOffset
if (!userTriggered)
{
if (!HitObject.HitWindows.CanBeHit(timeOffset))
ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Miss);
ApplyResult(Results.Single(), r => r.Type = HitResult.Miss);
return;
}
@ -68,7 +69,7 @@ protected override void CheckForJudgements(bool userTriggered, double timeOffset
if (result == HitResult.None)
return;
ApplyJudgement(HitObject.Judgement, j => j.Result = result);
ApplyResult(Results.Single(), r => r.Type = result);
}
public virtual bool OnPressed(ManiaAction action)

View File

@ -98,8 +98,6 @@ private void createTicks()
}
}
public HoldNoteJudgement Judgement { get; private set; }
protected override IEnumerable<Judgement> CreateJudgements() => new[] { Judgement = new HoldNoteJudgement() };
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new HoldNoteJudgement() };
}
}

View File

@ -12,8 +12,6 @@ namespace osu.Game.Rulesets.Mania.Objects
/// </summary>
public class HoldNoteTick : ManiaHitObject
{
public HoldNoteTickJudgement Judgement { get; private set; }
protected override IEnumerable<Judgement> CreateJudgements() => new[] { Judgement = new HoldNoteTickJudgement() };
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new HoldNoteTickJudgement() };
}
}

View File

@ -12,8 +12,6 @@ namespace osu.Game.Rulesets.Mania.Objects
/// </summary>
public class Note : ManiaHitObject
{
public virtual ManiaJudgement Judgement { get; } = new ManiaJudgement();
protected override IEnumerable<Judgement> CreateJudgements() => new[] { Judgement };
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new ManiaJudgement() };
}
}

View File

@ -1,12 +1,14 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Judgements;
namespace osu.Game.Rulesets.Mania.Objects
{
public class TailNote : Note
{
public override ManiaJudgement Judgement { get; } = new HoldNoteTailJudgement();
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new ManiaJudgement() };
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Judgements;
@ -97,31 +96,20 @@ public ManiaScoreProcessor(RulesetContainer<ManiaHitObject> rulesetContainer)
{
}
protected override void SimulateAutoplay(Beatmap<ManiaHitObject> beatmap)
protected override void ApplyBeatmap(Beatmap<ManiaHitObject> beatmap)
{
base.ApplyBeatmap(beatmap);
BeatmapDifficulty difficulty = beatmap.BeatmapInfo.BaseDifficulty;
hpMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_min, hp_multiplier_mid, hp_multiplier_max);
hpMissMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_miss_min, hp_multiplier_miss_mid, hp_multiplier_miss_max);
}
protected override void SimulateAutoplay(Beatmap<ManiaHitObject> beatmap)
{
while (true)
{
foreach (var obj in beatmap.HitObjects)
{
var holdNote = obj as HoldNote;
if (holdNote != null)
{
// Head
AddJudgement(new ManiaJudgement { Result = HitResult.Perfect });
// Ticks
int tickCount = holdNote.NestedHitObjects.OfType<HoldNoteTick>().Count();
for (int i = 0; i < tickCount; i++)
AddJudgement(new HoldNoteTickJudgement { Result = HitResult.Perfect });
}
AddJudgement(new ManiaJudgement { Result = HitResult.Perfect });
}
base.SimulateAutoplay(beatmap);
if (!HasFailed)
break;
@ -133,20 +121,20 @@ protected override void SimulateAutoplay(Beatmap<ManiaHitObject> beatmap)
}
}
protected override void OnNewJudgement(Judgement judgement)
protected override void OnNewJudgement(JudgementResult result)
{
base.OnNewJudgement(judgement);
base.OnNewJudgement(result);
bool isTick = judgement is HoldNoteTickJudgement;
bool isTick = result.Judgement is HoldNoteTickJudgement;
if (isTick)
{
if (judgement.IsHit)
if (result.IsHit)
Health.Value += hpMultiplier * hp_increase_tick;
}
else
{
switch (judgement.Result)
switch (result.Type)
{
case HitResult.Miss:
Health.Value += hpMissMultiplier * hp_increase_miss;

View File

@ -136,9 +136,9 @@ public override void Add(DrawableHitObject hitObject)
HitObjects.Add(hitObject);
}
internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
internal void OnJudgement(DrawableHitObject judgedObject, JudgementResult result)
{
if (!judgement.IsHit || !judgedObject.DisplayJudgement || !DisplayJudgements)
if (!result.IsHit || !judgedObject.DisplayJudgement || !DisplayJudgements)
return;
explosionContainer.Add(new HitExplosion(judgedObject)

View File

@ -10,8 +10,8 @@ namespace osu.Game.Rulesets.Mania.UI
{
internal class DrawableManiaJudgement : DrawableJudgement
{
public DrawableManiaJudgement(Judgement judgement, DrawableHitObject judgedObject)
: base(judgement, judgedObject)
public DrawableManiaJudgement(JudgementResult result, DrawableHitObject judgedObject)
: base(result, judgedObject)
{
}
@ -28,7 +28,7 @@ protected override void LoadComplete()
this.FadeInFromZero(50, Easing.OutQuint);
if (Judgement.IsHit)
if (Result.IsHit)
{
this.ScaleTo(0.8f);
this.ScaleTo(1, 250, Easing.OutElastic);

View File

@ -161,13 +161,13 @@ public override void Add(DrawableHitObject h)
public void Add(BarLine barline) => base.Add(new DrawableBarLine(barline));
internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
internal void OnJudgement(DrawableHitObject judgedObject, JudgementResult result)
{
if (!judgedObject.DisplayJudgement || !DisplayJudgements)
return;
judgements.Clear();
judgements.Add(new DrawableManiaJudgement(judgement, judgedObject)
judgements.Add(new DrawableManiaJudgement(result, judgedObject)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,