Editor/MotionBricks/InstallProgress.cs

A small record struct used in the editor tools to report installation progress. It stores bytes done/total, current file name, transfer speed and phase, and exposes a computed Fraction property clamped between 0 and 1.

#nullable enable annotations

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;

namespace HumanoidMocap.EditorTools.MotionBricks;

/// <summary>Progress of an install, for the progress bar and its caption.</summary>
public readonly record struct InstallProgress( long BytesDone, long BytesTotal, string CurrentFile, double BytesPerSecond, string Phase )
{
    public float Fraction => BytesTotal > 0 ? Math.Clamp( BytesDone / (float)BytesTotal, 0f, 1f ) : 0f;
}