private static void SetPlatform([NotNull] this IAcsStarter starter) { if (starter is IAcsPlatformSpecificStarter p) { p.Use32BitVersion = SettingsHolder.Drive.Use32BitVersion; } }
private static void SetPlatform([NotNull] this IAcsStarter starter) { var p = starter as IAcsPlatformSpecificStarter; if (p != null) { p.Use32Version = SettingsHolder.Drive.Use32BitVersion; } }
public static IAcsStarter PrepareCreated([NotNull] IAcsStarter starter) { starter.SetPlatform(); if (SettingsHolder.Drive.RunSteamIfNeeded) { starter.RunSteamIfNeeded = true; } Logging.Debug($"Starter created: {starter.GetType().Name}"); if (starter is IAcsPrepareableStarter preparable && !preparable.TryToPrepare()) { Logging.Warning("Can’t prepare, using fallback starter instead."); starter = CreateFallback(); starter.SetPlatform(); } return(starter); }
public static Result Start([NotNull] IAcsStarter starter, [NotNull] StartProperties properties) { if (starter == null) { throw new ArgumentNullException(nameof(starter)); } if (properties == null) { throw new ArgumentNullException(nameof(properties)); } if (_busy) { return(null); } _busy = true; RemoveResultJson(); var start = DateTime.Now; try { properties.Set(); if (OptionRaceIniTestMode) { return(null); } starter.Run(); starter.WaitUntilGame(); starter.WaitGame(); } finally { starter.CleanUp(); _busy = false; properties.RevertChanges(); } return(GetResult(start)); }
public AcShadowsPatcher(IAcsStarter starter) { starter.PreviewRun += OnPreviewRun; }
public static async Task <Result> StartAsync(IAcsStarter starter, StartProperties properties, IProgress <ProgressState> progress = null, CancellationToken cancellation = default(CancellationToken)) { if (_busy) { return(null); } _busy = true; if (OptionDebugMode) { progress?.Report(ProgressState.Waiting); await Task.Delay(500, cancellation); _busy = false; return(GetResult(DateTime.MinValue)); } RemoveResultJson(); IKeyboardListener listener = null; if (properties.SetKeyboardListener) { try { listener = KeyboardListenerFactory.Get(); listener.Subscribe(); } catch (Exception e) { AcToolsLogging.Write("Can’t set listener: " + e); } } var start = DateTime.Now; try { progress?.Report(ProgressState.Preparing); await Task.Run(() => properties.Set(), cancellation); if (cancellation.IsCancellationRequested || OptionRaceIniTestMode) { return(null); } progress?.Report(ProgressState.Launching); await starter.RunAsync(cancellation); if (cancellation.IsCancellationRequested) { return(null); } var process = await starter.WaitUntilGameAsync(cancellation); await Task.Run(() => properties.SetGame(process), cancellation); if (cancellation.IsCancellationRequested) { return(null); } progress?.Report(ProgressState.Waiting); await starter.WaitGameAsync(cancellation); if (cancellation.IsCancellationRequested) { return(null); } } finally { _busy = false; if (cancellation.IsCancellationRequested) { starter.CleanUp(); } else { progress?.Report(ProgressState.Finishing); await starter.CleanUpAsync(cancellation); } properties.RevertChanges(); listener?.Dispose(); } return(GetResult(start)); }