private ImportSavegame(float gameTime) { this.gameTime = gameTime; // manual species-name fixing nameReplacing = new Dictionary <string, string> { { "Paraceratherium", "Paracer" }, { "Ichthyosaurus", "Ichthy" }, { "Dire Bear", "Direbear" } }; // add Blueprints of species (ark-tools doesn't convert e.g. the aberrant species) Regex r = new Regex(@"\/([^\/.]+)\."); foreach (Species s in Values.V.species) { Match m = r.Match(s.blueprintPath); if (!m.Success) { continue; } string bpPart = m.Groups[1].Value + "_C"; if (!nameReplacing.ContainsKey(bpPart)) { nameReplacing.Add(bpPart, s.name); } } arkData = ArkDataReader.ReadFromFile(FileService.GetJsonPath(FileService.ArkDataJson)); }
public static void EnsureArkDataAvailability() { Task.Run(async() => { if (!File.Exists(filename)) { await DownloadArkData(); } else { ArkData = ArkDataReader.ReadFromFile(filename); } }); }
private async Task <bool> LoadArkData(string targetFile) { return(await Task.Run <bool>(() => { try { arkReader.SetArkData(ArkDataReader.ReadFromFile(targetFile)); return true; } catch (Exception) { return false; } })); }
static async Task Main(string[] args) { var savegameFile = args.FirstOrDefault(); if (savegameFile == null) { Console.Error.WriteLine("Usage: MapCalibrator.exe <savegame>"); Environment.Exit(1); } var arkDataFile = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Larkator"), "ark-data.json"); var arkData = ArkDataReader.ReadFromFile(arkDataFile); (GameObjectContainer gameObjects, float gameTime) = await ReadSavegameFile(savegameFile); // Find any objects that have a relevant BoxName var items = gameObjects .Where(o => o.Parent == null && o.GetPropertyValue <string>("BoxName", defaultValue: "").StartsWith("Calibration:")) .ToList(); // Extract XYZ location and calibration lat/lon var inputs = items.Select(o => (o.Location, LatLon: LatLongFromName(o.GetPropertyValue <string>("BoxName")))).ToArray(); // Perform linear regression on the values for best fit, separately for X and Y double[] xValues = inputs.Select(i => (double)i.Location.X).ToArray(); double[] yValues = inputs.Select(i => (double)i.Location.Y).ToArray(); double[] lonValues = inputs.Select(i => i.LatLon.Lon).ToArray(); double[] latValues = inputs.Select(i => i.LatLon.Lat).ToArray(); var(xOffset, xMult) = Fit.Line(xValues, lonValues); var(yOffset, yMult) = Fit.Line(yValues, latValues); var xCorr = GoodnessOfFit.RSquared(xValues.Select(x => xOffset + xMult * x), lonValues); var yCorr = GoodnessOfFit.RSquared(yValues.Select(y => yOffset + yMult * y), latValues); Console.WriteLine($"X: {xOffset} + X/{1 / xMult} (corr {xCorr})"); Console.WriteLine($"Y: {yOffset} + X/{1 / yMult} (corr {yCorr})"); Console.ReadLine(); }
public static async Task DownloadArkData() { await tryDownload(new Uri(arkDataUrl), filename); ArkData = ArkDataReader.ReadFromFile(filename); }