AcManager.Pages.Drive.Rsr.ViewModel.Go C# (CSharp) 메소드

Go() 공개 메소드

public Go ( ) : Task
리턴 Task
            public async Task<bool> Go() {
                if (EventId == null) return false;

                try {
                    var app = PythonAppsManager.Instance.GetById(RsrMark.AppId);
                    if (app == null) {
                        throw new InformativeException(AppStrings.Rsr_AppIsMissing, AppStrings.Rsr_AppIsMissing_Commentary);
                    }

                    if (!app.Enabled) {
                        app.ToggleCommand.Execute(null);
                        await Task.Delay(500);
                    }

                    if (!app.Enabled) {
                        throw new InformativeException(AppStrings.Rsr_AppIsDisabled, AppStrings.Rsr_AppIsDisabled_Commentary);
                    }

                    var ids = await LoadData();
                    if (ids == null) {
                        throw new InformativeException(AppStrings.Rsr_InvalidParameters, AppStrings.Rsr_InvalidParameters_Commentary);
                    }

                    if (Car == null) {
                        throw new InformativeException(string.Format(ToolsStrings.AcError_CarIsMissing, ids.Item1), AppStrings.Rsr_ContentIsMissing_Commentary);
                    }

                    if (Track == null) {
                        throw new InformativeException(string.Format(ToolsStrings.AcError_TrackIsMissing, ids.Item2), AppStrings.Rsr_ContentIsMissing_Commentary);
                    }

                    await GameWrapper.StartAsync(new Game.StartProperties {
                        BasicProperties = new Game.BasicProperties {
                            CarId = Car.Id,
                            TrackId = Track.Id,
                            TrackConfigurationId = Track.LayoutId,
                            CarSkinId = CarSkin?.Id,
                        },
                        AssistsProperties = Assists.ToGameProperties(),
                        ConditionProperties = new Game.ConditionProperties {
                            AmbientTemperature = 26d,
                            RoadTemperature = 32d,
                            CloudSpeed = 1d,
                            SunAngle = 0,
                            TimeMultipler = 1d,
                            WeatherName = WeatherManager.Instance.GetDefault()?.Id
                        },
                        TrackProperties = Game.GetDefaultTrackPropertiesPreset().Properties,
                        ModeProperties = new Game.HotlapProperties {
                            SessionName = AppStrings.Rsr_SessionName,
                            Penalties = true,
                            GhostCar = GhostCar,
                            GhostCarAdvantage = 0d
                        },
                        AdditionalPropertieses = {
                            new RsrMark()
                        }
                    });

                    return true;
                } catch (Exception e) {
                    NonfatalError.Notify(AppStrings.Common_CannotStartRace, e);
                    return false;
                }
            }