// 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 System.Linq; using MessagePack; using Newtonsoft.Json; using osu.Game.Online.API; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; namespace osu.Game.Online.Spectator { [Serializable] [MessagePackObject] public class FrameHeader { /// /// The total score. /// [Key(0)] public long TotalScore { get; set; } /// /// The current accuracy of the score. /// [Key(1)] public double Accuracy { get; set; } /// /// The current combo of the score. /// [Key(2)] public int Combo { get; set; } /// /// The maximum combo achieved up to the current point in time. /// [Key(3)] public int MaxCombo { get; set; } /// /// Cumulative hit statistics. /// [Key(4)] public Dictionary Statistics { get; set; } /// /// Additional statistics that guides the score processor to calculate the correct score for this frame. /// [Key(5)] public ScoreProcessorStatistics ScoreProcessorStatistics { get; set; } /// /// The time at which this frame was received by the server. /// [Key(6)] public DateTimeOffset ReceivedTime { get; set; } /// /// The set of mods currently active. /// /// /// Nullable for backwards compatibility with older clients /// (these structures are also used server-side, and will be used as marker that the data isn't there). /// can be made non-nullable 20250407 /// [Key(7)] public APIMod[]? Mods { get; set; } /// /// Construct header summary information from a point-in-time reference to a score which is actively being played. /// /// The score for reference. /// The score processor statistics for the current point in time. public FrameHeader(ScoreInfo score, ScoreProcessorStatistics statistics) { TotalScore = score.TotalScore; Accuracy = score.Accuracy; Combo = score.Combo; MaxCombo = score.MaxCombo; // copy for safety Statistics = new Dictionary(score.Statistics); Mods = score.APIMods.ToArray(); ScoreProcessorStatistics = statistics; } [JsonConstructor] [SerializationConstructor] public FrameHeader(long totalScore, double accuracy, int combo, int maxCombo, Dictionary statistics, ScoreProcessorStatistics scoreProcessorStatistics, DateTimeOffset receivedTime) { TotalScore = totalScore; Accuracy = accuracy; Combo = combo; MaxCombo = maxCombo; Statistics = statistics; ScoreProcessorStatistics = scoreProcessorStatistics; ReceivedTime = receivedTime; } } }