Пример #1
0
        /// <summary>
        /// Create a weapon mount using names instead of IDs, because user readability is important and untrustworthy.
        /// </summary>
        /// <param name="xmlNode"></param>
        public void CreateByName(XmlNode xmlNode)
        {
            XmlDocument xmlDoc      = XmlManager.Load("vehicles.xml");
            WeaponMount objMount    = this;
            XmlNode     xmlDataNode = xmlDoc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{xmlNode["size"]?.InnerText}\" and category = \"Size\"]");

            if (xmlDataNode != null)
            {
                objMount.Create(xmlDataNode);

                xmlDataNode = xmlDoc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{xmlNode["flexibility"]?.InnerText}\" and category = \"Flexibility\"]");
                if (xmlDataNode != null)
                {
                    WeaponMountOption objWeaponMountOption = new WeaponMountOption(_objCharacter);
                    objWeaponMountOption.Create(xmlDataNode);
                    objMount.WeaponMountOptions.Add(objWeaponMountOption);
                }

                xmlDataNode = xmlDoc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{xmlNode["control"]?.InnerText}\" and category = \"Control\"]");
                if (xmlDataNode != null)
                {
                    WeaponMountOption objWeaponMountOption = new WeaponMountOption(_objCharacter);
                    objWeaponMountOption.Create(xmlDataNode);
                    objMount.WeaponMountOptions.Add(objWeaponMountOption);
                }

                xmlDataNode = xmlDoc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{xmlNode["visibility"]?.InnerText}\" and category = \"Visibility\"]");
                if (xmlDataNode != null)
                {
                    WeaponMountOption objWeaponMountOption = new WeaponMountOption(_objCharacter);
                    objWeaponMountOption.Create(xmlDataNode);
                    objMount.WeaponMountOptions.Add(objWeaponMountOption);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Create a weapon mount using names instead of IDs, because user readability is important and untrustworthy.
        /// </summary>
        /// <param name="xmlNode"></param>
        public void CreateByName(XmlNode xmlNode)
        {
            XmlDocument xmlDoc      = XmlManager.Load("vehicles.xml");
            WeaponMount objMount    = this;
            XmlNode     xmlDataNode = xmlDoc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{xmlNode["size"]?.InnerText}\" and category = \"Size\"]");

            if (xmlDataNode != null)
            {
                objMount.Create(xmlDataNode);

                xmlDataNode = xmlDoc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{xmlNode["flexibility"]?.InnerText}\" and category = \"Flexibility\"]");
                if (xmlDataNode != null)
                {
                    WeaponMountOption objWeaponMountOption = new WeaponMountOption(_objCharacter);
                    objWeaponMountOption.Create(xmlDataNode);
                    objMount.WeaponMountOptions.Add(objWeaponMountOption);
                }

                xmlDataNode = xmlDoc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{xmlNode["control"]?.InnerText}\" and category = \"Control\"]");
                if (xmlDataNode != null)
                {
                    WeaponMountOption objWeaponMountOption = new WeaponMountOption(_objCharacter);
                    objWeaponMountOption.Create(xmlDataNode);
                    objMount.WeaponMountOptions.Add(objWeaponMountOption);
                }

                xmlDataNode = xmlDoc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{xmlNode["visibility"]?.InnerText}\" and category = \"Visibility\"]");
                if (xmlDataNode != null)
                {
                    WeaponMountOption objWeaponMountOption = new WeaponMountOption(_objCharacter);
                    objWeaponMountOption.Create(xmlDataNode);
                    objMount.WeaponMountOptions.Add(objWeaponMountOption);
                }
                _strLocation       = xmlNode["location"]?.InnerText ?? string.Empty;
                _strAllowedWeapons = xmlNode["allowedweapons"]?.InnerText ?? string.Empty;
                xmlDataNode        = xmlNode["mods"];
                if (xmlDataNode == null)
                {
                    return;
                }
                using (XmlNodeList xmlModList = xmlDataNode.SelectNodes("mod"))
                    if (xmlModList != null)
                    {
                        foreach (XmlNode xmlModNode in xmlModList)
                        {
                            VehicleMod objMod = new VehicleMod(_objCharacter)
                            {
                                Parent            = Parent,
                                WeaponMountParent = this
                            };
                            objMod.Load(xmlModNode);
                            _lstMods.Add(objMod);
                        }
                    }
            }
        }
Пример #3
0
        /// <summary>
        /// Create a weapon mount using names instead of IDs, because user readability is important and untrustworthy.
        /// </summary>
        /// <param name="n"></param>
        internal void CreateByName(XmlNode n, TreeNode t)
        {
            XmlDocument doc   = XmlManager.Load("vehicles.xml");
            TreeNode    tree  = new TreeNode();
            WeaponMount mount = this;
            XmlNode     node  = doc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{n["size"].InnerText}\" and category = \"Size\"]");

            mount.Create(node, tree, _vehicle);
            WeaponMountOption option = new WeaponMountOption(_character);

            node = doc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{n["flexibility"].InnerText}\" and category = \"Flexibility\"]");
            option.Create(node["id"].InnerText, mount.WeaponMountOptions);
            option = new WeaponMountOption(_character);
            node   = doc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{n["control"].InnerText}\" and category = \"Control\"]");
            option.Create(node["id"].InnerText, mount.WeaponMountOptions);
            option = new WeaponMountOption(_character);
            node   = doc.SelectSingleNode($"/chummer/weaponmounts/weaponmount[name = \"{n["visibility"].InnerText}\" and category = \"Visibility\"]");
            option.Create(node["id"].InnerText, mount.WeaponMountOptions);
            t.Text = DisplayName;
            t.Tag  = _guiID.ToString();
        }