AcManager.Pages.Drive.QuickDrive_GridTest.ViewModel.Drive C# (CSharp) Method

Drive() public method

public Drive ( Game basicProperties, Game assistsProperties, Game conditionProperties, Game trackProperties ) : System.Threading.Tasks.Task
basicProperties AcTools.Processes.Game
assistsProperties AcTools.Processes.Game
conditionProperties AcTools.Processes.Game
trackProperties AcTools.Processes.Game
return System.Threading.Tasks.Task
            public override async Task Drive(Game.BasicProperties basicProperties, Game.AssistsProperties assistsProperties,
                    Game.ConditionProperties conditionProperties, Game.TrackProperties trackProperties) {
                var selectedCar = CarsManager.Instance.GetById(basicProperties.CarId);
                var selectedTrack = TracksManager.Instance.GetLayoutById(basicProperties.TrackId, basicProperties.TrackConfigurationId);

                IEnumerable<Game.AiCar> botCars;

                try {
                    using (var waiting = new WaitingDialog()) {
                        if (selectedCar == null || !selectedCar.Enabled) {
                            ModernDialog.ShowMessage(AppStrings.Drive_CannotStart_SelectNonDisabled, AppStrings.Drive_CannotStart_Title, MessageBoxButton.OK);
                            return;
                        }

                        if (selectedTrack == null) {
                            ModernDialog.ShowMessage(AppStrings.Drive_CannotStart_SelectTrack, AppStrings.Drive_CannotStart_Title, MessageBoxButton.OK);
                            return;
                        }

                        botCars = await RaceGridViewModel.GenerateGameEntries(waiting.CancellationToken);
                        if (waiting.CancellationToken.IsCancellationRequested) return;

                        if (botCars == null || !botCars.Any()) {
                            ModernDialog.ShowMessage(AppStrings.Drive_CannotStart_SetOpponent, AppStrings.Drive_CannotStart_Title, MessageBoxButton.OK);
                            return;
                        }
                    }
                } catch (TaskCanceledException) {
                    return;
                }

                await StartAsync(new Game.StartProperties {
                    BasicProperties = basicProperties,
                    AssistsProperties = assistsProperties,
                    ConditionProperties = conditionProperties,
                    TrackProperties = trackProperties,
                    ModeProperties = GetModeProperties(botCars)
                });
            }