public string Save(SaveMode mode) { m_mode = mode; GameXmlWriter writer = new GameXmlWriter(mode); UpdateImpliedTypesCache(); writer.WriteComment("Saved by Quest Editor v5.0"); writer.WriteStartElement("asl"); writer.WriteAttributeString("version", "500"); if (mode == SaveMode.SavedGame) { writer.WriteAttributeString("original", m_worldModel.Filename); } foreach (ElementType t in Enum.GetValues(typeof(ElementType))) { if (m_elementsSavers.ContainsKey(t)) { // We have an IElementsSaver which saves all elements of a particular type at once m_elementsSavers[t].Save(writer, m_worldModel); } else { // Save the elements individually IElementSaver saver; if (m_elementSavers.TryGetValue(t, out saver)) { if (saver.AutoSave) { foreach (Element e in m_worldModel.Elements.GetElements(t).Where(e => CanSave(e))) { saver.Save(writer, e); } } } else { throw new Exception("ERROR: No ElementSaver for type " + t.ToString()); } } } writer.WriteEndElement(); writer.Close(); return writer.ToString(); }