public void LoadData(FleetDesign data)
 {
     foreach (Ship ship in EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetFleetsDict()[this.FleetToEdit].Ships)
     {
         ship.GetSO().World = Matrix.CreateTranslation(new Vector3(ship.RelativeFleetOffset, -1000000f));
         ship.fleet = null;
     }
     this.fleet.DataNodes.Clear();
     this.fleet.Ships.Clear();
     foreach (List<Fleet.Squad> Flank in this.fleet.AllFlanks)
     {
         Flank.Clear();
     }
     this.fleet.Name = data.Name;
     foreach (FleetDataNode node in data.Data)
     {
         this.fleet.DataNodes.Add(node);
     }
     this.fleet.FleetIconIndex = data.FleetIconIndex;
 }
 public static void CreateFleetFromDataAt(FleetDesign data, Empire Owner, Vector2 Position, float facing)
 {
     Fleet fleet = new Fleet()
     {
         Position = Position,
         facing = facing,
         Owner = Owner,
         DataNodes = new BatchRemovalCollection<FleetDataNode>()
     };
     foreach (FleetDataNode node in data.Data)
     {
         fleet.DataNodes.Add(node);
     }
     fleet.AssignDataPositions(facing);
     fleet.Name = data.Name;
     fleet.FleetIconIndex = data.FleetIconIndex;
     fleet.DataNodes.thisLock.EnterWriteLock();
     foreach (FleetDataNode node in fleet.DataNodes)
     {
         Ship s = ResourceManager.CreateShipAtPoint(node.ShipName, Owner, Position + node.OrdersOffset, facing);
         s.RelativeFleetOffset = node.FleetOffset;
         node.SetShip(s);
         fleet.AddShip(s);
     }
     fleet.DataNodes.thisLock.ExitWriteLock();
     foreach (Ship s in Owner.GetFleetsDict()[1].Ships)
     {
         s.fleet = null;
     }
     Owner.GetFleetsDict()[1] = fleet;
 }
 private void DoSave()
 {
     FleetDesign d = new FleetDesign()
     {
         Name = this.EnterNameArea.Text
     };
     foreach (FleetDataNode node in this.f.DataNodes)
     {
         d.Data.Add(node);
     }
     d.FleetIconIndex = this.f.FleetIconIndex;
     string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
     XmlSerializer Serializer = new XmlSerializer(typeof(FleetDesign));
     TextWriter WriteFileStream = new StreamWriter(string.Concat(path, "/StarDrive/Fleet Designs/", this.EnterNameArea.Text, ".xml"));
     Serializer.Serialize(WriteFileStream, d);
     WriteFileStream.Close();
 }