public void Save(TreeSaver saver, string path)
        {
            saver.StartTree(this);
            var totalCost = 0;

            foreach (var node in TechTree)
            {
                totalCost += node.Cost;
                var parts = new List <string>();
                foreach (var part in node.Parts)
                {
                    parts.Add(part.PartName);
                }
                var parents = new List <string>();
                foreach (var parent in node.Parents)
                {
                    parents.Add(parent.NodeName);
                }
                saver.StartNode().
                SaveAttribute(new KeyValuePair <string, string>("name", node.NodeName)).
                SaveAttribute(new KeyValuePair <string, string>("techID", node.TechId)).
                SavePosition(node.Pos.X, node.Pos.Y, node.Zlayer).
                SaveAttribute(new KeyValuePair <string, string>("icon", node.Icon.ToString())).
                SaveAttribute(new KeyValuePair <string, string>("cost", node.Cost.ToString(CultureInfo.InvariantCulture))).
                SaveAttribute(new KeyValuePair <string, string>("title", node.Title)).
                SaveAttribute(new KeyValuePair <string, string>("description", node.Description)).
                SaveAttribute(new KeyValuePair <string, string>("anyParent", node.AnyParent.ToString())).
                SaveAttribute(new KeyValuePair <string, string>("hideIfEmpty", node.HideIfEmpty.ToString())).
                SaveAttribute(new KeyValuePair <string, string>("hideIfNoBranchParts", node.HideIfNoBranchParts.ToString())).
                StartParents().
                SaveParents(parents).
                EndParents().
                StartParts().
                SaveParts(node).
                EndParts().
                EndNode();
            }
            saver.EndTree();
            saver.Save(path);
            Logger.Log("Tree saved succesfully to {0}. Total cost: {1} science. Total nodes: {2} nodes.", path, totalCost, TechTree.Count);
        }
Esempio n. 2
0
 public void Save(TreeSaver saver, string path)
 {
     saver.StartTree(this);
     foreach (var node in TechTree)
     {
         var parts = new List <string>();
         foreach (var part in node.Parts)
         {
             parts.Add(part.PartName);
         }
         var parents = new List <string>();
         foreach (var parent in node.Parents)
         {
             parents.Add(parent.NodeName);
         }
         saver.StartNode().
         SaveAttribute(new KeyValuePair <string, string>("name", node.NodeName)).
         SaveAttribute(new KeyValuePair <string, string>("techID", node.TechId)).
         SavePosition(node.Pos.X, node.Pos.Y, node.Zlayer).
         SaveAttribute(new KeyValuePair <string, string>("icon", node.Icon.ToString())).
         SaveAttribute(new KeyValuePair <string, string>("cost", node.Cost.ToString(CultureInfo.InvariantCulture))).
         SaveAttribute(new KeyValuePair <string, string>("title", node.Title)).
         SaveAttribute(new KeyValuePair <string, string>("description", node.Description)).
         SaveAttribute(new KeyValuePair <string, string>("anyParent", node.AnyParent.ToString())).
         SaveAttribute(new KeyValuePair <string, string>("hideIfEmpty", node.HideIfEmpty.ToString())).
         StartParents().
         SaveParents(parents).
         EndParents().
         StartParts().
         SaveParts(node.Parts).
         EndParts().
         EndNode();
     }
     saver.EndTree();
     saver.Save(path);
 }
 public void Save(TreeSaver saver, string path)
 {
     saver.StartTree(this);
     var totalCost = 0;
     foreach (var node in TechTree)
     {
         totalCost += node.Cost;
         var parts = new List<string>();
         foreach (var part in node.Parts)
         {
             parts.Add(part.PartName);
         }
         var parents = new List<string>();
         foreach (var parent in node.Parents)
         {
             parents.Add(parent.NodeName);
         }
         saver.StartNode().
               SaveAttribute(new KeyValuePair<string, string>("name", node.NodeName)).
               SaveAttribute(new KeyValuePair<string, string>("techID", node.TechId)).
               SavePosition(node.Pos.X, node.Pos.Y, node.Zlayer).
               SaveAttribute(new KeyValuePair<string, string>("icon", node.Icon.ToString())).
               SaveAttribute(new KeyValuePair<string, string>("cost", node.Cost.ToString(CultureInfo.InvariantCulture))).
               SaveAttribute(new KeyValuePair<string, string>("title", node.Title)).
               SaveAttribute(new KeyValuePair<string, string>("description", node.Description)).
               SaveAttribute(new KeyValuePair<string, string>("anyParent", node.AnyParent.ToString())).
               SaveAttribute(new KeyValuePair<string, string>("hideIfEmpty", node.HideIfEmpty.ToString())).
               SaveAttribute(new KeyValuePair<string, string>("hideIfNoBranchParts", node.HideIfNoBranchParts.ToString())).
               StartParents().
               SaveParents(parents).
               EndParents().
               StartParts().
               SaveParts(node).
               EndParts().
               EndNode();
     }
     saver.EndTree();
     saver.Save(path);
     Logger.Log("Tree saved succesfully to {0}. Total cost: {1} science. Total nodes: {2} nodes.", path, totalCost, TechTree.Count);
 }