public XDocument GenerateShipOLD(GenerateOptions genOptions)
        {
            string             shipName = genOptions.shipName;
            ShipImplementation ship     = exporter.GetShipImplementation(shipName);
            Paint paint = ship.GetPaintByName(genOptions.paintName);
            //shipName = "AEGS_Gladius";
            XDocument xml         = new XDocument();
            string    loadoutName = null;

            if (genOptions.loadoutName != null)
            {
                loadoutName = genOptions.loadoutName;
            }
            else
            {
                loadoutName = "Default_Loadout_" + shipName;
            }

            string prefLibName = "";

            if (paint != null)
            {
                prefLibName = shipName + "-" + paint.name;
            }
            else
            {
                prefLibName = shipName;
            }
            prefLibName = "ships/" + prefLibName;
            XElement PrefabsLibrary = new XElement("PrefabsLibrary");

            //PrefabsLibrary.Attribute("Name").Value = shipName+"_Ship";
            //PrefabsLibrary.Add(new XAttribute("Name", shipName + "_Ship"));
            PrefabsLibrary.Add(new XAttribute("Name", prefLibName));

            XElement Prefab   = new XElement("Prefab");
            string   prefabId = GuidUtility.GenPrefabID(prefLibName);

            //Prefab.Add(new XAttribute("Name", shipName));
            Prefab.Add(new XAttribute("Name", "Ship"));
            Prefab.Add(new XAttribute("Id", prefabId));
            // Prefab.Add(new XAttribute("Library", shipName + "_Ship"));
            Prefab.Add(new XAttribute("Library", prefLibName));

            XElement Objects = new XElement("Objects");


            Loadout loadout = exporter.GetLoadout(loadoutName);

            Console.WriteLine(loadout.name);


            XElement Object = new XElement("Object");
            //string partid = GuidUtility.GenID("jhk777gt" + shipName  );
            //string layerid = GuidUtility.GenID("ghjg557kk" + shipName  );
            string partid   = GuidUtility.GenID();
            string layerid  = GuidUtility.GenID();
            string parentid = "0";

            parentid = partid;

            Object = AddObjects(Object, ship.parts.First(), loadout, parentid, partid, layerid, paint);
            i      = 0;
            //Object = AddPrefabsFromObjectContainers(Object, ship, parentid, layerid);
            Object = AddObjectsFromObjectContainers(Object, ship.objectContainers, parentid, layerid);

            if (Object.Attribute("Name") != null)
            {
                Objects.Add(Object);
            }
            //Objects.Add(Object);

            XElement ObjectsNew = new XElement("Objects");

            foreach (XElement obj in Objects.Descendants("Object"))
            {
                XElement ObjectNew = new XElement("Object");
                //ObjectNew.Add(new XElement("Properties"));
                if (obj.Element("Properties") != null)
                {
                    ObjectNew.Add(obj.Element("Properties"));
                }
                foreach (XAttribute atr in obj.Attributes())
                {
                    ObjectNew.Add(atr);
                }
                if (obj.Element("Components") != null)
                {
                    ObjectNew.Add(obj.Element("Components"));
                }

                if (obj.Element("Points") != null)
                {
                    ObjectNew.Add(obj.Element("Points"));
                }

                if (ObjectNew.Attribute("Name") != null)
                {
                    ObjectsNew.Add(ObjectNew);
                }
            }

            Prefab.Add(ObjectsNew);
            PrefabsLibrary.Add(Prefab);
            foreach (XElement pr in prefabs)
            {
                PrefabsLibrary.Add(pr);
            }
            xml.Add(PrefabsLibrary);

            //XDocument xmlpreflib = XDocument.Load(prefablib);
            //XElement preflibel = xmlpreflib.Element("PrefabsLibrary");
            //xml.Add(preflibel);

            return(xml);
        }
        public XDocument GenerateShipModification(GenerateOptions genOptions)
        {
            string shipName         = genOptions.shipName;
            string modificationName = genOptions.modificationName;

            XDocument xml = new XDocument();

            ShipImplementation ship           = exporter.GetShipImplementation(shipName);
            Paint        paint                = ship.GetPaintByName(genOptions.paintName);
            Modification shipModification     = ship.GetModificationByName(modificationName);
            string       modificationTrueName = shipModification.trueName;
            string       loadoutName          = null;

            if (genOptions.loadoutName != null)
            {
                loadoutName = genOptions.loadoutName;
            }
            else
            {
                loadoutName = "Default_Loadout_" + modificationTrueName;
            }
            Loadout loadout = exporter.GetLoadout(loadoutName);

            Console.WriteLine(loadout.name);

            string prefLibName = "";

            if (paint != null)
            {
                prefLibName = modificationTrueName + "-" + paint.name;
            }
            else
            {
                prefLibName = modificationTrueName;
            }
            prefLibName = "ships/Variants/" + prefLibName;
            XElement PrefabsLibrary = new XElement("PrefabsLibrary");

            PrefabsLibrary.Add(new XAttribute("Name", prefLibName));
            XElement Prefab   = new XElement("Prefab");
            string   prefabId = GuidUtility.GenPrefabID(prefLibName);

            Prefab.Add(new XAttribute("Name", "Ship"));
            Prefab.Add(new XAttribute("Id", prefabId));
            Prefab.Add(new XAttribute("Library", prefLibName));

            XElement Objects  = new XElement("Objects");
            XElement Object   = new XElement("Object");
            string   partid   = GuidUtility.GenID("werw34" + shipName + modificationName + prefLibName);
            string   layerid  = GuidUtility.GenID("dsfhf555hyyh" + shipName + modificationName + prefLibName);
            string   parentid = "0";

            parentid = partid;

            if (shipModification.parts.Count != 0)
            {
                Object = AddObjects(Object, shipModification.parts.First(), loadout, parentid, partid, layerid, paint);
                Object = AddObjectsFromObjectContainers(Object, shipModification.objectContainers, parentid, layerid);
            }
            else
            {
                Object = AddObjects(Object, ship.parts.First(), loadout, parentid, partid, layerid, paint);
                Object = AddObjectsFromObjectContainers(Object, ship.objectContainers, parentid, layerid);
            }
            i = 0;


            if (Object.Attribute("Name") != null)
            {
                Objects.Add(Object);
            }

            XElement ObjectsNew = new XElement("Objects");

            foreach (XElement obj in Objects.Descendants("Object"))
            {
                XElement ObjectNew = new XElement("Object");
                if (obj.Element("Properties") != null)
                {
                    ObjectNew.Add(obj.Element("Properties"));
                }
                foreach (XAttribute atr in obj.Attributes())
                {
                    ObjectNew.Add(atr);
                }
                if (obj.Element("Components") != null)
                {
                    ObjectNew.Add(obj.Element("Components"));
                }

                if (ObjectNew.Attribute("Name") != null)
                {
                    ObjectsNew.Add(ObjectNew);
                }
            }

            Prefab.Add(ObjectsNew);
            PrefabsLibrary.Add(Prefab);
            foreach (XElement pr in prefabs)
            {
                PrefabsLibrary.Add(pr);
            }
            xml.Add(PrefabsLibrary);

            return(xml);
        }