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 @@ public class BeatSyncedContainer : Container
protected override void Update()
{
var track = Beatmap.Value?.Track;
var track = Beatmap.Value.Track;
if (track == null)
return;

View File

@ -86,13 +86,15 @@ private void load(ShaderManager shaders, OsuGame game)
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++)
{
if (beatmap?.Value?.Track?.IsRunning ?? false)
if (track?.IsRunning ?? false)
{
float targetAmplitude = temporalAmplitudes[(i + indexOffset) % bars_per_visualiser] * (effect?.KiaiMode == true ? 1 : 0.5f);
if (targetAmplitude > frequencyAmplitudes[i])

View File

@ -275,7 +275,7 @@ protected override void Update()
const float scale_adjust_cutoff = 0.4f;
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);
if (maxAmplitude > velocity_adjust_cutoff)

View File

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

View File

@ -165,7 +165,7 @@ private void load(OsuColour colours)
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.2f,
Texture = Beatmap.Value?.Background,
Texture = Beatmap.Value.Background,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill

View File

@ -59,14 +59,14 @@ private void beatmap_ValueChanged(WorkingBeatmap beatmap)
{
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;
beatmapDetails.Beatmap = beatmap;
if (beatmap?.Track != null)
if (beatmap.Track != null)
beatmap.Track.Looping = true;
}
@ -97,7 +97,7 @@ protected override bool OnExiting(Screen next)
if (base.OnExiting(next))
return true;
if (Beatmap.Value?.Track != null)
if (Beatmap.Value.Track != null)
Beatmap.Value.Track.Looping = false;
return false;

View File

@ -224,7 +224,7 @@ private void carouselSelectionChanged(BeatmapInfo beatmap)
if (beatmap.Equals(beatmapNoDebounce))
return;
bool preview = beatmap.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID;
bool preview = beatmap.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID;
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
sampleChangeDifficulty.Play();
@ -347,15 +347,12 @@ private void changeBackground(WorkingBeatmap beatmap)
private void ensurePlayingSelected(bool preview = false)
{
Track track = Beatmap.Value?.Track;
Track track = Beatmap.Value.Track;
trackManager.SetExclusive(track);
if (track != null)
{
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
track.Start();
}
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
track.Start();
}
private void removeBeatmapSet(BeatmapSetInfo beatmapSet)