1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Merge pull request #733 from smoogipooo/hitrenderer-improvements

Hitrenderer improvements
This commit is contained in:
Dean Herbert 2017-05-11 15:16:45 +09:00 committed by GitHub
commit 057d0cd523
3 changed files with 21 additions and 6 deletions

View File

@ -12,6 +12,7 @@ using Container = osu.Framework.Graphics.Containers.Container;
using osu.Game.Rulesets.Objects.Types;
using OpenTK.Graphics;
using osu.Game.Audio;
using System.Linq;
namespace osu.Game.Rulesets.Objects.Drawables
{
@ -24,6 +25,11 @@ namespace osu.Game.Rulesets.Objects.Drawables
public TJudgement Judgement;
/// <summary>
/// Whether this hit object has been judged.
/// </summary>
public virtual bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None;
protected abstract TJudgement CreateJudgement();
protected abstract void UpdateState(ArmedState state);
@ -86,6 +92,11 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </summary>
public Color4 AccentColour { get; protected set; }
/// <summary>
/// Whether this hit object and all of its nested hit objects have been judged.
/// </summary>
public sealed override bool Judged => base.Judged && (NestedHitObjects?.All(h => h.Judged) ?? true);
protected DrawableHitObject(TObject hitObject)
{
HitObject = hitObject;
@ -97,7 +108,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// <returns>Whether a hit was processed.</returns>
protected bool UpdateJudgement(bool userTriggered)
{
IPartialJudgement partial = Judgement as IPartialJudgement;
var partial = Judgement as IPartialJudgement;
// Never re-process non-partial hits
if (Judgement.Result != HitResult.None && partial == null)
@ -169,7 +180,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
}
private List<DrawableHitObject<TObject, TJudgement>> nestedHitObjects;
protected IEnumerable<DrawableHitObject<TObject, TJudgement>> NestedHitObjects => nestedHitObjects;
protected void AddNested(DrawableHitObject<TObject, TJudgement> h)

View File

@ -187,17 +187,19 @@ namespace osu.Game.Rulesets.UI
public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor;
protected override Container<Drawable> Content => content;
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result != HitResult.None);
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
protected override bool AllObjectsJudged => drawableObjects.All(h => h.Judged);
/// <summary>
/// The playfield.
/// </summary>
protected Playfield<TObject, TJudgement> Playfield;
protected override Container<Drawable> Content => content;
private readonly Container content;
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
private readonly List<DrawableHitObject<TObject, TJudgement>> drawableObjects = new List<DrawableHitObject<TObject, TJudgement>>();
protected HitRenderer(WorkingBeatmap beatmap)
: base(beatmap)
@ -224,6 +226,8 @@ namespace osu.Game.Rulesets.UI
private void loadObjects()
{
drawableObjects.Capacity = Beatmap.HitObjects.Count;
foreach (TObject h in Beatmap.HitObjects)
{
var drawableObject = GetVisualRepresentation(h);
@ -233,6 +237,7 @@ namespace osu.Game.Rulesets.UI
drawableObject.OnJudgement += onJudgement;
drawableObjects.Add(drawableObject);
Playfield.Add(drawableObject);
}

View File

@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// The HitObjects contained in this Playfield.
/// </summary>
public HitObjectContainer<DrawableHitObject<TObject, TJudgement>> HitObjects;
protected HitObjectContainer<DrawableHitObject<TObject, TJudgement>> HitObjects;
internal Container<Drawable> ScaledContent;