Exemple #1
0
        public static MapInstruction FromStrings(List <string> lines)
        {
            var portals = lines.Where(x => x.StartsWith("Portal-")).Select(PortalInstruction.FromString).ToList();
            var layers  = new List <LayerInstruction>();

            var foundFirstLayer = false;
            var currentLines    = new List <string>();

            foreach (var line in lines.Where(x => !x.StartsWith("Portal-")))
            {
                if (line.StartsWith("Layer"))
                {
                    if (foundFirstLayer)
                    {
                        layers.Add(LayerInstruction.FromStrings(currentLines));
                    }
                    else
                    {
                        foundFirstLayer = true;
                    }
                    currentLines.Clear();
                }
                currentLines.Add(line);
            }
            if (foundFirstLayer)
            {
                layers.Add(LayerInstruction.FromStrings(currentLines));
            }

            return(new MapInstruction(layers, portals));
        }
        public static FacilityLayer Assemble(LayerInstruction instructions)
        {
            var builder = new LayerBuilder(instructions.Size);

            instructions.Rooms
            .ForEach(x => x.ObjectInstructions
                     .ForEach(y => builder.Put(y, x.Location)));
            instructions.Links.ForEach(x => builder.Link(x));
            return(builder.Build());
        }