public static XElement CreateTerrainlayout(List <IntVec3> cellExport, Area area, Map map, bool exportNatural, out bool add) { XElement liMain = new XElement("li", null); RectUtils.EdgeFromList(cellExport, out int height, out int width); add = false; IntVec3 first = cellExport.First(); for (int i = 0; i < height; i++) { XElement li = new XElement("li", null); string temp = ""; for (int i2 = 0; i2 < width; i2++) { if (area != null && !area.ActiveCells.Contains(first)) { if (i2 + 1 == width) { temp += "."; } else { temp += ".,"; } } else if (map.terrainGrid.TerrainAt(first) is TerrainDef d && !d.BuildableByPlayer && !d.HasTag("Road") && !exportNatural) { if (i2 + 1 == width) { temp += "."; } else { temp += ".,"; } }
public static XElement CreateThinglayout(List <IntVec3> cellExport, int index, Area area, Dictionary <IntVec3, List <Thing> > pairsCellThingList, bool exportFilth) { XElement liMain = new XElement("li", null); RectUtils.EdgeFromList(cellExport, out int height, out int width); List <Thing> aAdded = new List <Thing>(); IntVec3 first = cellExport.First(); for (int i = 0; i < height; i++) { XElement li = new XElement("li", null); string temp = ""; for (int i2 = 0; i2 < width; i2++) { List <Thing> things = pairsCellThingList.TryGetValue(first).FindAll(t => t.def.category != ThingCategory.Pawn && t.def.category != ThingCategory.Item); if (!exportFilth) { things.RemoveAll(t => t.def.category == ThingCategory.Filth); } Thing thing; if (things.Count < index + 1 || (area != null && !area.ActiveCells.Contains(first))) { if (i2 + 1 == width) { temp += "."; } else { temp += ".,"; } } else { thing = things[index]; if (!aAdded.Contains(thing) && thing.Position == first) { SymbolDef symbolDef; if (thing.Stuff != null) { if (thing.def.rotatable) { symbolDef = DefDatabase <SymbolDef> .AllDefsListForReading.Find(s => s.thingDef == thing.def && s.stuffDef == thing.Stuff && s.rotation == thing.Rotation); } else { symbolDef = DefDatabase <SymbolDef> .AllDefsListForReading.Find(s => s.thingDef == thing.def && s.stuffDef == thing.Stuff); } } else { if (thing.def.rotatable) { symbolDef = DefDatabase <SymbolDef> .AllDefsListForReading.Find(s => s.thingDef == thing.def && s.rotation == thing.Rotation); } else { symbolDef = DefDatabase <SymbolDef> .AllDefsListForReading.Find(s => s.thingDef == thing.def); } } if (symbolDef == null) { string symbolString = thing.def.defName; if (thing.Stuff != null) { symbolString += "_" + thing.Stuff.defName; } if (thing.def.rotatable && thing.def.category != ThingCategory.Plant) { symbolString += "_" + thing.Rotation.ToStringHuman(); } if (i2 + 1 == width) { temp += symbolString; } else { temp += symbolString + ","; } } else { if (i2 + 1 == width) { temp += symbolDef.defName; } else { temp += symbolDef.defName + ","; } } aAdded.Add(thing); } else { if (i2 + 1 == width) { temp += "."; } else { temp += ".,"; } } } first.x++; } first.x -= width; li.Add(temp); liMain.Add(li); first.z++; } return(liMain); }