public string YAMLFromMap(ICompoundMap map) { var bridge = BridgeFromMap(map); var yaml = YAMLFromBridge(bridge); return(yaml); }
public CompoundMapBridge BridgeFromMap(ICompoundMap map) { var bridge = new CompoundMapBridge { Name = map.Name, Width = map.Width, Height = map.Height, }; // we want to create a list of the distinct terrains // used in this map List <string> distinctTerrainNames = new List <string>(); foreach (var space in map.SpaceMap) { var name = space.Item.Terrain.Name; if (!distinctTerrainNames.Contains(name)) { distinctTerrainNames.Add(name); } } // ...then build the bridge legend from those foreach (var name in distinctTerrainNames) { var kv = Atlas.Legend.Where(t => t.Value.Name == name).Single(); var ch = ((char)kv.Value.Cell.Glyph).ToString(); bridge.Legend[ch] = name; } //data.Legend["."] = "dot dirt dere"; //data.Legend["~"] = "tilde dirt"; for (int y = 0; y < map.SpaceMap.Height; y++) { var sb = new StringBuilder(map.SpaceMap.Width); for (int x = 0; x < map.SpaceMap.Width; x++) { var sp = map.SpaceMap.GetItem((x, y)); sb.Append((char)sp.Terrain.Cell.Glyph); } bridge.Terrain.Add(sb.ToString()); } foreach (var beingST in map.BeingMap) { bridge.MultiBeings[beingST.Item.ID] = new Coord_IBeing { Coord = beingST.Position, Being = beingST.Item }; } foreach (var itemST in map.ItemMap) { bridge.MultiItems[itemST.Item.ID] = new Coord_IItem { Coord = itemST.Position, Item = itemST.Item }; } foreach (var rotST in map.RotMap) { bridge.AreaRots.Add(rotST.Position, rotST.Item); } bridge.Triggers.AddRange(map.Triggers); return(bridge); }
public (ScrollingConsole, Window) CreateMapWindow(Size windowSize, string title, ICompoundMap fullMap) { int viewWidth = windowSize.Width - 2; int viewHeight = windowSize.Height - 2; Window mapWindow = new Window(windowSize.Width, windowSize.Height, MapFont) { CanDrag = true, Title = title.Align(HorizontalAlignment.Center, viewWidth), }; log.DebugFormat("Created map window, [{0}].", mapWindow.AbsoluteArea); var mapConsole = new ScrollingConsole( fullMap.Width, fullMap.Height, MapFont, new MG.Rectangle(0, 0, viewWidth, viewHeight)); // Fit the MapConsole inside the MapWindow border mapConsole.Position = new Coord(1, 1); mapWindow.Children.Add(mapConsole); log.DebugFormat("Created map console, map size [{0},{1}], viewport size [{2}].", fullMap.Width, fullMap.Height, mapWindow.ViewPort); return(mapConsole, mapWindow); }