mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Fix crashing if selected ruleset doesn't have an autoplay mod.
This commit is contained in:
parent
efbc02b521
commit
e9b09373e7
@ -100,7 +100,7 @@ namespace osu.Game.Rulesets
|
||||
return value;
|
||||
}
|
||||
|
||||
public ModAutoplay GetAutoplayMod() => GetAllMods().OfType<ModAutoplay>().First();
|
||||
public ModAutoplay GetAutoplayMod() => GetAllMods().OfType<ModAutoplay>().FirstOrDefault();
|
||||
|
||||
public virtual ISkin CreateLegacySkinProvider(ISkinSource source, IBeatmap beatmap) => null;
|
||||
|
||||
|
@ -49,8 +49,11 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
if (removeAutoModOnResume)
|
||||
{
|
||||
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
|
||||
ModSelect.DeselectTypes(new[] { autoType }, true);
|
||||
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod()?.GetType();
|
||||
|
||||
if (autoType != null)
|
||||
ModSelect.DeselectTypes(new[] { autoType }, true);
|
||||
|
||||
removeAutoModOnResume = false;
|
||||
}
|
||||
}
|
||||
@ -78,14 +81,17 @@ namespace osu.Game.Screens.Select
|
||||
if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true)
|
||||
{
|
||||
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
|
||||
var autoType = auto.GetType();
|
||||
var autoType = auto?.GetType();
|
||||
|
||||
var mods = Mods.Value;
|
||||
|
||||
if (mods.All(m => m.GetType() != autoType))
|
||||
if (autoType != null)
|
||||
{
|
||||
Mods.Value = mods.Append(auto).ToArray();
|
||||
removeAutoModOnResume = true;
|
||||
var mods = Mods.Value;
|
||||
|
||||
if (mods.All(m => m.GetType() != autoType))
|
||||
{
|
||||
Mods.Value = mods.Append(auto).ToArray();
|
||||
removeAutoModOnResume = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user