Moved MapEntity saving methods to the shared project (the server needs to be able to save subs in the campaign mode)

This commit is contained in:
Joonas Rikkonen
2017-08-30 18:09:48 +03:00
parent dc3b9baa0d
commit 96a64d45dc
26 changed files with 386 additions and 434 deletions
@@ -1,4 +1,5 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
@@ -205,5 +206,27 @@ namespace Barotrauma.Items.Components
}
}
public void Save(XElement parentElement)
{
XElement newElement = new XElement(IsOutput ? "output" : "input", new XAttribute("name", Name));
Array.Sort(Wires, delegate (Wire wire1, Wire wire2)
{
if (wire1 == null) return 1;
if (wire2 == null) return -1;
return wire1.Item.ID.CompareTo(wire2.Item.ID);
});
for (int i = 0; i < MaxLinked; i++)
{
if (Wires[i] == null) continue;
newElement.Add(new XElement("link",
new XAttribute("w", Wires[i].Item.ID.ToString())));
}
parentElement.Add(newElement);
}
}
}