osu/osu.Game/Screens/Play/GameplayState.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

104 lines
3.5 KiB
C#
Raw Normal View History

2021-10-01 17:22:23 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2021-10-05 05:48:10 +00:00
using System;
2021-10-01 17:22:23 +00:00
using System.Collections.Generic;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
2021-10-04 11:33:54 +00:00
using osu.Game.Scoring;
using osu.Game.Storyboards;
2021-10-01 17:22:23 +00:00
namespace osu.Game.Screens.Play
{
2021-10-01 17:28:35 +00:00
/// <summary>
/// The state of an active gameplay session, generally constructed and exposed by <see cref="Player"/>.
/// </summary>
2021-10-01 17:22:23 +00:00
public class GameplayState
{
/// <summary>
/// The final post-convert post-mod-application beatmap.
/// </summary>
public readonly IBeatmap Beatmap;
2021-10-01 17:28:35 +00:00
/// <summary>
/// The ruleset used in gameplay.
/// </summary>
2021-10-01 17:22:23 +00:00
public readonly Ruleset Ruleset;
2021-10-01 17:28:35 +00:00
/// <summary>
/// The mods applied to the gameplay.
/// </summary>
2021-10-04 11:20:24 +00:00
public readonly IReadOnlyList<Mod> Mods;
2021-10-01 17:22:23 +00:00
2021-10-04 11:33:54 +00:00
/// <summary>
/// The gameplay score.
/// </summary>
2021-10-05 05:48:10 +00:00
public readonly Score Score;
2021-10-04 11:33:54 +00:00
public readonly ScoreProcessor ScoreProcessor;
Implement toggling visibility of pass and fail storyboard layers Closes https://github.com/ppy/osu/issues/6842. This is a rather barebones implementation, just to get this in place somehow at least. The logic is simple - 50% health or above shows pass layer, anything below shows fail layer. This does not match stable logic all across the board because I have no idea how to package that. Stable defines "passing" in like fifty ways: - in mania it's >80% HP (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Rulesets/Mania/RulesetMania.cs#L333-L336) - in taiko it's >80% *accuracy* (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Rulesets/Taiko/RulesetTaiko.cs#L486-L492) - there's also the part where "geki additions" will unconditionally set passing state (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Player.cs#L3561-L3564) - and also the part where at the end of the map, the final passing state is determined by checking whether the user passed more sections than failed (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Player.cs#L3320) The biggest issues of these are probably the first two, and they can *probably* be fixed, but would require a new member on `Ruleset` and I'm not sure how to make one look, so I'm not doing that at this time pending collection of ideas on how to do that.
2024-06-14 11:36:40 +00:00
public readonly HealthProcessor HealthProcessor;
/// <summary>
/// The storyboard associated with the beatmap.
/// </summary>
public readonly Storyboard Storyboard;
/// <summary>
/// Whether gameplay completed without the user failing.
/// </summary>
public bool HasPassed { get; set; }
/// <summary>
/// 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; }
2022-01-25 17:02:31 +00:00
/// <summary>
2022-02-08 12:20:33 +00:00
/// Whether the user quit gameplay without having either passed or failed.
2022-01-25 17:02:31 +00:00
/// </summary>
public bool HasQuit { get; set; }
2021-10-01 17:28:35 +00:00
/// <summary>
/// A bindable tracking the last judgement result applied to any hit object.
/// </summary>
public IBindable<JudgementResult> LastJudgementResult => lastJudgementResult;
private readonly Bindable<JudgementResult> lastJudgementResult = new Bindable<JudgementResult>();
Implement toggling visibility of pass and fail storyboard layers Closes https://github.com/ppy/osu/issues/6842. This is a rather barebones implementation, just to get this in place somehow at least. The logic is simple - 50% health or above shows pass layer, anything below shows fail layer. This does not match stable logic all across the board because I have no idea how to package that. Stable defines "passing" in like fifty ways: - in mania it's >80% HP (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Rulesets/Mania/RulesetMania.cs#L333-L336) - in taiko it's >80% *accuracy* (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Rulesets/Taiko/RulesetTaiko.cs#L486-L492) - there's also the part where "geki additions" will unconditionally set passing state (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Player.cs#L3561-L3564) - and also the part where at the end of the map, the final passing state is determined by checking whether the user passed more sections than failed (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Player.cs#L3320) The biggest issues of these are probably the first two, and they can *probably* be fixed, but would require a new member on `Ruleset` and I'm not sure how to make one look, so I'm not doing that at this time pending collection of ideas on how to do that.
2024-06-14 11:36:40 +00:00
public GameplayState(
IBeatmap beatmap,
Ruleset ruleset,
IReadOnlyList<Mod>? mods = null,
Score? score = null,
ScoreProcessor? scoreProcessor = null,
HealthProcessor? healthProcessor = null,
Storyboard? storyboard = null)
2021-10-01 17:22:23 +00:00
{
Beatmap = beatmap;
Ruleset = ruleset;
Score = score ?? new Score
{
ScoreInfo =
{
BeatmapInfo = beatmap.BeatmapInfo,
Ruleset = ruleset.RulesetInfo
}
};
Mods = mods ?? Array.Empty<Mod>();
ScoreProcessor = scoreProcessor ?? ruleset.CreateScoreProcessor();
Implement toggling visibility of pass and fail storyboard layers Closes https://github.com/ppy/osu/issues/6842. This is a rather barebones implementation, just to get this in place somehow at least. The logic is simple - 50% health or above shows pass layer, anything below shows fail layer. This does not match stable logic all across the board because I have no idea how to package that. Stable defines "passing" in like fifty ways: - in mania it's >80% HP (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Rulesets/Mania/RulesetMania.cs#L333-L336) - in taiko it's >80% *accuracy* (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Rulesets/Taiko/RulesetTaiko.cs#L486-L492) - there's also the part where "geki additions" will unconditionally set passing state (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Player.cs#L3561-L3564) - and also the part where at the end of the map, the final passing state is determined by checking whether the user passed more sections than failed (https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameModes/Play/Player.cs#L3320) The biggest issues of these are probably the first two, and they can *probably* be fixed, but would require a new member on `Ruleset` and I'm not sure how to make one look, so I'm not doing that at this time pending collection of ideas on how to do that.
2024-06-14 11:36:40 +00:00
HealthProcessor = healthProcessor ?? ruleset.CreateHealthProcessor(beatmap.HitObjects[0].StartTime);
Storyboard = storyboard ?? new Storyboard();
2021-10-01 17:22:23 +00:00
}
2021-10-01 17:28:35 +00:00
/// <summary>
/// Applies the score change of a <see cref="JudgementResult"/> to this <see cref="GameplayState"/>.
/// </summary>
/// <param name="result">The <see cref="JudgementResult"/> to apply.</param>
2021-10-01 17:22:23 +00:00
public void ApplyResult(JudgementResult result) => lastJudgementResult.Value = result;
}
}