// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; namespace osu.Game.Online.Rooms { /// /// The local availability information about a certain beatmap for the client. /// public readonly struct BeatmapAvailability : IEquatable { /// /// The beatmap's availability state. /// public readonly DownloadState State; /// /// The beatmap's downloading progress, null when not in state. /// public readonly double? DownloadProgress; /// /// Constructs a new non- beatmap availability state. /// /// The beatmap availability state. /// Throws if was specified in this constructor, as it has its own constructor (see . public BeatmapAvailability(DownloadState state) { if (state == DownloadState.Downloading) throw new ArgumentException($"{nameof(DownloadState.Downloading)} state has its own constructor, use it instead."); State = state; DownloadProgress = null; } /// /// Constructs a new -specific beatmap availability state. /// /// The beatmap availability state (always ). /// The beatmap's downloading current progress. /// Throws if non- was specified in this constructor, as they have their own constructor (see . public BeatmapAvailability(DownloadState state, double downloadProgress) { if (state != DownloadState.Downloading) throw new ArgumentException($"This is a constructor specific for {DownloadState.Downloading} state, use the regular one instead."); State = DownloadState.Downloading; DownloadProgress = downloadProgress; } public bool Equals(BeatmapAvailability other) => State == other.State && DownloadProgress == other.DownloadProgress; public override string ToString() => $"{string.Join(", ", State, $"{DownloadProgress:0.00%}")}"; } }