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;
|
2022-05-30 10:14:03 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2021-10-04 11:33:54 +00:00
|
|
|
using osu.Game.Scoring;
|
2024-02-29 02:39:36 +00:00
|
|
|
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
|
|
|
|
2022-05-30 10:14:03 +00:00
|
|
|
public readonly ScoreProcessor ScoreProcessor;
|
|
|
|
|
2024-02-29 02:39:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The storyboard associated with the beatmap.
|
|
|
|
/// </summary>
|
|
|
|
public readonly Storyboard Storyboard;
|
|
|
|
|
2022-01-25 16:45:11 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Whether gameplay completed without the user failing.
|
|
|
|
/// </summary>
|
|
|
|
public bool HasPassed { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2024-01-04 07:41:52 +00:00
|
|
|
/// Whether the user failed during gameplay. This is only set when the gameplay session has completed due to the fail.
|
2022-01-25 16:45:11 +00:00
|
|
|
/// </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>();
|
|
|
|
|
2024-02-29 02:39:36 +00:00
|
|
|
public GameplayState(IBeatmap beatmap, Ruleset ruleset, IReadOnlyList<Mod>? mods = null, Score? score = null, ScoreProcessor? scoreProcessor = null, Storyboard? storyboard = null)
|
2021-10-01 17:22:23 +00:00
|
|
|
{
|
|
|
|
Beatmap = beatmap;
|
|
|
|
Ruleset = ruleset;
|
2022-01-10 04:08:57 +00:00
|
|
|
Score = score ?? new Score
|
|
|
|
{
|
|
|
|
ScoreInfo =
|
|
|
|
{
|
2022-07-25 02:21:27 +00:00
|
|
|
BeatmapInfo = beatmap.BeatmapInfo,
|
2022-01-10 04:08:57 +00:00
|
|
|
Ruleset = ruleset.RulesetInfo
|
|
|
|
}
|
|
|
|
};
|
2022-05-30 10:14:03 +00:00
|
|
|
Mods = mods ?? Array.Empty<Mod>();
|
|
|
|
ScoreProcessor = scoreProcessor ?? ruleset.CreateScoreProcessor();
|
2024-02-29 02:39:36 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|