mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-13 08:48:39 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
22 lines
565 B
C#
22 lines
565 B
C#
namespace Sandbox.Menu;
|
|
|
|
partial struct LoadingProgress
|
|
{
|
|
public readonly TimeSpan CalculateETA()
|
|
{
|
|
if ( Mbps <= 0 || Fraction >= 1 || TotalSize <= 0 )
|
|
return TimeSpan.MaxValue;
|
|
|
|
if ( Fraction < 0.25 )
|
|
return TimeSpan.MaxValue;
|
|
|
|
var remainingBytes = TotalSize * (1 - Fraction);
|
|
var bytesPerSecond = Mbps * 1_000_000 / 8; // Convert Mbps to bytes per second
|
|
var secondsRemaining = remainingBytes / bytesPerSecond;
|
|
|
|
var roundedSeconds = Math.Max( 1, (int)Math.Round( secondsRemaining ) );
|
|
|
|
return TimeSpan.FromSeconds( roundedSeconds );
|
|
}
|
|
}
|