1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 21:02:55 +08:00

Mark the property as non-nullable.

This commit is contained in:
andy840119 2022-07-31 21:43:16 +08:00
parent 72961ec336
commit 632577389d
7 changed files with 14 additions and 34 deletions

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.StateChanges;
@ -29,20 +28,16 @@ namespace osu.Game.Rulesets.Osu.Mods
public bool RestartOnFail => false;
private OsuInputManager? inputManager;
private OsuInputManager inputManager = null!;
private IFrameStableClock? gameplayClock;
private IFrameStableClock gameplayClock = null!;
private List<OsuReplayFrame>? replayFrames;
private List<OsuReplayFrame> replayFrames = null!;
private int currentFrame;
public void Update(Playfield playfield)
{
Debug.Assert(inputManager != null);
Debug.Assert(gameplayClock != null);
Debug.Assert(replayFrames != null);
if (currentFrame == replayFrames.Count - 1) return;
double time = gameplayClock.CurrentTime;

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -32,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public override double ScoreMultiplier => UsesDefaultConfiguration ? 1.12 : 1;
public override Type[] IncompatibleMods => new[] { typeof(OsuModFlashlight) };
private DrawableOsuBlinds? blinds;
private DrawableOsuBlinds blinds = null!;
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
@ -41,8 +40,6 @@ namespace osu.Game.Rulesets.Osu.Mods
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
{
Debug.Assert(blinds != null);
healthProcessor.Health.ValueChanged += health => { blinds.AnimateClosedness((float)health.NewValue); };
}

View File

@ -4,7 +4,6 @@
using System;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Events;
@ -52,14 +51,14 @@ namespace osu.Game.Rulesets.Osu.Mods
public override float DefaultFlashlightSize => 180;
private OsuFlashlight? flashlight;
private OsuFlashlight flashlight = null!;
protected override Flashlight CreateFlashlight() => flashlight = new OsuFlashlight(this);
public void ApplyToDrawableHitObject(DrawableHitObject drawable)
{
if (drawable is DrawableSlider s)
s.Tracking.ValueChanged += flashlight.AsNonNull().OnSliderTrackingChange;
s.Tracking.ValueChanged += flashlight.OnSliderTrackingChange;
}
private class OsuFlashlight : Flashlight, IRequireHighFrequencyMousePosition

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Diagnostics;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Utils;
@ -27,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(OsuModAutopilot), typeof(OsuModWiggle), typeof(OsuModTransform), typeof(ModAutoplay), typeof(OsuModRelax), typeof(OsuModRepel) };
private IFrameStableClock? gameplayClock;
private IFrameStableClock gameplayClock = null!;
[SettingSource("Attraction strength", "How strong the pull is.", 0)]
public BindableFloat AttractionStrength { get; } = new BindableFloat(0.5f)
@ -75,8 +74,6 @@ namespace osu.Game.Rulesets.Osu.Mods
{
double dampLength = Interpolation.Lerp(3000, 40, AttractionStrength.Value);
Debug.Assert(gameplayClock != null);
float x = (float)Interpolation.DampContinuously(hitObject.X, destination.X, dampLength, gameplayClock.ElapsedFrameTime);
float y = (float)Interpolation.DampContinuously(hitObject.Y, destination.Y, dampLength, gameplayClock.ElapsedFrameTime);

View File

@ -4,7 +4,6 @@
using System;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
@ -20,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{
public override string Description => "Where's the cursor?";
private PeriodTracker? spinnerPeriods;
private PeriodTracker spinnerPeriods = null!;
[SettingSource(
"Hidden at combo",
@ -42,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public void Update(Playfield playfield)
{
bool shouldAlwaysShowCursor = IsBreakTime.Value || spinnerPeriods.AsNonNull().IsInAny(playfield.Clock.CurrentTime);
bool shouldAlwaysShowCursor = IsBreakTime.Value || spinnerPeriods.IsInAny(playfield.Clock.CurrentTime);
float targetAlpha = shouldAlwaysShowCursor ? 1 : ComboBasedAlpha;
playfield.Cursor.Alpha = (float)Interpolation.Lerp(playfield.Cursor.Alpha, targetAlpha, Math.Clamp(playfield.Time.Elapsed / TRANSITION_DURATION, 0, 1));
}

View File

@ -29,9 +29,9 @@ namespace osu.Game.Rulesets.Osu.Mods
private bool isDownState;
private bool wasLeft;
private OsuInputManager? osuInputManager;
private OsuInputManager osuInputManager = null!;
private ReplayState<OsuAction>? state;
private ReplayState<OsuAction> state = null!;
private double lastStateChangeTime;
private bool hasReplay;
@ -44,8 +44,6 @@ namespace osu.Game.Rulesets.Osu.Mods
public void ApplyToPlayer(Player player)
{
Debug.Assert(osuInputManager != null);
if (osuInputManager.ReplayInputHandler != null)
{
hasReplay = true;
@ -134,9 +132,7 @@ namespace osu.Game.Rulesets.Osu.Mods
wasLeft = !wasLeft;
}
Debug.Assert(osuInputManager != null);
state?.Apply(osuInputManager.CurrentState, osuInputManager);
state.Apply(osuInputManager.CurrentState, osuInputManager);
}
}
}

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
@ -96,7 +95,7 @@ namespace osu.Game.Rulesets.Osu.Mods
#region Private Fields
private ControlPointInfo? controlPointInfo;
private ControlPointInfo controlPointInfo = null!;
#endregion
@ -156,7 +155,7 @@ namespace osu.Game.Rulesets.Osu.Mods
circle.ApproachCircle.Hide();
}
using (circle.BeginAbsoluteSequence(startTime - controlPointInfo.AsNonNull().TimingPointAt(startTime).BeatLength - undim_duration))
using (circle.BeginAbsoluteSequence(startTime - controlPointInfo.TimingPointAt(startTime).BeatLength - undim_duration))
circle.FadeColour(Color4.White, undim_duration);
}
@ -372,8 +371,6 @@ namespace osu.Game.Rulesets.Osu.Mods
int i = 0;
double currentTime = timingPoint.Time;
Debug.Assert(controlPointInfo != null);
while (!definitelyBigger(currentTime, mapEndTime) && ReferenceEquals(controlPointInfo.TimingPointAt(currentTime), timingPoint))
{
beats.Add(Math.Floor(currentTime));