Mark the property as nullable and add some assert check.

This commit is contained in:
為什麼 2022-07-11 00:00:48 +08:00 committed by andy840119
parent d766052be4
commit 860e9d42ff
3 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,7 @@
// 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.
using System.Diagnostics;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.UI;
@ -10,7 +11,7 @@ namespace osu.Game.Rulesets.Taiko.Mods
{
public class TaikoModClassic : ModClassic, IApplicableToDrawableRuleset<TaikoHitObject>, IUpdatableByPlayfield
{
private DrawableTaikoRuleset drawableTaikoRuleset;
private DrawableTaikoRuleset? drawableTaikoRuleset;
public void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset)
{
@ -23,6 +24,8 @@ namespace osu.Game.Rulesets.Taiko.Mods
public void Update(Playfield playfield)
{
Debug.Assert(drawableTaikoRuleset != null);
// Classic taiko scrolls at a constant 100px per 1000ms. More notes become visible as the playfield is lengthened.
const float scroll_rate = 10;

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Layout;
using osu.Game.Configuration;
@ -36,9 +37,9 @@ namespace osu.Game.Rulesets.Taiko.Mods
public override float DefaultFlashlightSize => 250;
protected override Flashlight CreateFlashlight() => new TaikoFlashlight(this, playfield);
protected override Flashlight CreateFlashlight() => new TaikoFlashlight(this, playfield.AsNonNull());
private TaikoPlayfield playfield;
private TaikoPlayfield? playfield;
public override void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset)
{

View File

@ -1,6 +1,7 @@
// 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.
using System.Diagnostics;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
@ -30,7 +31,7 @@ namespace osu.Game.Rulesets.Taiko.Mods
/// </summary>
private const float fade_out_duration = 0.375f;
private DrawableTaikoRuleset drawableRuleset;
private DrawableTaikoRuleset? drawableRuleset;
public void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset)
{
@ -44,6 +45,8 @@ namespace osu.Game.Rulesets.Taiko.Mods
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
{
Debug.Assert(drawableRuleset != null);
switch (hitObject)
{
case DrawableDrumRollTick: