Remove many now unnecessary null-checks

This commit is contained in:
Dean Herbert 2017-07-19 15:45:23 +09:00
parent 21d07428fe
commit 64ebc01a3b
7 changed files with 19 additions and 19 deletions

View File

@ -35,7 +35,7 @@ namespace osu.Game.Graphics.Containers
protected override void Update() protected override void Update()
{ {
var track = Beatmap.Value?.Track; var track = Beatmap.Value.Track;
if (track == null) if (track == null)
return; return;

View File

@ -86,13 +86,15 @@ namespace osu.Game.Screens.Menu
private void updateAmplitudes() private void updateAmplitudes()
{ {
float[] temporalAmplitudes = beatmap.Value?.Track?.CurrentAmplitudes.FrequencyAmplitudes ?? new float[256]; var track = beatmap.Value.Track;
var effect = beatmap.Value?.Beatmap.ControlPointInfo.EffectPointAt(beatmap.Value.Track?.CurrentTime ?? Time.Current); float[] temporalAmplitudes = track?.CurrentAmplitudes.FrequencyAmplitudes ?? new float[256];
var effect = beatmap.Value.Beatmap.ControlPointInfo.EffectPointAt(track?.CurrentTime ?? Time.Current);
for (int i = 0; i < bars_per_visualiser; i++) for (int i = 0; i < bars_per_visualiser; i++)
{ {
if (beatmap?.Value?.Track?.IsRunning ?? false) if (track?.IsRunning ?? false)
{ {
float targetAmplitude = temporalAmplitudes[(i + indexOffset) % bars_per_visualiser] * (effect?.KiaiMode == true ? 1 : 0.5f); float targetAmplitude = temporalAmplitudes[(i + indexOffset) % bars_per_visualiser] * (effect?.KiaiMode == true ? 1 : 0.5f);
if (targetAmplitude > frequencyAmplitudes[i]) if (targetAmplitude > frequencyAmplitudes[i])

View File

@ -275,7 +275,7 @@ namespace osu.Game.Screens.Menu
const float scale_adjust_cutoff = 0.4f; const float scale_adjust_cutoff = 0.4f;
const float velocity_adjust_cutoff = 0.98f; const float velocity_adjust_cutoff = 0.98f;
var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value?.Track?.CurrentAmplitudes.Maximum ?? 0 : 0; var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value.Track?.CurrentAmplitudes.Maximum ?? 0 : 0;
logoAmplitudeContainer.ScaleTo(1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.04f, 75, EasingTypes.OutQuint); logoAmplitudeContainer.ScaleTo(1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.04f, 75, EasingTypes.OutQuint);
if (maxAmplitude > velocity_adjust_cutoff) if (maxAmplitude > velocity_adjust_cutoff)

View File

@ -81,10 +81,11 @@ namespace osu.Game.Screens.Play
try try
{ {
if (Beatmap.Value == null) if (!Beatmap.Value.WithStoryboard)
// we need to ensure the storyboard is loaded.
Beatmap.Value = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true); Beatmap.Value = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true);
if (Beatmap.Value?.Beatmap == null) if (Beatmap.Value.Beatmap == null)
throw new InvalidOperationException("Beatmap was not loaded"); throw new InvalidOperationException("Beatmap was not loaded");
ruleset = osu?.Ruleset.Value ?? Beatmap.Value.BeatmapInfo.Ruleset; ruleset = osu?.Ruleset.Value ?? Beatmap.Value.BeatmapInfo.Ruleset;

View File

@ -165,7 +165,7 @@ namespace osu.Game.Screens.Ranking
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Alpha = 0.2f, Alpha = 0.2f,
Texture = Beatmap.Value?.Background, Texture = Beatmap.Value.Background,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
FillMode = FillMode.Fill FillMode = FillMode.Fill

View File

@ -59,14 +59,14 @@ namespace osu.Game.Screens.Select
{ {
if (!IsCurrentScreen) return; if (!IsCurrentScreen) return;
beatmap?.Mods.BindTo(modSelect.SelectedMods); beatmap.Mods.BindTo(modSelect.SelectedMods);
if (Beatmap.Value?.Track != null) if (Beatmap.Value.Track != null)
Beatmap.Value.Track.Looping = false; Beatmap.Value.Track.Looping = false;
beatmapDetails.Beatmap = beatmap; beatmapDetails.Beatmap = beatmap;
if (beatmap?.Track != null) if (beatmap.Track != null)
beatmap.Track.Looping = true; beatmap.Track.Looping = true;
} }
@ -97,7 +97,7 @@ namespace osu.Game.Screens.Select
if (base.OnExiting(next)) if (base.OnExiting(next))
return true; return true;
if (Beatmap.Value?.Track != null) if (Beatmap.Value.Track != null)
Beatmap.Value.Track.Looping = false; Beatmap.Value.Track.Looping = false;
return false; return false;

View File

@ -224,7 +224,7 @@ namespace osu.Game.Screens.Select
if (beatmap.Equals(beatmapNoDebounce)) if (beatmap.Equals(beatmapNoDebounce))
return; return;
bool preview = beatmap.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID; bool preview = beatmap.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID;
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID) if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
sampleChangeDifficulty.Play(); sampleChangeDifficulty.Play();
@ -347,16 +347,13 @@ namespace osu.Game.Screens.Select
private void ensurePlayingSelected(bool preview = false) private void ensurePlayingSelected(bool preview = false)
{ {
Track track = Beatmap.Value?.Track; Track track = Beatmap.Value.Track;
trackManager.SetExclusive(track); trackManager.SetExclusive(track);
if (track != null)
{
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime); if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
track.Start(); track.Start();
} }
}
private void removeBeatmapSet(BeatmapSetInfo beatmapSet) private void removeBeatmapSet(BeatmapSetInfo beatmapSet)
{ {