Flip condition to reduce nesting

This commit is contained in:
smoogipoo 2020-08-27 23:09:54 +09:00
parent 157e1d8965
commit 29b29cde8e
1 changed files with 18 additions and 18 deletions

View File

@ -101,28 +101,28 @@ private void onIsHittingChanged(ValueChangedEvent<bool> isHitting)
bodyAnimation.IsPlaying = isHitting.NewValue;
}
if (lightContainer != null)
if (lightContainer == null)
return;
if (isHitting.NewValue)
{
if (isHitting.NewValue)
{
// Clear the fade out and, more importantly, the removal.
lightContainer.ClearTransforms();
// Clear the fade out and, more importantly, the removal.
lightContainer.ClearTransforms();
// Only add the container if the removal has taken place.
if (lightContainer.Parent == null)
Column.TopLevelContainer.Add(lightContainer);
// Only add the container if the removal has taken place.
if (lightContainer.Parent == null)
Column.TopLevelContainer.Add(lightContainer);
// The light must be seeked only after being loaded, otherwise a nullref occurs (https://github.com/ppy/osu-framework/issues/3847).
if (light is TextureAnimation lightAnimation)
lightAnimation.GotoFrame(0);
// The light must be seeked only after being loaded, otherwise a nullref occurs (https://github.com/ppy/osu-framework/issues/3847).
if (light is TextureAnimation lightAnimation)
lightAnimation.GotoFrame(0);
lightContainer.FadeIn(80);
}
else
{
lightContainer.FadeOut(120)
.OnComplete(d => Column.TopLevelContainer.Remove(d));
}
lightContainer.FadeIn(80);
}
else
{
lightContainer.FadeOut(120)
.OnComplete(d => Column.TopLevelContainer.Remove(d));
}
}