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
@@ -16,7 +16,7 @@ namespace Barotrauma
partial class Structure : MapEntity, IDamageable, IServerSerializable
{
List<ConvexHull> convexHulls;
private List<ConvexHull> convexHulls;
private void GenerateConvexHull()
{
@@ -149,39 +149,5 @@ namespace Barotrauma
prefab.sprite.effects = oldEffects;
}
public override XElement Save(XElement parentElement)
{
XElement element = new XElement("Structure");
element.Add(new XAttribute("name", prefab.Name),
new XAttribute("ID", ID),
new XAttribute("rect",
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
(int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," +
rect.Width + "," + rect.Height));
for (int i = 0; i < sections.Length; i++)
{
if (sections[i].damage == 0.0f) continue;
var sectionElement =
new XElement("section",
new XAttribute("i", i),
new XAttribute("damage", sections[i].damage));
if (sections[i].gap != null)
{
sectionElement.Add(new XAttribute("gap", sections[i].gap.ID));
}
element.Add(sectionElement);
}
parentElement.Add(element);
return element;
}
}
}