Esempio n. 1
0
        private static IEnumerable <ObjectInstruction> GetRangeInstructions(string objectName, string arg,
                                                                            Orientation orientation)
        {
            var endpoints = arg.Split('-');
            var start     = GetXYOrientation(endpoints[0], orientation);
            var end       = XY.FromString(endpoints[1]);
            var range     = start.Thru(end);

            return(range.Select(
                       x => new ObjectInstruction(objectName, new XYOrientation(x.X, x.Y, start.Orientation))).ToList());
        }
        public static LinkInstruction FromString(string arg)
        {
            if (string.IsNullOrEmpty(arg) || !arg.Contains("-"))
            {
                throw new ArgumentException($"Invalid Link instruction: {arg}");
            }

            var targets   = arg.Replace("Link:", "").CleanAndSplit('-');
            var obj1Parts = targets[0].Split(',');
            var obj1      = new XYLocation <string>(XY.FromString(obj1Parts[1] + "," + obj1Parts[2]), obj1Parts[0]);
            var obj2Parts = targets[1].Split(',');
            var obj2      = new XYLocation <string>(XY.FromString(obj2Parts[1] + "," + obj2Parts[2]), obj2Parts[0]);

            return(new LinkInstruction(obj1, obj2));
        }
Esempio n. 3
0
        public static RoomInstruction FromStrings(List <string> lines)
        {
            if (lines.Count == 0)
            {
                throw new ArgumentException("No placement instructions.");
            }
            if (lines.Count(x => x.StartsWith("Room:")) != 1)
            {
                throw new ArgumentException("Single room details not found.");
            }

            var location         = XY.FromString(lines.First(x => x.StartsWith("Room:")).Split(':')[1]);
            var instructionLines =
                lines.Where(x => !string.IsNullOrEmpty(x) && !x.Contains("//") && !x.StartsWith("Room:"));

            return(new RoomInstruction(location, instructionLines.SelectMany(ObjectInstruction.FromString).ToList()));
        }
Esempio n. 4
0
 private static XY GetSize(string layerProperties)
 {
     return(XY.FromString(layerProperties.GetValue("Size")));
 }