mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 12:25:04 +08:00
General refactoring (no more casts :D).
This commit is contained in:
parent
36e8618370
commit
a9bc253b8c
@ -1,9 +1,4 @@
|
||||
using osu.Game.Modes.Judgements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Modes.Catch.Judgements
|
||||
{
|
||||
|
@ -1,9 +1,4 @@
|
||||
using osu.Game.Modes.Judgements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Modes.Mania.Judgements
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
{
|
||||
if (Judgement.Result.HasValue) return false;
|
||||
|
||||
((PositionalJudgementInfo)Judgement).PositionOffset = Vector2.Zero; //todo: set to correct value
|
||||
Judgement.PositionOffset = Vector2.Zero; //todo: set to correct value
|
||||
UpdateJudgement(true);
|
||||
return true;
|
||||
},
|
||||
@ -80,12 +80,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
||||
double hitOffset = Math.Abs(Judgement.TimeOffset);
|
||||
|
||||
OsuJudgementInfo osuJudgement = (OsuJudgementInfo)Judgement;
|
||||
|
||||
if (hitOffset < HitObject.HitWindowFor(OsuScoreResult.Hit50))
|
||||
{
|
||||
Judgement.Result = HitResult.Hit;
|
||||
osuJudgement.Score = HitObject.ScoreResultForOffset(hitOffset);
|
||||
Judgement.Score = HitObject.ScoreResultForOffset(hitOffset);
|
||||
}
|
||||
else
|
||||
Judgement.Result = HitResult.Miss;
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.ComponentModel;
|
||||
using osu.Game.Modes.Judgements;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
@ -125,27 +125,24 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
||||
protected override void CheckJudgement(bool userTriggered)
|
||||
{
|
||||
var j = (OsuJudgementInfo)Judgement;
|
||||
var sc = (OsuJudgementInfo)initialCircle.Judgement;
|
||||
|
||||
if (!userTriggered && Time.Current >= HitObject.EndTime)
|
||||
{
|
||||
var ticksCount = ticks.Children.Count() + 1;
|
||||
var ticksHit = ticks.Children.Count(t => t.Judgement.Result == HitResult.Hit);
|
||||
if (sc.Result == HitResult.Hit)
|
||||
if (initialCircle.Judgement.Result == HitResult.Hit)
|
||||
ticksHit++;
|
||||
|
||||
var hitFraction = (double)ticksHit / ticksCount;
|
||||
if (hitFraction == 1 && sc.Score == OsuScoreResult.Hit300)
|
||||
j.Score = OsuScoreResult.Hit300;
|
||||
else if (hitFraction >= 0.5 && sc.Score >= OsuScoreResult.Hit100)
|
||||
j.Score = OsuScoreResult.Hit100;
|
||||
if (hitFraction == 1 && initialCircle.Judgement.Score == OsuScoreResult.Hit300)
|
||||
Judgement.Score = OsuScoreResult.Hit300;
|
||||
else if (hitFraction >= 0.5 && initialCircle.Judgement.Score >= OsuScoreResult.Hit100)
|
||||
Judgement.Score = OsuScoreResult.Hit100;
|
||||
else if (hitFraction > 0)
|
||||
j.Score = OsuScoreResult.Hit50;
|
||||
Judgement.Score = OsuScoreResult.Hit50;
|
||||
else
|
||||
j.Score = OsuScoreResult.Miss;
|
||||
Judgement.Score = OsuScoreResult.Miss;
|
||||
|
||||
j.Result = j.Score != OsuScoreResult.Miss ? HitResult.Hit : HitResult.Miss;
|
||||
Judgement.Result = Judgement.Score != OsuScoreResult.Miss ? HitResult.Hit : HitResult.Miss;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using osu.Game.Modes.Judgements;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
@ -72,12 +71,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
||||
protected override void CheckJudgement(bool userTriggered)
|
||||
{
|
||||
var j = (OsuJudgementInfo)Judgement;
|
||||
|
||||
if (Judgement.TimeOffset >= 0)
|
||||
{
|
||||
j.Result = Tracking ? HitResult.Hit : HitResult.Miss;
|
||||
j.Score = Tracking ? OsuScoreResult.SliderTick : OsuScoreResult.Miss;
|
||||
Judgement.Result = Tracking ? HitResult.Hit : HitResult.Miss;
|
||||
Judgement.Score = Tracking ? OsuScoreResult.SliderTick : OsuScoreResult.Miss;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
{
|
||||
if (Time.Current < HitObject.StartTime) return;
|
||||
|
||||
var j = (OsuJudgementInfo)Judgement;
|
||||
|
||||
disc.ScaleTo(Interpolation.ValueAt(Math.Sqrt(Progress), scaleToCircle, Vector2.One, 0, 1), 100);
|
||||
|
||||
if (Progress >= 1)
|
||||
@ -86,24 +84,24 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
{
|
||||
if (Progress >= 1)
|
||||
{
|
||||
j.Score = OsuScoreResult.Hit300;
|
||||
j.Result = HitResult.Hit;
|
||||
Judgement.Score = OsuScoreResult.Hit300;
|
||||
Judgement.Result = HitResult.Hit;
|
||||
}
|
||||
else if (Progress > .9)
|
||||
{
|
||||
j.Score = OsuScoreResult.Hit100;
|
||||
j.Result = HitResult.Hit;
|
||||
Judgement.Score = OsuScoreResult.Hit100;
|
||||
Judgement.Result = HitResult.Hit;
|
||||
}
|
||||
else if (Progress > .75)
|
||||
{
|
||||
j.Score = OsuScoreResult.Hit50;
|
||||
j.Result = HitResult.Hit;
|
||||
Judgement.Score = OsuScoreResult.Hit50;
|
||||
Judgement.Result = HitResult.Hit;
|
||||
}
|
||||
else
|
||||
{
|
||||
j.Score = OsuScoreResult.Miss;
|
||||
Judgement.Score = OsuScoreResult.Miss;
|
||||
if (Time.Current >= HitObject.EndTime)
|
||||
j.Result = HitResult.Miss;
|
||||
Judgement.Result = HitResult.Miss;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,7 @@ using osu.Game.Modes.Osu.Objects.Drawables.Connections;
|
||||
using osu.Game.Modes.UI;
|
||||
using System.Linq;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Modes.Judgements;
|
||||
using OpenTK.Graphics;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Modes.Osu.UI
|
||||
{
|
||||
|
@ -1,9 +1,4 @@
|
||||
using osu.Game.Modes.Judgements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Judgements
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes.Judgements;
|
||||
|
@ -16,15 +16,36 @@ using osu.Game.Modes.Judgements;
|
||||
|
||||
namespace osu.Game.Modes.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Base HitRenderer. Doesn't hold objects, should not be derived.
|
||||
/// </summary>
|
||||
public abstract class HitRenderer : Container
|
||||
{
|
||||
/// <summary>
|
||||
/// The event that's fired when a hit object is judged.
|
||||
/// </summary>
|
||||
public event Action<JudgementInfo> OnJudgement;
|
||||
|
||||
/// <summary>
|
||||
/// The event that's fired when all hit objects have been judged.
|
||||
/// </summary>
|
||||
public event Action OnAllJudged;
|
||||
|
||||
/// <summary>
|
||||
/// The input manager for this HitRenderer.
|
||||
/// </summary>
|
||||
internal readonly PlayerInputManager InputManager = new PlayerInputManager();
|
||||
|
||||
/// <summary>
|
||||
/// The key conversion input manager for this HitRenderer.
|
||||
/// </summary>
|
||||
protected readonly KeyConversionInputManager KeyConversionInputManager;
|
||||
|
||||
/// <summary>
|
||||
/// Whether all the HitObjects have been judged.
|
||||
/// </summary>
|
||||
protected abstract bool AllObjectsJudged { get; }
|
||||
|
||||
protected HitRenderer()
|
||||
{
|
||||
KeyConversionInputManager = CreateKeyConversionInputManager();
|
||||
@ -32,10 +53,9 @@ namespace osu.Game.Modes.UI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether all the HitObjects have been judged.
|
||||
/// Triggers a judgement for further processing.
|
||||
/// </summary>
|
||||
protected abstract bool AllObjectsJudged { get; }
|
||||
|
||||
/// <param name="j">The judgement to trigger.</param>
|
||||
protected void TriggerOnJudgement(JudgementInfo j)
|
||||
{
|
||||
OnJudgement?.Invoke(j);
|
||||
@ -44,12 +64,24 @@ namespace osu.Game.Modes.UI
|
||||
OnAllJudged?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a key conversion input manager.
|
||||
/// </summary>
|
||||
/// <returns>The input manager.</returns>
|
||||
protected virtual KeyConversionInputManager CreateKeyConversionInputManager() => new KeyConversionInputManager();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HitRenderer that applies conversion to Beatmaps. Does not contain a Playfield
|
||||
/// and does not load drawable hit objects.
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">The type of HitObject contained by this HitRenderer.</typeparam>
|
||||
public abstract class HitRenderer<TObject> : HitRenderer
|
||||
where TObject : HitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The Beatmap
|
||||
/// </summary>
|
||||
public Beatmap<TObject> Beatmap;
|
||||
|
||||
protected HitRenderer(WorkingBeatmap beatmap)
|
||||
@ -61,6 +93,10 @@ namespace osu.Game.Modes.UI
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the active mods to this HitRenderer.
|
||||
/// </summary>
|
||||
/// <param name="mods"></param>
|
||||
private void applyMods(IEnumerable<Mod> mods)
|
||||
{
|
||||
if (mods == null)
|
||||
@ -70,9 +106,18 @@ namespace osu.Game.Modes.UI
|
||||
mod.Apply(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a converter to convert Beatmap to a specific mode.
|
||||
/// </summary>
|
||||
/// <returns>The Beatmap converter.</returns>
|
||||
protected abstract IBeatmapConverter<TObject> CreateBeatmapConverter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A derivable HitRenderer that manages the Playfield and HitObjects.
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">The type of HitObject contained by this HitRenderer.</typeparam>
|
||||
/// <typeparam name="TJudgement">The type of Judgement of DrawableHitObjects contained by this HitRenderer.</typeparam>
|
||||
public abstract class HitRenderer<TObject, TJudgement> : HitRenderer<TObject>
|
||||
where TObject : HitObject
|
||||
where TJudgement : JudgementInfo
|
||||
@ -80,6 +125,9 @@ namespace osu.Game.Modes.UI
|
||||
protected override Container<Drawable> Content => content;
|
||||
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
|
||||
|
||||
/// <summary>
|
||||
/// The playfield.
|
||||
/// </summary>
|
||||
protected Playfield<TObject, TJudgement> Playfield;
|
||||
|
||||
private Container content;
|
||||
@ -124,13 +172,27 @@ namespace osu.Game.Modes.UI
|
||||
Playfield.PostProcess();
|
||||
}
|
||||
|
||||
private void onJudgement(DrawableHitObject<TObject, TJudgement> j)
|
||||
/// <summary>
|
||||
/// Triggered when an object's Judgement is updated.
|
||||
/// </summary>
|
||||
/// <param name="judgedObject">The object that Judgement has been updated for.</param>
|
||||
private void onJudgement(DrawableHitObject<TObject, TJudgement> judgedObject)
|
||||
{
|
||||
TriggerOnJudgement(j.Judgement);
|
||||
Playfield.OnJudgement(j);
|
||||
TriggerOnJudgement(judgedObject.Judgement);
|
||||
Playfield.OnJudgement(judgedObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a DrawableHitObject from a HitObject.
|
||||
/// </summary>
|
||||
/// <param name="h">The HitObject to make drawable.</param>
|
||||
/// <returns>The DrawableHitObject.</returns>
|
||||
protected abstract DrawableHitObject<TObject, TJudgement> GetVisualRepresentation(TObject h);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Playfield.
|
||||
/// </summary>
|
||||
/// <returns>The Playfield.</returns>
|
||||
protected abstract Playfield<TObject, TJudgement> CreatePlayfield();
|
||||
}
|
||||
}
|
||||
|
@ -14,16 +14,15 @@ namespace osu.Game.Modes.UI
|
||||
where TObject : HitObject
|
||||
where TJudgement : JudgementInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The HitObjects contained in this Playfield.
|
||||
/// </summary>
|
||||
public HitObjectContainer<DrawableHitObject<TObject, TJudgement>> HitObjects;
|
||||
|
||||
public virtual void Add(DrawableHitObject<TObject, TJudgement> h) => HitObjects.Add(h);
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
internal Container<Drawable> ScaledContent;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private Container<Drawable> content;
|
||||
|
||||
/// <summary>
|
||||
@ -51,9 +50,22 @@ namespace osu.Game.Modes.UI
|
||||
});
|
||||
}
|
||||
|
||||
public virtual void PostProcess()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs post-processing tasks (if any) after all DrawableHitObjects are loaded into this Playfield.
|
||||
/// </summary>
|
||||
public virtual void PostProcess() { }
|
||||
|
||||
/// <summary>
|
||||
/// Adds a DrawableHitObject to this Playfield.
|
||||
/// </summary>
|
||||
/// <param name="h">The DrawableHitObject to add.</param>
|
||||
public virtual void Add(DrawableHitObject<TObject, TJudgement> h) => HitObjects.Add(h);
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when an object's Judgement is updated.
|
||||
/// </summary>
|
||||
/// <param name="judgedObject">The object that Judgement has been updated for.</param>
|
||||
public virtual void OnJudgement(DrawableHitObject<TObject, TJudgement> judgedObject) { }
|
||||
|
||||
private class ScaledContainer : Container
|
||||
{
|
||||
@ -72,7 +84,5 @@ namespace osu.Game.Modes.UI
|
||||
{
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
}
|
||||
|
||||
public virtual void OnJudgement(DrawableHitObject<TObject, TJudgement> judgedObject) { }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user