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:
@@ -251,22 +251,5 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual XElement Save(XElement parentElement)
|
|
||||||
{
|
|
||||||
XElement componentElement = new XElement(name);
|
|
||||||
|
|
||||||
foreach (RelatedItem ri in requiredItems)
|
|
||||||
{
|
|
||||||
XElement newElement = new XElement("requireditem");
|
|
||||||
ri.Save(newElement);
|
|
||||||
componentElement.Add(newElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectProperty.SaveProperties(this, componentElement);
|
|
||||||
|
|
||||||
parentElement.Add(componentElement);
|
|
||||||
return componentElement;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace Barotrauma.Items.Components
|
namespace Barotrauma.Items.Components
|
||||||
{
|
{
|
||||||
@@ -64,20 +63,5 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
Inventory.Draw(spriteBatch);
|
Inventory.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override XElement Save(XElement parentElement)
|
|
||||||
{
|
|
||||||
XElement componentElement = base.Save(parentElement);
|
|
||||||
|
|
||||||
string[] itemIdStrings = new string[Inventory.Items.Length];
|
|
||||||
for (int i = 0; i < Inventory.Items.Length; i++)
|
|
||||||
{
|
|
||||||
itemIdStrings[i] = (Inventory.Items[i] == null) ? "0" : Inventory.Items[i].ID.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
componentElement.Add(new XAttribute("contained", string.Join(",", itemIdStrings)));
|
|
||||||
|
|
||||||
return componentElement;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using Microsoft.Xna.Framework;
|
|||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace Barotrauma.Items.Components
|
namespace Barotrauma.Items.Components
|
||||||
{
|
{
|
||||||
@@ -270,30 +269,5 @@ 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;
|
|
||||||
|
|
||||||
//Connection recipient = wires[i].OtherConnection(this);
|
|
||||||
|
|
||||||
//int connectionIndex = recipient.item.Connections.FindIndex(x => x == recipient);
|
|
||||||
newElement.Add(new XElement("link",
|
|
||||||
new XAttribute("w", Wires[i].Item.ID.ToString())));
|
|
||||||
}
|
|
||||||
|
|
||||||
parentElement.Add(newElement);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace Barotrauma.Items.Components
|
namespace Barotrauma.Items.Components
|
||||||
{
|
{
|
||||||
@@ -26,17 +25,5 @@ namespace Barotrauma.Items.Components
|
|||||||
Connection.DrawConnections(spriteBatch, this, character);
|
Connection.DrawConnections(spriteBatch, this, character);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override XElement Save(XElement parentElement)
|
|
||||||
{
|
|
||||||
XElement componentElement = base.Save(parentElement);
|
|
||||||
|
|
||||||
foreach (Connection c in Connections)
|
|
||||||
{
|
|
||||||
c.Save(componentElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentElement;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ using Microsoft.Xna.Framework;
|
|||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace Barotrauma.Items.Components
|
namespace Barotrauma.Items.Components
|
||||||
{
|
{
|
||||||
@@ -231,23 +229,5 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override XElement Save(XElement parentElement)
|
|
||||||
{
|
|
||||||
XElement componentElement = base.Save(parentElement);
|
|
||||||
|
|
||||||
if (nodes == null || nodes.Count == 0) return componentElement;
|
|
||||||
|
|
||||||
string[] nodeCoords = new string[nodes.Count * 2];
|
|
||||||
for (int i = 0; i < nodes.Count; i++)
|
|
||||||
{
|
|
||||||
nodeCoords[i * 2] = nodes[i].X.ToString(CultureInfo.InvariantCulture);
|
|
||||||
nodeCoords[i * 2 + 1] = nodes[i].Y.ToString(CultureInfo.InvariantCulture);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentElement.Add(new XAttribute("nodes", string.Join(";", nodeCoords)));
|
|
||||||
|
|
||||||
return componentElement;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -380,55 +379,6 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override XElement Save(XElement parentElement)
|
|
||||||
{
|
|
||||||
XElement element = new XElement("Item");
|
|
||||||
|
|
||||||
element.Add(new XAttribute("name", prefab.Name),
|
|
||||||
new XAttribute("ID", ID));
|
|
||||||
|
|
||||||
System.Diagnostics.Debug.Assert(Submarine != null);
|
|
||||||
|
|
||||||
if (ResizeHorizontal || ResizeVertical)
|
|
||||||
{
|
|
||||||
element.Add(new XAttribute("rect",
|
|
||||||
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
|
||||||
(int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," +
|
|
||||||
rect.Width + "," + rect.Height));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
element.Add(new XAttribute("rect",
|
|
||||||
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
|
||||||
(int)(rect.Y - Submarine.HiddenSubPosition.Y)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (linkedTo != null && linkedTo.Count > 0)
|
|
||||||
{
|
|
||||||
string[] linkedToIDs = new string[linkedTo.Count];
|
|
||||||
|
|
||||||
for (int i = 0; i < linkedTo.Count; i++)
|
|
||||||
{
|
|
||||||
linkedToIDs[i] = linkedTo[i].ID.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
element.Add(new XAttribute("linked", string.Join(",", linkedToIDs)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ObjectProperty.SaveProperties(this, element);
|
|
||||||
|
|
||||||
foreach (ItemComponent ic in components)
|
|
||||||
{
|
|
||||||
ic.Save(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
parentElement.Add(element);
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime)
|
public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime)
|
||||||
{
|
{
|
||||||
if (type == ServerNetObject.ENTITY_POSITION)
|
if (type == ServerNetObject.ENTITY_POSITION)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -58,34 +57,5 @@ namespace Barotrauma
|
|||||||
(int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f));
|
(int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override XElement Save(XElement parentElement)
|
|
||||||
{
|
|
||||||
XElement element = new XElement("Gap");
|
|
||||||
|
|
||||||
element.Add(
|
|
||||||
new XAttribute("ID", ID),
|
|
||||||
new XAttribute("horizontal", isHorizontal ? "true" : "false"));
|
|
||||||
|
|
||||||
element.Add(new XAttribute("rect",
|
|
||||||
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
|
||||||
(int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," +
|
|
||||||
rect.Width + "," + rect.Height));
|
|
||||||
|
|
||||||
//if (linkedTo != null)
|
|
||||||
//{
|
|
||||||
// int i = 0;
|
|
||||||
// foreach (Entity e in linkedTo)
|
|
||||||
// {
|
|
||||||
// if (e == null) continue;
|
|
||||||
// element.Add(new XAttribute("linkedto" + i, e.ID));
|
|
||||||
// i += 1;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
parentElement.Add(element);
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Microsoft.Xna.Framework;
|
|||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -323,27 +322,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
x += width;
|
x += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override XElement Save(XElement parentElement)
|
|
||||||
{
|
|
||||||
XElement element = new XElement("Hull");
|
|
||||||
|
|
||||||
element.Add
|
|
||||||
(
|
|
||||||
new XAttribute("ID", ID),
|
|
||||||
new XAttribute("rect",
|
|
||||||
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
|
||||||
(int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," +
|
|
||||||
rect.Width + "," + rect.Height),
|
|
||||||
new XAttribute("water", volume)
|
|
||||||
);
|
|
||||||
|
|
||||||
parentElement.Add(element);
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using Microsoft.Xna.Framework;
|
|||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
@@ -145,86 +144,5 @@ namespace Barotrauma
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override XElement Save(XElement parentElement)
|
|
||||||
{
|
|
||||||
XElement saveElement = null;
|
|
||||||
|
|
||||||
if (sub == null)
|
|
||||||
{
|
|
||||||
if (this.saveElement == null)
|
|
||||||
{
|
|
||||||
var doc = Submarine.OpenFile(filePath);
|
|
||||||
saveElement = doc.Root;
|
|
||||||
|
|
||||||
saveElement.Name = "LinkedSubmarine";
|
|
||||||
|
|
||||||
saveElement.Add(new XAttribute("filepath", filePath));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
saveElement = this.saveElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (saveElement.Attribute("pos") != null) saveElement.Attribute("pos").Remove();
|
|
||||||
saveElement.Add(new XAttribute("pos", ToolBox.Vector2ToString(Position - Submarine.HiddenSubPosition)));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var linkedPort = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
|
||||||
if (linkedPort != null)
|
|
||||||
{
|
|
||||||
if (saveElement.Attribute("linkedto") != null) saveElement.Attribute("linkedto").Remove();
|
|
||||||
|
|
||||||
saveElement.Add(new XAttribute("linkedto", linkedPort.ID));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
saveElement = new XElement("LinkedSubmarine");
|
|
||||||
|
|
||||||
|
|
||||||
sub.SaveToXElement(saveElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sub != null)
|
|
||||||
{
|
|
||||||
bool leaveBehind = false;
|
|
||||||
if (!sub.DockedTo.Contains(Submarine.MainSub))
|
|
||||||
{
|
|
||||||
System.Diagnostics.Debug.Assert(Submarine.MainSub.AtEndPosition || Submarine.MainSub.AtStartPosition);
|
|
||||||
if (Submarine.MainSub.AtEndPosition)
|
|
||||||
{
|
|
||||||
leaveBehind = sub.AtEndPosition != Submarine.MainSub.AtEndPosition;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
leaveBehind = sub.AtStartPosition != Submarine.MainSub.AtStartPosition;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (leaveBehind)
|
|
||||||
{
|
|
||||||
saveElement.SetAttributeValue("location", Level.Loaded.Seed);
|
|
||||||
saveElement.SetAttributeValue("worldpos", ToolBox.Vector2ToString(sub.SubBody.Position));
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (saveElement.Attribute("location") != null) saveElement.Attribute("location").Remove();
|
|
||||||
if (saveElement.Attribute("worldpos") != null) saveElement.Attribute("worldpos").Remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
saveElement.SetAttributeValue("pos", ToolBox.Vector2ToString(Position - Submarine.HiddenSubPosition));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
parentElement.Add(saveElement);
|
|
||||||
|
|
||||||
return saveElement;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Microsoft.Xna.Framework.Input;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -75,20 +74,10 @@ namespace Barotrauma
|
|||||||
get { return selectedList.Contains(this); }
|
get { return selectedList.Contains(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool ResizeHorizontal
|
|
||||||
{
|
|
||||||
get { return prefab != null && prefab.ResizeHorizontal; }
|
|
||||||
}
|
|
||||||
protected bool ResizeVertical
|
|
||||||
{
|
|
||||||
get { return prefab != null && prefab.ResizeVertical; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Draw(SpriteBatch spriteBatch, bool editing, bool back = true) { }
|
public virtual void Draw(SpriteBatch spriteBatch, bool editing, bool back = true) { }
|
||||||
|
|
||||||
public virtual void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect) { }
|
public virtual void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect) { }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the selection logic in submarine editor
|
/// Update the selection logic in submarine editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -635,13 +624,5 @@ namespace Barotrauma
|
|||||||
|
|
||||||
return foundEntities;
|
return foundEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual XElement Save(XElement parentElement)
|
|
||||||
{
|
|
||||||
DebugConsole.ThrowError("Saving entity " + GetType() + " failed.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
partial class Structure : MapEntity, IDamageable, IServerSerializable
|
partial class Structure : MapEntity, IDamageable, IServerSerializable
|
||||||
{
|
{
|
||||||
List<ConvexHull> convexHulls;
|
private List<ConvexHull> convexHulls;
|
||||||
|
|
||||||
private void GenerateConvexHull()
|
private void GenerateConvexHull()
|
||||||
{
|
{
|
||||||
@@ -149,39 +149,5 @@ namespace Barotrauma
|
|||||||
|
|
||||||
prefab.sprite.effects = oldEffects;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,48 +103,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Save()
|
|
||||||
{
|
|
||||||
return SaveAs(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SaveAs(string filePath)
|
|
||||||
{
|
|
||||||
name = System.IO.Path.GetFileNameWithoutExtension(filePath);
|
|
||||||
|
|
||||||
XDocument doc = new XDocument(new XElement("Submarine"));
|
|
||||||
SaveToXElement(doc.Root);
|
|
||||||
|
|
||||||
hash = new Md5Hash(doc);
|
|
||||||
doc.Root.Add(new XAttribute("md5hash", hash.Hash));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SaveUtil.CompressStringToFile(filePath, doc.ToString());
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
DebugConsole.ThrowError("Saving submarine \"" + filePath + "\" failed!", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveToXElement(XElement element)
|
|
||||||
{
|
|
||||||
element.Add(new XAttribute("name", name));
|
|
||||||
element.Add(new XAttribute("description", Description == null ? "" : Description));
|
|
||||||
|
|
||||||
element.Add(new XAttribute("tags", tags.ToString()));
|
|
||||||
|
|
||||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
|
||||||
{
|
|
||||||
if (e.MoveWithLevel || e.Submarine != this) continue;
|
|
||||||
e.Save(element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool SaveCurrent(string filePath)
|
public static bool SaveCurrent(string filePath)
|
||||||
{
|
{
|
||||||
if (Submarine.MainSub == null)
|
if (Submarine.MainSub == null)
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Xml.Linq;
|
|
||||||
//using Microsoft.Xna.Framework.Input;
|
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -192,52 +190,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//GUI.Font.DrawString(spriteBatch, "Spawnpoint: " + spawnType.ToString() + " +/-", new Vector2(x, y + 40), Color.Black);
|
|
||||||
|
|
||||||
|
|
||||||
y = y + 30;
|
y = y + 30;
|
||||||
|
|
||||||
return editingHUD;
|
return editingHUD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override XElement Save(XElement parentElement)
|
|
||||||
{
|
|
||||||
if (MoveWithLevel) return null;
|
|
||||||
XElement element = new XElement("WayPoint");
|
|
||||||
|
|
||||||
element.Add(new XAttribute("ID", ID),
|
|
||||||
new XAttribute("x", (int)(rect.X - Submarine.HiddenSubPosition.X)),
|
|
||||||
new XAttribute("y", (int)(rect.Y - Submarine.HiddenSubPosition.Y)),
|
|
||||||
new XAttribute("spawn", spawnType));
|
|
||||||
|
|
||||||
if (idCardTags.Length > 0)
|
|
||||||
{
|
|
||||||
element.Add(new XAttribute("idcardtags", string.Join(",", idCardTags)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (assignedJob != null) element.Add(new XAttribute("job", assignedJob.Name));
|
|
||||||
|
|
||||||
|
|
||||||
if (ConnectedGap != null) element.Add(new XAttribute("gap", ConnectedGap.ID));
|
|
||||||
if (Ladders != null) element.Add(new XAttribute("ladders", Ladders.Item.ID));
|
|
||||||
|
|
||||||
parentElement.Add(element);
|
|
||||||
|
|
||||||
if (linkedTo != null)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
foreach (MapEntity e in linkedTo)
|
|
||||||
{
|
|
||||||
element.Add(new XAttribute("linkedto" + i, e.ID));
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -575,5 +575,21 @@ namespace Barotrauma.Items.Components
|
|||||||
return ic;
|
return ic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual XElement Save(XElement parentElement)
|
||||||
|
{
|
||||||
|
XElement componentElement = new XElement(name);
|
||||||
|
|
||||||
|
foreach (RelatedItem ri in requiredItems)
|
||||||
|
{
|
||||||
|
XElement newElement = new XElement("requireditem");
|
||||||
|
ri.Save(newElement);
|
||||||
|
componentElement.Add(newElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectProperty.SaveProperties(this, componentElement);
|
||||||
|
|
||||||
|
parentElement.Add(componentElement);
|
||||||
|
return componentElement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
public const int MaxInventoryCount = 4;
|
public const int MaxInventoryCount = 4;
|
||||||
|
|
||||||
List<RelatedItem> containableItems;
|
private List<RelatedItem> containableItems;
|
||||||
public ItemInventory Inventory;
|
public ItemInventory Inventory;
|
||||||
|
|
||||||
private List<Pair<Item, StatusEffect>> itemsWithStatusEffects;
|
private List<Pair<Item, StatusEffect>> itemsWithStatusEffects;
|
||||||
|
|
||||||
|
private ushort[] itemIds;
|
||||||
|
|
||||||
//how many items can be contained
|
//how many items can be contained
|
||||||
[HasDefaultValue(5, false)]
|
[HasDefaultValue(5, false)]
|
||||||
public int Capacity
|
public int Capacity
|
||||||
@@ -240,6 +242,19 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ushort[] itemIds;
|
public override XElement Save(XElement parentElement)
|
||||||
|
{
|
||||||
|
XElement componentElement = base.Save(parentElement);
|
||||||
|
|
||||||
|
string[] itemIdStrings = new string[Inventory.Items.Length];
|
||||||
|
for (int i = 0; i < Inventory.Items.Length; i++)
|
||||||
|
{
|
||||||
|
itemIdStrings[i] = (Inventory.Items[i] == null) ? "0" : Inventory.Items[i].ID.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentElement.Add(new XAttribute("contained", string.Join(",", itemIdStrings)));
|
||||||
|
|
||||||
|
return componentElement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Xml.Linq;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,6 +108,18 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override XElement Save(XElement parentElement)
|
||||||
|
{
|
||||||
|
XElement componentElement = base.Save(parentElement);
|
||||||
|
|
||||||
|
foreach (Connection c in Connections)
|
||||||
|
{
|
||||||
|
c.Save(componentElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
return componentElement;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void RemoveComponentSpecific()
|
protected override void RemoveComponentSpecific()
|
||||||
{
|
{
|
||||||
foreach (Connection c in Connections)
|
foreach (Connection c in Connections)
|
||||||
|
|||||||
@@ -477,6 +477,24 @@ namespace Barotrauma.Items.Components
|
|||||||
Drawable = nodes.Any();
|
Drawable = nodes.Any();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override XElement Save(XElement parentElement)
|
||||||
|
{
|
||||||
|
XElement componentElement = base.Save(parentElement);
|
||||||
|
|
||||||
|
if (nodes == null || nodes.Count == 0) return componentElement;
|
||||||
|
|
||||||
|
string[] nodeCoords = new string[nodes.Count * 2];
|
||||||
|
for (int i = 0; i < nodes.Count; i++)
|
||||||
|
{
|
||||||
|
nodeCoords[i * 2] = nodes[i].X.ToString(CultureInfo.InvariantCulture);
|
||||||
|
nodeCoords[i * 2 + 1] = nodes[i].Y.ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentElement.Add(new XAttribute("nodes", string.Join(";", nodeCoords)));
|
||||||
|
|
||||||
|
return componentElement;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void ShallowRemoveComponentSpecific()
|
protected override void ShallowRemoveComponentSpecific()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
|
|||||||
@@ -1676,7 +1676,53 @@ namespace Barotrauma
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override XElement Save(XElement parentElement)
|
||||||
|
{
|
||||||
|
XElement element = new XElement("Item");
|
||||||
|
|
||||||
|
element.Add(new XAttribute("name", prefab.Name),
|
||||||
|
new XAttribute("ID", ID));
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.Assert(Submarine != null);
|
||||||
|
|
||||||
|
if (ResizeHorizontal || ResizeVertical)
|
||||||
|
{
|
||||||
|
element.Add(new XAttribute("rect",
|
||||||
|
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
||||||
|
(int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," +
|
||||||
|
rect.Width + "," + rect.Height));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
element.Add(new XAttribute("rect",
|
||||||
|
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
||||||
|
(int)(rect.Y - Submarine.HiddenSubPosition.Y)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkedTo != null && linkedTo.Count > 0)
|
||||||
|
{
|
||||||
|
string[] linkedToIDs = new string[linkedTo.Count];
|
||||||
|
|
||||||
|
for (int i = 0; i < linkedTo.Count; i++)
|
||||||
|
{
|
||||||
|
linkedToIDs[i] = linkedTo[i].ID.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
element.Add(new XAttribute("linked", string.Join(",", linkedToIDs)));
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectProperty.SaveProperties(this, element);
|
||||||
|
|
||||||
|
foreach (ItemComponent ic in components)
|
||||||
|
{
|
||||||
|
ic.Save(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
parentElement.Add(element);
|
||||||
|
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnMapLoaded()
|
public override void OnMapLoaded()
|
||||||
|
|||||||
@@ -685,12 +685,24 @@ namespace Barotrauma
|
|||||||
g.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
g.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
||||||
|
|
||||||
g.linkedToID = new List<ushort>();
|
g.linkedToID = new List<ushort>();
|
||||||
//int i = 0;
|
}
|
||||||
//while (element.Attribute("linkedto" + i) != null)
|
|
||||||
//{
|
public override XElement Save(XElement parentElement)
|
||||||
// g.linkedToID.Add(int.Parse(element.Attribute("linkedto" + i).Value));
|
{
|
||||||
// i += 1;
|
XElement element = new XElement("Gap");
|
||||||
//}
|
|
||||||
|
element.Add(
|
||||||
|
new XAttribute("ID", ID),
|
||||||
|
new XAttribute("horizontal", isHorizontal ? "true" : "false"));
|
||||||
|
|
||||||
|
element.Add(new XAttribute("rect",
|
||||||
|
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
||||||
|
(int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," +
|
||||||
|
rect.Width + "," + rect.Height));
|
||||||
|
|
||||||
|
parentElement.Add(element);
|
||||||
|
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -736,5 +736,24 @@ namespace Barotrauma
|
|||||||
h.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
h.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override XElement Save(XElement parentElement)
|
||||||
|
{
|
||||||
|
XElement element = new XElement("Hull");
|
||||||
|
|
||||||
|
element.Add
|
||||||
|
(
|
||||||
|
new XAttribute("ID", ID),
|
||||||
|
new XAttribute("rect",
|
||||||
|
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
||||||
|
(int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," +
|
||||||
|
rect.Width + "," + rect.Height),
|
||||||
|
new XAttribute("water", volume)
|
||||||
|
);
|
||||||
|
|
||||||
|
parentElement.Add(element);
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,5 +237,86 @@ namespace Barotrauma
|
|||||||
sub.SetPosition(sub.WorldPosition - Submarine.WorldPosition);
|
sub.SetPosition(sub.WorldPosition - Submarine.WorldPosition);
|
||||||
sub.Submarine = Submarine;
|
sub.Submarine = Submarine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override XElement Save(XElement parentElement)
|
||||||
|
{
|
||||||
|
XElement saveElement = null;
|
||||||
|
|
||||||
|
if (sub == null)
|
||||||
|
{
|
||||||
|
if (this.saveElement == null)
|
||||||
|
{
|
||||||
|
var doc = Submarine.OpenFile(filePath);
|
||||||
|
saveElement = doc.Root;
|
||||||
|
|
||||||
|
saveElement.Name = "LinkedSubmarine";
|
||||||
|
|
||||||
|
saveElement.Add(new XAttribute("filepath", filePath));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
saveElement = this.saveElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saveElement.Attribute("pos") != null) saveElement.Attribute("pos").Remove();
|
||||||
|
saveElement.Add(new XAttribute("pos", ToolBox.Vector2ToString(Position - Submarine.HiddenSubPosition)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var linkedPort = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
||||||
|
if (linkedPort != null)
|
||||||
|
{
|
||||||
|
if (saveElement.Attribute("linkedto") != null) saveElement.Attribute("linkedto").Remove();
|
||||||
|
|
||||||
|
saveElement.Add(new XAttribute("linkedto", linkedPort.ID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
saveElement = new XElement("LinkedSubmarine");
|
||||||
|
|
||||||
|
|
||||||
|
sub.SaveToXElement(saveElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sub != null)
|
||||||
|
{
|
||||||
|
bool leaveBehind = false;
|
||||||
|
if (!sub.DockedTo.Contains(Submarine.MainSub))
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.Assert(Submarine.MainSub.AtEndPosition || Submarine.MainSub.AtStartPosition);
|
||||||
|
if (Submarine.MainSub.AtEndPosition)
|
||||||
|
{
|
||||||
|
leaveBehind = sub.AtEndPosition != Submarine.MainSub.AtEndPosition;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
leaveBehind = sub.AtStartPosition != Submarine.MainSub.AtStartPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (leaveBehind)
|
||||||
|
{
|
||||||
|
saveElement.SetAttributeValue("location", Level.Loaded.Seed);
|
||||||
|
saveElement.SetAttributeValue("worldpos", ToolBox.Vector2ToString(sub.SubBody.Position));
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (saveElement.Attribute("location") != null) saveElement.Attribute("location").Remove();
|
||||||
|
if (saveElement.Attribute("worldpos") != null) saveElement.Attribute("worldpos").Remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
saveElement.SetAttributeValue("pos", ToolBox.Vector2ToString(Position - Submarine.HiddenSubPosition));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
parentElement.Add(saveElement);
|
||||||
|
|
||||||
|
return saveElement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ using FarseerPhysics;
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
//using Microsoft.Xna.Framework.Graphics;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -89,6 +89,15 @@ namespace Barotrauma
|
|||||||
get { return false; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected bool ResizeHorizontal
|
||||||
|
{
|
||||||
|
get { return prefab != null && prefab.ResizeHorizontal; }
|
||||||
|
}
|
||||||
|
protected bool ResizeVertical
|
||||||
|
{
|
||||||
|
get { return prefab != null && prefab.ResizeVertical; }
|
||||||
|
}
|
||||||
|
|
||||||
public virtual bool SelectableInEditor
|
public virtual bool SelectableInEditor
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
@@ -375,9 +384,13 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual void OnMapLoaded() { }
|
public virtual void OnMapLoaded() { }
|
||||||
|
|
||||||
|
public virtual XElement Save(XElement parentElement)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Saving entity " + GetType() + " failed.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void RemoveLinked(MapEntity e)
|
public void RemoveLinked(MapEntity e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -856,6 +856,39 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnMapLoaded()
|
public override void OnMapLoaded()
|
||||||
{
|
{
|
||||||
foreach (WallSection s in sections)
|
foreach (WallSection s in sections)
|
||||||
|
|||||||
@@ -1105,6 +1105,50 @@ namespace Barotrauma
|
|||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool Save()
|
||||||
|
{
|
||||||
|
return SaveAs(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SaveAs(string filePath)
|
||||||
|
{
|
||||||
|
name = System.IO.Path.GetFileNameWithoutExtension(filePath);
|
||||||
|
|
||||||
|
XDocument doc = new XDocument(new XElement("Submarine"));
|
||||||
|
SaveToXElement(doc.Root);
|
||||||
|
|
||||||
|
hash = new Md5Hash(doc);
|
||||||
|
doc.Root.Add(new XAttribute("md5hash", hash.Hash));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SaveUtil.CompressStringToFile(filePath, doc.ToString());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Saving submarine \"" + filePath + "\" failed!", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveToXElement(XElement element)
|
||||||
|
{
|
||||||
|
element.Add(new XAttribute("name", name));
|
||||||
|
element.Add(new XAttribute("description", Description == null ? "" : Description));
|
||||||
|
|
||||||
|
element.Add(new XAttribute("tags", tags.ToString()));
|
||||||
|
|
||||||
|
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||||
|
{
|
||||||
|
if (e.MoveWithLevel || e.Submarine != this) continue;
|
||||||
|
e.Save(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static bool Unloading
|
public static bool Unloading
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|||||||
@@ -594,6 +594,42 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override XElement Save(XElement parentElement)
|
||||||
|
{
|
||||||
|
if (MoveWithLevel) return null;
|
||||||
|
XElement element = new XElement("WayPoint");
|
||||||
|
|
||||||
|
element.Add(new XAttribute("ID", ID),
|
||||||
|
new XAttribute("x", (int)(rect.X - Submarine.HiddenSubPosition.X)),
|
||||||
|
new XAttribute("y", (int)(rect.Y - Submarine.HiddenSubPosition.Y)),
|
||||||
|
new XAttribute("spawn", spawnType));
|
||||||
|
|
||||||
|
if (idCardTags.Length > 0)
|
||||||
|
{
|
||||||
|
element.Add(new XAttribute("idcardtags", string.Join(",", idCardTags)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assignedJob != null) element.Add(new XAttribute("job", assignedJob.Name));
|
||||||
|
|
||||||
|
|
||||||
|
if (ConnectedGap != null) element.Add(new XAttribute("gap", ConnectedGap.ID));
|
||||||
|
if (Ladders != null) element.Add(new XAttribute("ladders", Ladders.Item.ID));
|
||||||
|
|
||||||
|
parentElement.Add(element);
|
||||||
|
|
||||||
|
if (linkedTo != null)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
foreach (MapEntity e in linkedTo)
|
||||||
|
{
|
||||||
|
element.Add(new XAttribute("linkedto" + i, e.ID));
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
public override void ShallowRemove()
|
public override void ShallowRemove()
|
||||||
{
|
{
|
||||||
base.ShallowRemove();
|
base.ShallowRemove();
|
||||||
|
|||||||
Reference in New Issue
Block a user