internal static ShipPartsDataBase.ShipPart FromXml(XmlNode n)
            {
                if (n == null)
                {
                    return((ShipPartsDataBase.ShipPart)null);
                }
                if (n.ChildNodes == null)
                {
                    return((ShipPartsDataBase.ShipPart)null);
                }
                if (n.Name != "ship_part")
                {
                    return((ShipPartsDataBase.ShipPart)null);
                }
                if (n.Attributes["name"] == null)
                {
                    return((ShipPartsDataBase.ShipPart)null);
                }
                ShipPartsDataBase.ShipPart shipPart = new ShipPartsDataBase.ShipPart();
                shipPart.m_name               = Useful.XmlGetAttribute(n, "name", shipPart.m_name);
                shipPart.m_type               = ShipPartsDataBase.ToPartsType(Useful.XmlGetAttribute(n, "PartsType", ShipPartsDataBase.ToString(shipPart.m_type)));
                shipPart.m_ship_size_type     = ShipPartsDataBase.ToShipSizeType(Useful.XmlGetAttribute(n, "ShipSizeType", ShipPartsDataBase.ToString(shipPart.m_ship_size_type)));
                shipPart.m_is_general_purpose = Useful.ToBool(Useful.XmlGetAttribute(n, "IsGeneralPurpose", shipPart.m_is_general_purpose.ToString()), shipPart.m_is_general_purpose);
                for (int index = 0; index < Enum.GetValues(typeof(ShipPartsDataBase.BuildTargetType)).Length; ++index)
                {
                    XmlNode element = Useful.XmlGetElement(n, "data_values", ShipPartsDataBase.ToString(ShipPartsDataBase.ToBuildTargetType(index)));
                    if (element != null)
                    {
                        int min = Useful.ToInt32(Useful.XmlGetAttribute(element, "Min", shipPart.m_value_tbl[index].Min.ToString()), shipPart.m_value_tbl[index].Min);
                        int max = Useful.ToInt32(Useful.XmlGetAttribute(element, "Max", shipPart.m_value_tbl[index].Max.ToString()), shipPart.m_value_tbl[index].Max);
                        shipPart.m_value_tbl[index].SetData(min, max, max - (max - min) / 2);
                    }
                }
                XmlNode node = (XmlNode)n["detail"];

                if (node != null)
                {
                    shipPart.Skill     = Useful.XmlGetAttribute(node, "Skill", shipPart.Skill);
                    shipPart.Citys     = Useful.XmlGetAttribute(node, "Citys", shipPart.Citys);
                    shipPart.NPC       = Useful.XmlGetAttribute(node, "NPC", shipPart.NPC);
                    shipPart.Materials = Useful.XmlGetAttribute(node, "Materials", shipPart.Materials);
                    shipPart.ShipType  = Useful.XmlGetAttribute(node, "ShipType", shipPart.ShipType);
                    shipPart.Price     = Useful.XmlGetAttribute(node, "Price", shipPart.Price);
                }
                shipPart.optimize();
                return(shipPart);
            }
 public static ShipPartsDataBase.PartsType ToPartsType(int index)
 {
     return(ShipPartsDataBase.ToPartsType(index.ToString()));
 }