mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 13:32:54 +08:00
Move result creation to load(), add exceptions
This commit is contained in:
parent
b35817c877
commit
754f3c8621
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
@ -70,7 +71,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
/// <summary>
|
||||
/// The scoring result of this <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
public readonly JudgementResult Result;
|
||||
public JudgementResult Result { get; private set; }
|
||||
|
||||
private bool judgementOccurred;
|
||||
|
||||
@ -87,14 +88,19 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
protected DrawableHitObject(HitObject hitObject)
|
||||
{
|
||||
HitObject = hitObject;
|
||||
|
||||
if (hitObject.Judgement != null)
|
||||
Result = CreateJudgementResult(hitObject.Judgement);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
if (HitObject.Judgement != null)
|
||||
{
|
||||
Result = CreateJudgementResult(HitObject.Judgement);
|
||||
|
||||
if (Result == null)
|
||||
throw new InvalidOperationException($"{GetType().ReadableName()} must provide a {nameof(JudgementResult)} through {nameof(CreateJudgementResult)}.");
|
||||
}
|
||||
|
||||
var samples = GetSamples().ToArray();
|
||||
|
||||
if (samples.Any())
|
||||
@ -188,6 +194,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
{
|
||||
application?.Invoke(Result);
|
||||
|
||||
if (!Result.HasResult)
|
||||
throw new InvalidOperationException($"{GetType().ReadableName()} applied a {nameof(JudgementResult)} but did not update {nameof(JudgementResult.Type)}.");
|
||||
|
||||
judgementOccurred = true;
|
||||
|
||||
// Ensure that the judgement is given a valid time offset, because this may not get set by the caller
|
||||
|
Loading…
Reference in New Issue
Block a user