internal static Foothold Parse(WZProperty c) { Foothold result = new Foothold(); result.id = int.Parse(c.NameWithoutExtension); result.next = c.ResolveFor <int>("next") ?? 0; result.prev = c.ResolveFor <int>("prev") ?? 0; result.piece = c.ResolveFor <int>("piece") ?? 0; result.x1 = c.ResolveFor <int>("x1") ?? 0; result.x2 = c.ResolveFor <int>("x2") ?? 0; result.y1 = c.ResolveFor <int>("y1") ?? 0; result.y2 = c.ResolveFor <int>("y2") ?? 0; result.GroupId = int.Parse(c.Parent.Name); result.LayerId = int.Parse(c.Parent.Parent.Name); return(result); }
private static void ParseFootholds(Map result, WZProperty mapEntry) { Stopwatch watch = Stopwatch.StartNew(); ConcurrentDictionary <int, Foothold> fhHolder = new ConcurrentDictionary <int, Foothold>(); Parallel.ForEach(mapEntry.Resolve("foothold").Children .SelectMany(c => c.Children) .SelectMany(c => c.Children), (fh) => { Foothold res = Foothold.Parse(fh); fhHolder.TryAdd(res.id, res); }); result.Footholds = new Dictionary <int, Foothold>(fhHolder); watch.Stop(); Package.Logging($"Map ParseFootholds took {watch.ElapsedMilliseconds}"); }