public GalaxyData(XmlNode galaxyNode, CatDatExtractor cde)
        {
            try
            {
                GalaxyNode = galaxyNode;
                XmlNode childNode = XMLFunctions.FindChild(GalaxyNode, "connections").FirstChild;
                while (childNode != null)
                {
                    try
                    {
                        if (childNode.Attributes["connection"].Value.ToLower() != "clusters")
                        {
                            Clusters.Add(new ClusterData(childNode, cde));
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Unable to parse child of galaxy.", ex);
                    }

                    childNode = childNode.NextSibling;
                }

                GetSkunk();
                this.cde = cde;
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to parse galaxy node.", ex);
            }
        }
        public HighwayData(XmlNode highwayNode, CatDatExtractor cde)
        {
            // 1 Celestialbody: <connection connection="region_zone_011_connection"> -> <component class="celestialbody" component="cluster_b" connection="space" id="[0x1b5e7]">
            try
            {
                this.cde    = cde;
                HighwayNode = highwayNode.FirstChild;
                HighwayName = highwayNode.Attributes["connection"].Value;

                XmlNode childNode = XMLFunctions.FindChild(HighwayNode, "connections").FirstChild;

                while (childNode != null)
                {
                    try
                    {
                        if (childNode.Attributes["connection"].Value == "ships")
                        {
                            Ships.Add(new ShipData(childNode, cde));
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Unable to add Highway child", ex);
                    }
                    childNode = childNode.NextSibling;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to parse Highway node.", ex);
            }
        }
Example #3
0
        public RegionData(XmlNode regionNode, CatDatExtractor cde)
        {
            try
            {
                // 1 Region: <connection connection="region_zone_011_connection"> -> <component class="region" macro="region_zone_011_macro" connection="cluster" id="[0x17266]">
                RegionNode = regionNode.FirstChild;
                RegionName = regionNode.Attributes["connection"].Value;
                // Some region does not have any "connections" node.
                if (XMLFunctions.FindChild(RegionNode, "connections") != null)
                {
                    XmlNode childNode = XMLFunctions.FindChild(RegionNode, "connections").FirstChild;
                    this.cde = cde;

                    while (childNode != null)
                    {
                        try
                        {
                            if (childNode.Attributes["connection"].Value == "ships")
                            {
                                Ships.Add(new ShipData(childNode, cde));
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.Error("Unable to add child to region.", ex);
                        }
                        childNode = childNode.NextSibling;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to parse region.", ex);
            }
        }
        public ShipWeaponCycleSlotData(XmlNode weaponCycleSlotNode, CatDatExtractor cde)
        {
            try
            {
                this.cde            = cde;
                WeaponCycleSlotNode = weaponCycleSlotNode;
                WeaponCycleSlotRef  = WeaponCycleSlotNode.Attributes["ref"].Value;

                XmlNode childNode = WeaponCycleSlotNode.FirstChild;
                while (childNode != null)
                {
                    XmlAttribute indexAt = WeaponCycleSlotNode.Attributes["Index"];
                    int          index   = 0;

                    if (indexAt != null)
                    {
                        index = Convert.ToInt32(indexAt.Value);
                    }
                    WeaponCycleCycle.Add(new KeyValuePair <string, int>(WeaponCycleSlotNode.Attributes["ref"].Value, index));
                    childNode = childNode.NextSibling;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to parse weapon cycle slots", ex);
            }
        }
 public TypeObject(XmlNode shipNode, XmlNode shipGroupNode, CatDatExtractor cde)
 {
     ShipNode      = shipNode;
     ShipGroupNode = shipGroupNode;
     _isShip       = true;
     this.cde      = cde;
 }
 public LicenceData(string factions, string type, XmlNode parent, CatDatExtractor cde)
 {
     LicenseNode = parent.OwnerDocument.CreateElement("license");
     LicenseNode.Attributes.Append(parent.OwnerDocument.CreateAttribute("type"));
     LicenseNode.Attributes["type"].Value = type;
     LicenseNode.Attributes.Append(parent.OwnerDocument.CreateAttribute("factions"));
     LicenseNode.Attributes["factions"].Value = factions;
     parent.AppendChild(LicenseNode);
 }
Example #7
0
 public RelationData(string faction, float relation, XmlNode parent, CatDatExtractor cde)
 {
     RelationNode = parent.OwnerDocument.CreateElement("relation");
     RelationNode.Attributes.Append(parent.OwnerDocument.CreateAttribute("faction"));
     RelationNode.Attributes["faction"].Value = faction;
     RelationNode.Attributes.Append(parent.OwnerDocument.CreateAttribute("relation"));
     RelationNode.Attributes["relation"].Value = relation.ToString();
     parent.AppendChild(RelationNode);
 }
 public NPCsData(XmlNode saveGame, CatDatExtractor cde)
 {
     this.cde = cde;
     //component class="npc"
     foreach (XmlNode node in saveGame.SelectNodes("//component[@class='npc']"))
     {
         NPCs.Add(new NPCData(node.ParentNode, cde));
     }
 }
 public FactionData(string factionName, XmlNode parent, CatDatExtractor cde, FactionsData factionsData)
 {
     FactionNode = parent.OwnerDocument.CreateElement("faction");
     parent.AppendChild(FactionNode);
     FactionNode.Attributes.Append(parent.OwnerDocument.CreateAttribute("id"));
     FactionNode.Attributes["id"].Value = factionName;
     this.cde          = cde;
     this.factionsData = factionsData;
 }
        public FactionsData(XmlNode factionsNode, CatDatExtractor cde)
        {
            FactionsNode = factionsNode;
            this.cde     = cde;

            foreach (XmlNode node in factionsNode.ChildNodes)
            {
                Factions.Add(new FactionData(node, cde, this));
            }
        }
 public ShipStorageData(XmlNode shipStorageNode, CatDatExtractor cde)
 {
     try
     {
         this.cde        = cde;
         ShipStorageNode = shipStorageNode;
     }
     catch (Exception ex)
     {
         throw new Exception("Unable to parse ship storage.", ex);
     }
 }
 public ShipCockpitData(XmlNode shipCockpitNode, CatDatExtractor cde)
 {
     try
     {
         this.cde        = cde;
         ShipCockpitNode = shipCockpitNode;
     }
     catch (Exception ex)
     {
         throw new Exception("Unable to parse cockpit", ex);
     }
 }
 public CelestialbodyData(XmlNode celestialbodyNode, CatDatExtractor cde)
 {
     // 1 Celestialbody: <connection connection="region_zone_011_connection"> -> <component class="celestialbody" component="cluster_b" connection="space" id="[0x1b5e7]">
     try
     {
         CelestialbodyNode = celestialbodyNode.FirstChild;
         CelestialbodyName = celestialbodyNode.Attributes["connection"].Value;
         this.cde          = cde;
     }
     catch (Exception ex)
     {
         Logger.Warning("Unable to create CelestialbodyData.", ex);
     }
 }
Example #14
0
        public SectorData(XmlNode sectorNode, CatDatExtractor cde)
        {
            try
            {
                this.cde = cde;

                // 1 Sector: <connection connection="cluster_b_sector04_connection"> -> <component class="sector" macro="cluster_b_sector04_macro" connection="cluster" knownto="player" id="[0x17267]">
                SectorNode = sectorNode.FirstChild;
                SectorName = sectorNode.Attributes["connection"].Value;

                XmlNode childNode = XMLFunctions.FindChild(SectorNode, "connections").FirstChild;
                while (childNode != null)
                {
                    try
                    {
                        if (childNode.FirstChild.Attributes["class"].Value.ToLower() == "zone" &&
                            childNode.FirstChild.Attributes["macro"].Value.ToLower() == "tempzone"
                            )
                        {
                            TempZones.Add(new ZoneData(childNode, cde));
                        }
                        else if (childNode.FirstChild.Attributes["class"].Value.ToLower() == "zone")
                        {
                            Zones.Add(new ZoneData(childNode, cde));
                        }
                        else if (childNode.FirstChild.Attributes["class"].Value.ToLower() == "highway")
                        {
                            Highways.Add(new HighwayData(childNode, cde));
                        }
                        else
                        {
                            throw new Exception("Not a zone or highway. This is a " + childNode.FirstChild.Attributes["class"].Value);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Unable to add child to sector", ex);
                    }

                    childNode = childNode.NextSibling;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to parse sector.", ex);
            }
        }
        public SaveGameInfoData(XmlNode saveGameInfoNode, CatDatExtractor cde)
        {
            SaveGameInfoNode = saveGameInfoNode;
            this.cde         = cde;
            XmlNode patches = XMLFunctions.FindChild(saveGameInfoNode, "patches");

            if (patches != null)
            {
                XmlNode patch = patches.FirstChild;

                while (patch != null)
                {
                    Patches.Add(new PatchInfoData(patch, cde));
                    patch = patch.NextSibling;
                }
            }
        }
Example #16
0
        public ShipShieldData(XmlNode shipShieldNode, CatDatExtractor cde)
        {
            this.cde       = cde;
            ShipShieldNode = shipShieldNode;
// behind: <connection connection="connection_dock_s01" macro="connection_dock_s01">
//            <connection connection="shields">
//<component class="shieldgenerator" macro="shieldgenerator_player_bal_mk4_macro" connection="connection01" id="[0xc5c]">
//<offset default="1" />
//<connections />
//</component>
//</connection>
// At the end
//            <connection connection="shieldgenerators">
//<component class="shieldgenerator" macro="shieldgenerator_player_cap_mk3_macro" connection="connection01" id="[0xc72]">
//<offset default="1" />
//<connections />
//</component>
//</connection>
        }
        public ShipSoftwareData(string macro, string softwareSlot, XmlNode shipNode, CatDatExtractor cde)
        {
            // Create software
            XmlElement   connection    = shipNode.OwnerDocument.CreateElement("connection");
            XmlAttribute connectionAtt = shipNode.OwnerDocument.CreateAttribute("connection");

            connectionAtt.Value = softwareSlot;
            connection.Attributes.Append(connectionAtt);
            XmlElement   component         = shipNode.OwnerDocument.CreateElement("component");
            XmlAttribute componentAttClass = shipNode.OwnerDocument.CreateAttribute("clas");

            componentAttClass.Value = "software";
            component.Attributes.Append(componentAttClass);
            XmlAttribute componentAttmacro = shipNode.OwnerDocument.CreateAttribute("macro");

            componentAttmacro.Value = macro;
            component.Attributes.Append(componentAttmacro);
            XmlAttribute componentAttConn = shipNode.OwnerDocument.CreateAttribute("connection");

            componentAttConn.Value = "softwareconnection";
            component.Attributes.Append(componentAttConn);
            XmlAttribute componentAttId = shipNode.OwnerDocument.CreateAttribute("id");

            componentAttId.Value = XMLFunctions.DetermineNewId(shipNode.OwnerDocument);
            component.Attributes.Append(componentAttId);
            connection.AppendChild(component);

            XmlNode insertAfter = null;

            if (SoftwareSlot == 2)
            {
                insertAfter = XMLFunctions.FindChild(shipNode.FirstChild, "connections").SelectSingleNode("connection[@connection='connection_software01']");
            }

            if (insertAfter == null)
            {
                insertAfter = XMLFunctions.FindChild(shipNode.FirstChild, "connections").SelectSingleNode("connection[@connection='storage']");
            }
            XMLFunctions.FindChild(shipNode.FirstChild, "connections").InsertAfter(connection, insertAfter);

            this.cde         = cde;
            ShipSoftwareNode = connection;
        }
        public ZoneData(XmlNode zoneNode, CatDatExtractor cde)
        {
            try
            {
                this.cde = cde;
                // 1 Zone: <connection connection="tzonecluster_d_sector18_zone45_connection"> -> <component class="zone" macro="tzonecluster_d_sector18_zone45_macro" connection="sector" owner="canteran" knownto="player" id="[0x1c2c5]">
                ZoneNode = zoneNode.FirstChild;
                ZoneName = zoneNode.Attributes["connection"].Value;
                // Some zone does not have any "connections" node.
                if (XMLFunctions.FindChild(ZoneNode, "connections") != null)
                {
                    XmlNode childNode = XMLFunctions.FindChild(ZoneNode, "connections").FirstChild;

                    while (childNode != null)
                    {
                        try
                        {
                            if (childNode.Attributes["connection"].Value == "ships")
                            {
                                Ships.Add(new ShipData(childNode, cde));
                            }
                            else if (childNode.HasChildNodes && childNode.FirstChild.Attributes["class"] != null && childNode.FirstChild.Attributes["class"].Value.StartsWith("ship"))
                            {
                                Ships.Add(new ShipData(childNode, cde));
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.Error("Unable to add child node for zone", ex);
                        }
                        childNode = childNode.NextSibling;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to parse zone node", ex);
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="shipSoftwareNode"></param>
 public ShipSoftwareData(XmlNode shipSoftwareNode, CatDatExtractor cde)
 {
     this.cde         = cde;
     ShipSoftwareNode = shipSoftwareNode;
 }
Example #20
0
 public RelationData(XmlNode relationNode, CatDatExtractor cde)
 {
     RelationNode = relationNode;
     this.cde     = cde;
 }
 public ShipInventoryItemData(XmlNode shipInventoryItemNode, CatDatExtractor cde)
 {
     this.cde = cde;
     ShipInventoryItemNode = shipInventoryItemNode;
 }
 public LicenceData(XmlNode licenseNode, CatDatExtractor cde)
 {
     LicenseNode = licenseNode;
     this.cde    = cde;
 }
Example #23
0
 public BoosterData(XmlNode relationNode, CatDatExtractor cde)
 {
     BoosterNode = relationNode;
     this.cde    = cde;
 }
Example #24
0
 public BoosterData(string faction, float relation, double time, XmlNode parent, CatDatExtractor cde)
 {
     BoosterNode = parent.OwnerDocument.CreateElement("booster");
     BoosterNode.Attributes.Append(parent.OwnerDocument.CreateAttribute("faction"));
     BoosterNode.Attributes["faction"].Value = faction;
     BoosterNode.Attributes.Append(parent.OwnerDocument.CreateAttribute("relation"));
     BoosterNode.Attributes["relation"].Value = XmlConvert.ToString(relation);
     // Max/min value observed in game save
     // 0.15 for a discount booster
     // 0.578817/-1  for a relation booster
     BoosterNode.Attributes.Append(parent.OwnerDocument.CreateAttribute("time"));
     BoosterNode.Attributes["time"].Value = XmlConvert.ToString(time);
     // Usual time in savegame: ~150e3 (not expressed in scientific notation)
     parent.AppendChild(BoosterNode);
 }
 public NPCData(XmlNode npcNode, CatDatExtractor cde)
 {
     NPCNode  = npcNode;
     this.cde = cde;
 }
Example #26
0
 public ShipWeaponData(XmlNode shipWeaponNode, CatDatExtractor cde)
 {
     this.cde       = cde;
     ShipWeaponNode = shipWeaponNode;
 }
Example #27
0
        public ShipData(XmlNode shipNode, CatDatExtractor cde)
        {
            try
            {
                this.cde = cde;
                ShipNode = shipNode;

                XmlNode childNode = null;
                //<shields> ???

                // Storages
                XmlNode storage = null;
                storage = shipNode.SelectSingleNode(".//connection[@connection='connection_storage01']");
                if (storage != null)
                {
                    ShipStorage.Add(1, new ShipStorageData(storage, cde));
                }

                storage = null;
                storage = shipNode.SelectSingleNode(".//connection[@connection='connection_storage02']");
                if (storage != null)
                {
                    ShipStorage.Add(2, new ShipStorageData(storage, cde));
                }

                storage = null;
                storage = shipNode.SelectSingleNode(".//connection[@connection='connection_storage03']");
                if (storage != null)
                {
                    ShipStorage.Add(3, new ShipStorageData(storage, cde));
                }

                storage = null;
                storage = shipNode.SelectSingleNode(".//connection[@connection='connection_storage04']");
                if (storage != null)
                {
                    ShipStorage.Add(4, new ShipStorageData(storage, cde));
                }

                storage = null;
                storage = shipNode.SelectSingleNode(".//connection[@connection='connection_storage05']");
                if (storage != null)
                {
                    ShipStorage.Add(5, new ShipStorageData(storage, cde));
                }


                #region Skunk
                if (IsSkunk()) // Some prats should only be handled for skunk at the moment
                {
                    try
                    {
                        //<weaponcycle>
                        childNode = XMLFunctions.FindChild(ShipNode.FirstChild, "weaponcycle");

                        if (childNode != null)
                        {
                            childNode = childNode.FirstChild;

                            while (childNode != null)
                            {
                                try
                                {
                                    WeaponCycleSlot.Add(new ShipWeaponCycleSlotData(childNode, cde));
                                }
                                catch (Exception ex)
                                {
                                    Logger.Error("Unable to add weaponcycle.", ex);
                                }
                                childNode = childNode.NextSibling;
                            }
                        }
                        else
                        {
                            throw new Exception("weaponcycle child node not found.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Unable to parse weaponcycle.", ex);
                    }

                    try
                    {
                        //<connections>
                        childNode = XMLFunctions.FindChild(ShipNode.FirstChild, "connections");

                        if (childNode != null)
                        {
                            childNode = childNode.FirstChild;

                            while (childNode != null)
                            {
                                try
                                {
                                    if (childNode.Attributes["connection"].Value == "connection_software01" ||
                                        childNode.Attributes["connection"].Value == "connection_software02" ||
                                        childNode.Attributes["connection"].Value == "connection_software03" ||//Just in case
                                        childNode.Attributes["connection"].Value == "connection_software04"   //Just in case
                                        )
                                    {
                                        InstalledSoftware.Add(new ShipSoftwareData(childNode, cde));
                                    }
                                    else if (childNode.Attributes["connection"].Value == "scannerconnection")
                                    {
                                        InstalledScanner = new ShipScannerData(childNode, cde);
                                    }
                                    else if (childNode.Attributes["connection"].Value == "shields" ||
                                             childNode.Attributes["connection"].Value == "shieldgenerators"
                                             )
                                    {// I need it!
                                        InstalledShields.Add(new ShipShieldData(childNode, cde));
                                    }
                                    else if (childNode.Attributes["connection"].Value == "engine_r" ||
                                             childNode.Attributes["connection"].Value == "engine_l"
                                             )
                                    {// I need it!
                                        InstalledEngines.Add(new ShipEngineData(childNode, cde));
                                    }
                                    else if (childNode.Attributes["connection"].Value == "conn_primaryweapon_shotgun" ||
                                             childNode.Attributes["connection"].Value == "conn_primaryweapon_impuls" ||
                                             childNode.Attributes["connection"].Value == "conn_primaryweapon_beam" ||
                                             childNode.Attributes["connection"].Value == "conn_primaryweapon_plasma" ||
                                             childNode.Attributes["connection"].Value == "conn_primaryweapon_mg"
                                             )
                                    {// I need it!
                                        InstalledWeapons.Add(new ShipWeaponData(childNode, cde));
                                    }
                                    else if (childNode.Attributes["connection"].Value == "cockpit")
                                    {// I need it!
                                        ShipCockpit = new ShipCockpitData(childNode, cde);
                                    }
                                    else if (childNode.Attributes["connection"].Value == "connection_radar01")
                                    {// Do I need it?
                                    }
                                    else if (childNode.Attributes["connection"].Value == "connection_dock_s01")
                                    {// Do I need it?
                                    }
                                    else if (childNode.Attributes["connection"].Value == "tagweaponconnection01")
                                    {// Do I need it?
                                    }
                                    else if (childNode.Attributes["connection"].Value == "weaponconnection4")
                                    {// Do I need it?
                                    }
                                    else if (childNode.Attributes["connection"].Value == "weaponconnection3")
                                    {// Do I need it?
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Logger.Error("Unable to add this ship conection", ex);
                                }

                                childNode = childNode.NextSibling;
                            }
                        }
                        else
                        {
                            throw new Exception("connections child node not found.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Unable to parse connections.", ex);
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to parse ship.", ex);
            }
        }
Example #28
0
 public ShipScannerData(XmlNode shipScannerNode, CatDatExtractor cde)
 {
     this.cde        = cde;
     ShipScannerNode = shipScannerNode;
 }
Example #29
0
/*
 *      <connection connection="conn_primaryweapon_impuls">
 * <component class="playerweapon" macro="weapon_player_impulse_mk1_macro" connection="shipconnection" lastshottime="0" ammunition="-1" targetseen="0" id="[0xc68]">
 * <offset>
 * <position x="-3.294" y="-0.1191" z="-2.88" />
 * </offset>
 * <shootcontroller class="playerprimary" shooter="[0xc68]" starttime="118.091" angle="0.0872665" />
 * <connections />
 * </component>
 * </connection>
 */

        public ShipWeaponData(string macro, string connection, XmlNode shipNode, CatDatExtractor cde)
        {
            this.cde = cde;

            ShipWeaponNode = shipNode.OwnerDocument.CreateElement("connection");
            XmlAttribute shipWeaponNodeAtt = shipNode.OwnerDocument.CreateAttribute("connection");

            shipWeaponNodeAtt.Value = connection;
            ShipWeaponNode.Attributes.Append(shipWeaponNodeAtt);
            XmlNode      comp      = shipNode.OwnerDocument.CreateElement("component");
            XmlAttribute compClass = shipNode.OwnerDocument.CreateAttribute("class");

            compClass.Value = "playerweapon";
            comp.Attributes.Append(compClass);
            XmlAttribute compMacro = shipNode.OwnerDocument.CreateAttribute("macro");

            compMacro.Value = macro;
            comp.Attributes.Append(compMacro);
            XmlAttribute compConn = shipNode.OwnerDocument.CreateAttribute("connection");

            if (connection.Contains("beam"))
            {
                compConn.Value = "shipconnection01";
            }
            else
            {
                compConn.Value = "shipconnection";
            }
            comp.Attributes.Append(compConn);
            XmlAttribute compLastShot = shipNode.OwnerDocument.CreateAttribute("lastshottime");

            compLastShot.Value = "0";
            comp.Attributes.Append(compLastShot);
            XmlAttribute compAmm = shipNode.OwnerDocument.CreateAttribute("ammunition");

            compAmm.Value = "-1";
            comp.Attributes.Append(compAmm);
            XmlAttribute compTar = shipNode.OwnerDocument.CreateAttribute("targetseen");

            compTar.Value = "0";
            comp.Attributes.Append(compTar);
            XmlAttribute compId  = shipNode.OwnerDocument.CreateAttribute("id");
            string       shooter = XMLFunctions.DetermineNewId(shipNode.OwnerDocument);

            compId.Value = shooter;
            comp.Attributes.Append(compId);
            comp.AppendChild(shipNode.OwnerDocument.ImportNode(cde.GetPlayerConnectionOffset(connection), true));
            XmlNode      shoot      = shipNode.OwnerDocument.CreateElement("shootcontroller");
            XmlAttribute shootClass = shipNode.OwnerDocument.CreateAttribute("class");

            shootClass.Value = "playerprimary";
            shoot.Attributes.Append(shootClass);
            XmlAttribute shootShoot = shipNode.OwnerDocument.CreateAttribute("shooter");

            shootShoot.Value = shooter;
            shoot.Attributes.Append(shootShoot);
            XmlAttribute shootST = shipNode.OwnerDocument.CreateAttribute("starttime");

            shootST.Value = "1";
            shoot.Attributes.Append(shootST);
            XmlAttribute shootAngle = shipNode.OwnerDocument.CreateAttribute("angle");

            shootAngle.Value = "0.0872665";
            shoot.Attributes.Append(shootAngle);
            comp.AppendChild(shoot);
            XmlNode connections = shipNode.OwnerDocument.CreateElement("connections");

            comp.AppendChild(connections);
            ShipWeaponNode.AppendChild(comp);
            XMLFunctions.FindChild(shipNode.FirstChild, "connections").InsertAfter(ShipWeaponNode, XMLFunctions.FindChild(shipNode.FirstChild, "connections").SelectSingleNode("connection[@connection='primaryship']"));
        }
Example #30
0
        public PlayerData(XmlNode playerNode, CatDatExtractor cde)
        {
            PlayerNode = playerNode;
            XmlNode childNode = null;

            this.cde = cde;

            try
            {
                childNode = XMLFunctions.FindChild(PlayerNode.FirstChild, "inventory").FirstChild;

                while (childNode != null)
                {
                    try
                    {
                        PlayerInventory.Add(new ShipInventoryItemData(childNode, cde));
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Unable to add player inventory item.", ex);
                    }
                    childNode = childNode.NextSibling;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Unable to parse inventory", ex);
            }

            try
            {
                childNode = XMLFunctions.FindChild(PlayerNode.FirstChild, "known").FirstChild;

                while (childNode != null)
                {
                    try
                    {
                        List <string> ids          = new List <string>();
                        XmlNode       childSubNode = childNode.FirstChild;
                        XmlAttribute  att          = childNode.Attributes["type"];
                        if (att == null)
                        {
                            Logger.Warning("The entry in the known list does not have a type.");
                        }
                        else
                        {
                            while (childSubNode != null)
                            {
                                try
                                {
                                    ids.Add(childSubNode.Attributes["id"].Value);
                                }
                                catch (Exception ex)
                                {
                                    Logger.Error("Unable to create known list item", ex);
                                }
                                childSubNode = childSubNode.NextSibling;
                            }
                            PlayerKnown.Add(childNode.Attributes["type"].Value, ids);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Unable to create known list", ex);
                    }
                    childNode = childNode.NextSibling;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to parse known. This is a fatal error.", ex);
            }
        }