Files
RobustToolbox/Robust.Client/Replays/Loading/LoadReplayJob.cs
Pieter-Jan BriersandGitHub 2715581f48 Replays: final boss (#4156)
* Add ISawmill.Verbose log helpers

* Verbose logs for server-side networking handshake.

* Replays: final boss

It does zippies now. It fucking works. Amazingly, in fact.

* Add ZipArchive to sandbox
2023-06-24 18:56:37 -05:00

44 lines
1.2 KiB
C#

using Robust.Shared.ContentPack;
using System.Threading.Tasks;
using Robust.Shared.CPUJob.JobQueues;
using Robust.Shared.Utility;
namespace Robust.Client.Replays.Loading;
/// <summary>
/// Simple job for loading some replay file. Note that tick updates need to be blocked
/// (<see cref="IGameController.TickUpdateOverride"/>) in order to avoid unexpected errors.
/// </summary>
[Virtual]
public class LoadReplayJob : Job<bool>
{
private readonly IReplayFileReader _fileReader;
private readonly IReplayLoadManager _loadMan;
public LoadReplayJob(
float maxTime,
IReplayFileReader fileReader,
IReplayLoadManager loadMan)
: base(maxTime)
{
_fileReader = fileReader;
_loadMan = loadMan;
}
protected override async Task<bool> Process()
{
await _loadMan.LoadAndStartReplayAsync(_fileReader, Yield);
return true;
}
protected virtual async Task Yield(float value, float maxValue, LoadingState state, bool force)
{
// Content inheritors can update some UI or loading indicator here
if (force)
await SuspendNow();
else
await SuspendIfOutOfTime();
}
}