Nullable annotate classes

This commit is contained in:
Dan Balasescu 2022-03-14 15:38:00 +09:00
parent 926827207a
commit 9cc7f70872
3 changed files with 14 additions and 8 deletions

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable enable
using System;
using osu.Framework.Bindables;
using osu.Framework.Utils;
@ -14,12 +16,12 @@ public abstract class HealthProcessor : JudgementProcessor
/// Invoked when the <see cref="ScoreProcessor"/> is in a failed state.
/// Return true if the fail was permitted.
/// </summary>
public event Func<bool> Failed;
public event Func<bool>? Failed;
/// <summary>
/// Additional conditions on top of <see cref="DefaultFailCondition"/> that cause a failing state.
/// </summary>
public event Func<HealthProcessor, JudgementResult, bool> FailConditions;
public event Func<HealthProcessor, JudgementResult, bool>? FailConditions;
/// <summary>
/// The current health.

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable enable
using System;
using osu.Framework.Bindables;
using osu.Framework.Extensions.TypeExtensions;
@ -17,12 +19,12 @@ public abstract class JudgementProcessor : Component
/// <summary>
/// Invoked when a new judgement has occurred. This occurs after the judgement has been processed by this <see cref="JudgementProcessor"/>.
/// </summary>
public event Action<JudgementResult> NewJudgement;
public event Action<JudgementResult>? NewJudgement;
/// <summary>
/// Invoked when a judgement is reverted, usually due to rewinding gameplay.
/// </summary>
public event Action<JudgementResult> JudgementReverted;
public event Action<JudgementResult>? JudgementReverted;
/// <summary>
/// The maximum number of hits that can be judged.
@ -34,7 +36,7 @@ public abstract class JudgementProcessor : Component
/// </summary>
public int JudgedHits { get; private set; }
private JudgementResult lastAppliedResult;
private JudgementResult? lastAppliedResult;
private readonly BindableBool hasCompleted = new BindableBool();
@ -163,7 +165,7 @@ void simulate(HitObject obj)
protected override void Update()
{
base.Update();
hasCompleted.Value = JudgedHits == MaxHits && (JudgedHits == 0 || lastAppliedResult.TimeAbsolute < Clock.CurrentTime);
hasCompleted.Value = JudgedHits == MaxHits && (JudgedHits == 0 || lastAppliedResult?.TimeAbsolute < Clock.CurrentTime);
}
/// <summary>

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -24,7 +26,7 @@ public class ScoreProcessor : JudgementProcessor
/// <summary>
/// Invoked when this <see cref="ScoreProcessor"/> was reset from a replay frame.
/// </summary>
public event Action OnResetFromReplayFrame;
public event Action? OnResetFromReplayFrame;
/// <summary>
/// The current total score.
@ -110,7 +112,7 @@ public class ScoreProcessor : JudgementProcessor
private readonly Dictionary<HitResult, int> scoreResultCounts = new Dictionary<HitResult, int>();
private readonly List<HitEvent> hitEvents = new List<HitEvent>();
private HitObject lastHitObject;
private HitObject? lastHitObject;
private double scoreMultiplier = 1;