public void LoadFootholds(WzImage mapImage, Board mapBoard) { List <FootholdAnchor> anchors = new List <FootholdAnchor>(); WzSubProperty footholdParent = (WzSubProperty)mapImage["foothold"]; int layer; FootholdAnchor a; FootholdAnchor b; Dictionary <int, FootholdLine> fhs = new Dictionary <int, FootholdLine>(); foreach (WzSubProperty layerProp in footholdParent.WzProperties) { layer = int.Parse(layerProp.Name); Layer l = mapBoard.Layers[layer]; foreach (WzSubProperty platProp in layerProp.WzProperties) { int zM = int.Parse(platProp.Name); l.zMList.Add(zM); foreach (WzSubProperty fhProp in platProp.WzProperties) { a = new FootholdAnchor(mapBoard, InfoTool.GetInt(fhProp["x1"]), InfoTool.GetInt(fhProp["y1"]), layer, zM, false); b = new FootholdAnchor(mapBoard, InfoTool.GetInt(fhProp["x2"]), InfoTool.GetInt(fhProp["y2"]), layer, zM, false); int num = int.Parse(fhProp.Name); int next = InfoTool.GetInt(fhProp["next"]); int prev = InfoTool.GetInt(fhProp["prev"]); MapleBool cantThrough = InfoTool.GetOptionalBool(fhProp["cantThrough"]); MapleBool forbidFallDown = InfoTool.GetOptionalBool(fhProp["forbidFallDown"]); int? piece = InfoTool.GetOptionalInt(fhProp["piece"]); int? force = InfoTool.GetOptionalInt(fhProp["force"]); if (a.X != b.X || a.Y != b.Y) { FootholdLine fh = new FootholdLine(mapBoard, a, b, forbidFallDown, cantThrough, piece, force); fh.num = num; fh.prev = prev; fh.next = next; mapBoard.BoardItems.FootholdLines.Add(fh); fhs[num] = fh; anchors.Add(a); anchors.Add(b); } } } anchors.Sort(new Comparison <FootholdAnchor>(FootholdAnchor.FHAnchorSorter)); for (int i = 0; i < anchors.Count - 1; i++) { a = anchors[i]; b = anchors[i + 1]; if (a.X == b.X && a.Y == b.Y) { FootholdAnchor.MergeAnchors(a, b); // Transfer lines from b to a anchors.RemoveAt(i + 1); // Remove b i--; // Fix index after we removed b } } foreach (FootholdAnchor anchor in anchors) { if (anchor.connectedLines.Count > 2) { foreach (FootholdLine line in anchor.connectedLines) { if (IsAnchorPrevOfFoothold(anchor, line)) { if (fhs.ContainsKey(line.prev)) { line.prevOverride = fhs[line.prev]; } } else { if (fhs.ContainsKey(line.next)) { line.nextOverride = fhs[line.next]; } } } } mapBoard.BoardItems.FHAnchors.Add(anchor); } anchors.Clear(); } }