public static bool FromId(int id, Markup markup, ObjectsMap map, out MarkupPoint point) { point = null; var enterId = GetEnter(id); var num = GetNum(id); var type = GetType(id); if (map.TryGetValue(new ObjectId() { Segment = enterId }, out ObjectId targetSegment)) { enterId = targetSegment.Segment; } if (map.TryGetValue(new ObjectId() { Point = GetId(enterId, num, type) }, out ObjectId targetPoint)) { num = GetNum(targetPoint.Point); } return(markup.TryGetEnter(enterId, out Enter enter) && enter.TryGetPoint(num, type, out point)); }
public static bool FromXml(Version version, XElement config, ObjectsMap map, out NodeMarkup markup) { var nodeId = config.GetAttrValue <ushort>(nameof(Id)); while (map.TryGetValue(new ObjectId() { Node = nodeId }, out ObjectId targetNode)) { nodeId = targetNode.Node; } try { markup = MarkupManager.NodeManager.Get(nodeId); markup.FromXml(version, config, map); return(true); } catch (Exception error) { Mod.Logger.Error($"Could not load node #{nodeId} markup", error); markup = null; return(false); } }
public static bool FromId(int id, Markup markup, ObjectsMap map, out MarkupPoint point) { point = null; var enterId = GetEnter(id); var num = GetNum(id); var type = GetType(id); switch (markup.Type) { case MarkupType.Node when map.TryGetValue(new ObjectId() { Segment = enterId }, out ObjectId targetSegment): enterId = targetSegment.Segment; break; case MarkupType.Segment when map.TryGetValue(new ObjectId() { Node = enterId }, out ObjectId targetNode): enterId = targetNode.Node; break; } if (map.TryGetValue(new ObjectId() { Point = GetId(enterId, num, type) }, out ObjectId targetPoint)) { num = GetNum(targetPoint.Point); } return(markup.TryGetEnter(enterId, out Enter enter) && enter.TryGetPoint(num, type, out point)); }