Add a gameplay configuration flag to disable fail animation

This commit is contained in:
Dean Herbert 2024-01-04 16:41:52 +09:00
parent f0aeeeea96
commit 0bbc27e380
No known key found for this signature in database
4 changed files with 40 additions and 29 deletions

View File

@ -26,9 +26,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
protected override bool PauseOnFocusLost => false;
// Disallow fails in multiplayer for now.
protected override bool CheckModsAllowFailure() => false;
protected override UserActivity InitialActivity => new UserActivity.InMultiplayerGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
[Resolved]
@ -55,6 +52,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
AllowPause = false,
AllowRestart = false,
AllowFailAnimation = false,
AllowSkipping = room.AutoSkip.Value,
AutomaticallySkipIntro = room.AutoSkip.Value,
AlwaysShowLeaderboard = true,

View File

@ -46,7 +46,7 @@ namespace osu.Game.Screens.Play
public bool HasPassed { get; set; }
/// <summary>
/// Whether the user failed during gameplay.
/// Whether the user failed during gameplay. This is only set when the gameplay session has completed due to the fail.
/// </summary>
public bool HasFailed { get; set; }

View File

@ -735,7 +735,7 @@ namespace osu.Game.Screens.Play
}
// Only show the completion screen if the player hasn't failed
if (HealthProcessor.HasFailed)
if (GameplayState.HasFailed)
return;
GameplayState.HasPassed = true;
@ -924,37 +924,44 @@ namespace osu.Game.Screens.Play
if (!CheckModsAllowFailure())
return false;
Debug.Assert(!GameplayState.HasFailed);
Debug.Assert(!GameplayState.HasPassed);
Debug.Assert(!GameplayState.HasQuit);
if (Configuration.AllowFailAnimation)
{
Debug.Assert(!GameplayState.HasFailed);
Debug.Assert(!GameplayState.HasPassed);
Debug.Assert(!GameplayState.HasQuit);
GameplayState.HasFailed = true;
GameplayState.HasFailed = true;
updateGameplayState();
updateGameplayState();
// There is a chance that we could be in a paused state as the ruleset's internal clock (see FrameStabilityContainer)
// could process an extra frame after the GameplayClock is stopped.
// In such cases we want the fail state to precede a user triggered pause.
if (PauseOverlay.State.Value == Visibility.Visible)
PauseOverlay.Hide();
// There is a chance that we could be in a paused state as the ruleset's internal clock (see FrameStabilityContainer)
// could process an extra frame after the GameplayClock is stopped.
// In such cases we want the fail state to precede a user triggered pause.
if (PauseOverlay.State.Value == Visibility.Visible)
PauseOverlay.Hide();
failAnimationContainer.Start();
failAnimationContainer.Start();
// Failures can be triggered either by a judgement, or by a mod.
//
// For the case of a judgement, due to ordering considerations, ScoreProcessor will not have received
// the final judgement which triggered the failure yet (see DrawableRuleset.NewResult handling above).
//
// A schedule here ensures that any lingering judgements from the current frame are applied before we
// finalise the score as "failed".
Schedule(() =>
// Failures can be triggered either by a judgement, or by a mod.
//
// For the case of a judgement, due to ordering considerations, ScoreProcessor will not have received
// the final judgement which triggered the failure yet (see DrawableRuleset.NewResult handling above).
//
// A schedule here ensures that any lingering judgements from the current frame are applied before we
// finalise the score as "failed".
Schedule(() =>
{
ScoreProcessor.FailScore(Score.ScoreInfo);
OnFail();
if (GameplayState.Mods.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
Restart(true);
});
}
else
{
ScoreProcessor.FailScore(Score.ScoreInfo);
OnFail();
if (GameplayState.Mods.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
Restart(true);
});
}
return true;
}

View File

@ -15,6 +15,12 @@ namespace osu.Game.Screens.Play
/// </summary>
public bool ShowResults { get; set; } = true;
/// <summary>
/// Whether the fail animation / screen should be triggered on failing.
/// If false, the score will still be marked as failed but gameplay will continue.
/// </summary>
public bool AllowFailAnimation { get; set; } = true;
/// <summary>
/// Whether the player should be allowed to trigger a restart.
/// </summary>