2020-12-14 16:33:23 +08: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.
|
|
|
|
|
|
|
|
#nullable enable
|
|
|
|
|
|
|
|
using System;
|
2020-12-16 14:35:07 +08:00
|
|
|
using System.Collections.Generic;
|
2021-01-26 15:39:35 +08:00
|
|
|
using MessagePack;
|
2020-12-14 17:41:24 +08:00
|
|
|
using Newtonsoft.Json;
|
2020-12-16 14:35:07 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-12-14 16:33:23 +08:00
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Online.Spectator
|
|
|
|
{
|
|
|
|
[Serializable]
|
2021-01-26 15:39:35 +08:00
|
|
|
[MessagePackObject]
|
2020-12-14 16:33:23 +08:00
|
|
|
public class FrameHeader
|
|
|
|
{
|
2020-12-24 13:46:52 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The current accuracy of the score.
|
|
|
|
/// </summary>
|
2021-01-26 15:39:35 +08:00
|
|
|
[Key(0)]
|
2020-12-24 13:46:52 +08:00
|
|
|
public double Accuracy { get; set; }
|
|
|
|
|
2020-12-16 15:19:53 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The current combo of the score.
|
|
|
|
/// </summary>
|
2021-01-26 15:39:35 +08:00
|
|
|
[Key(1)]
|
2020-12-14 16:33:23 +08:00
|
|
|
public int Combo { get; set; }
|
|
|
|
|
2020-12-16 15:19:53 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The maximum combo achieved up to the current point in time.
|
|
|
|
/// </summary>
|
2021-01-26 15:39:35 +08:00
|
|
|
[Key(2)]
|
2020-12-14 16:33:23 +08:00
|
|
|
public int MaxCombo { get; set; }
|
|
|
|
|
2020-12-16 15:19:53 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Cumulative hit statistics.
|
|
|
|
/// </summary>
|
2021-01-26 15:39:35 +08:00
|
|
|
[Key(3)]
|
2020-12-16 14:35:07 +08:00
|
|
|
public Dictionary<HitResult, int> Statistics { get; set; }
|
2020-12-14 16:33:23 +08:00
|
|
|
|
2020-12-16 15:19:53 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The time at which this frame was received by the server.
|
|
|
|
/// </summary>
|
2021-01-26 15:39:35 +08:00
|
|
|
[Key(4)]
|
2020-12-16 15:19:53 +08:00
|
|
|
public DateTimeOffset ReceivedTime { get; set; }
|
|
|
|
|
2020-12-14 16:33:23 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Construct header summary information from a point-in-time reference to a score which is actively being played.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="score">The score for reference.</param>
|
|
|
|
public FrameHeader(ScoreInfo score)
|
|
|
|
{
|
|
|
|
Combo = score.Combo;
|
|
|
|
MaxCombo = score.MaxCombo;
|
2020-12-24 13:46:52 +08:00
|
|
|
Accuracy = score.Accuracy;
|
2020-12-14 16:33:23 +08:00
|
|
|
|
2020-12-16 14:35:07 +08:00
|
|
|
// copy for safety
|
|
|
|
Statistics = new Dictionary<HitResult, int>(score.Statistics);
|
2020-12-14 17:41:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[JsonConstructor]
|
2021-01-26 15:39:35 +08:00
|
|
|
[SerializationConstructor]
|
|
|
|
public FrameHeader(double accuracy, int combo, int maxCombo, Dictionary<HitResult, int> statistics, DateTimeOffset receivedTime)
|
2020-12-14 17:41:24 +08:00
|
|
|
{
|
|
|
|
Combo = combo;
|
|
|
|
MaxCombo = maxCombo;
|
2020-12-24 13:46:52 +08:00
|
|
|
Accuracy = accuracy;
|
2020-12-14 17:41:24 +08:00
|
|
|
Statistics = statistics;
|
2020-12-16 15:19:53 +08:00
|
|
|
ReceivedTime = receivedTime;
|
2020-12-14 16:33:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|