예제 #1
0
        public ArkSpeciesStatsData(ArkSpeciesStatsData values, List <ArkSpeciesStatsData> mods) : this()
        {
            if (values?.SpeciesStats != null)
            {
                SpeciesStats.AddRange(values.SpeciesStats);
            }

            foreach (var mod in mods)
            {
                if (mod?.SpeciesStats != null)
                {
                    SpeciesStats.AddRange(mod.SpeciesStats);
                }
            }
        }
예제 #2
0
        public async Task LoadOrUpdate(int[] modIds)
        {
            Task updateTask = null;

            lock (_lock)
            {
                if (_updateTask == null)
                {
                    updateTask = _updateTask = Task.Run(async() =>
                    {
                        try
                        {
                            // values.json
                            var data = await DownloadResource <ArkSpeciesStatsData>(_obeliskUrl + _valuesUrl, _valuesFileName);
                            if (data != null)
                            {
                                Values = data;
                            }

                            // _manifest.json
                            var manifest = await DownloadResource <ObeliskManifest>(_obeliskUrl + _manifestUrl, _manifestFileName);
                            if (manifest != null)
                            {
                                Manifest = manifest;
                            }

                            // mods
                            if (modIds?.Length > 0)
                            {
                                foreach (var modId in modIds)
                                {
                                    var strModId = modId.ToString();
                                    var mod      = Manifest?.Files?.FirstOrDefault(x => x.Value?.Mod?.Id.Equals(strModId) == true);

                                    var modData = await DownloadResource <ArkSpeciesStatsData>(mod.HasValue ? _obeliskUrl + mod.Value.Key : null, $"obelisk-asb-species-{modId}.json", skipDownload: mod == null);
                                    if (modData != null)
                                    {
                                        ViewModel.Workspace.Instance.Console.AddLog("Loaded species data for " + (mod.HasValue ? $"{mod.Value.Value.Mod.Title} ({modId})" : $"'{modId}'") + ".");
                                        Mods.Add(modData);
                                    }
                                    else
                                    {
                                        ViewModel.Workspace.Instance.Console.AddLog($"Mod '{modId}' is not supported and could result in some data missing from the web app.");
                                    }
                                }
                            }

                            Data = new ArkSpeciesStatsData(Values, Mods);
                        }
                        finally
                        {
                            lock (_lock)
                            {
                                _updateTask = null;
                            }
                        }
                    });
                }
                else
                {
                    updateTask = _updateTask;
                }
            }

            await updateTask;
        }