// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; 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; using osu.Game.Scoring; namespace osu.Game.Screens.Play { /// /// The state of an active gameplay session, generally constructed and exposed by . /// public class GameplayState { /// /// The final post-convert post-mod-application beatmap. /// public readonly IBeatmap Beatmap; /// /// The ruleset used in gameplay. /// public readonly Ruleset Ruleset; /// /// The mods applied to the gameplay. /// public readonly IReadOnlyList Mods; /// /// The gameplay score. /// public readonly Score Score; public readonly ScoreProcessor ScoreProcessor; /// /// Whether gameplay completed without the user failing. /// public bool HasPassed { get; set; } /// /// Whether the user failed during gameplay. /// public bool HasFailed { get; set; } /// /// Whether the user quit gameplay without having either passed or failed. /// public bool HasQuit { get; set; } /// /// A bindable tracking the last judgement result applied to any hit object. /// public IBindable LastJudgementResult => lastJudgementResult; private readonly Bindable lastJudgementResult = new Bindable(); public GameplayState(IBeatmap beatmap, Ruleset ruleset, IReadOnlyList? mods = null, Score? score = null, ScoreProcessor? scoreProcessor = null) { Beatmap = beatmap; Ruleset = ruleset; Score = score ?? new Score { ScoreInfo = { BeatmapInfo = beatmap.BeatmapInfo, Ruleset = ruleset.RulesetInfo } }; Mods = mods ?? Array.Empty(); ScoreProcessor = scoreProcessor ?? ruleset.CreateScoreProcessor(); } /// /// Applies the score change of a to this . /// /// The to apply. public void ApplyResult(JudgementResult result) => lastJudgementResult.Value = result; } }