Ejemplo n.º 1
0
 public static bool FromString(string keyValue, out BodyProperties bodyProperties)
 {
     if (keyValue.StartsWith("<BodyProperties ", StringComparison.InvariantCultureIgnoreCase) || keyValue.StartsWith("<BodyPropertiesMax ", StringComparison.InvariantCultureIgnoreCase))
     {
         XmlDocument xmlDocument = new XmlDocument();
         try
         {
             xmlDocument.LoadXml(keyValue);
         }
         catch (XmlException ex)
         {
             bodyProperties = new BodyProperties();
             return(false);
         }
         if (xmlDocument.FirstChild.Name.Equals(nameof(BodyProperties), StringComparison.InvariantCultureIgnoreCase) || xmlDocument.FirstChild.Name.Equals("BodyPropertiesMax", StringComparison.InvariantCultureIgnoreCase))
         {
             BodyProperties.FromXmlNode(xmlDocument.FirstChild, out bodyProperties);
             float result1 = 20f;
             float result2 = 0.0f;
             float result3 = 0.0f;
             if (xmlDocument.FirstChild.Attributes["age"] != null)
             {
                 float.TryParse(xmlDocument.FirstChild.Attributes["age"].Value, out result1);
             }
             if (xmlDocument.FirstChild.Attributes["weight"] != null)
             {
                 float.TryParse(xmlDocument.FirstChild.Attributes["weight"].Value, out result2);
             }
             if (xmlDocument.FirstChild.Attributes["build"] != null)
             {
                 float.TryParse(xmlDocument.FirstChild.Attributes["build"].Value, out result3);
             }
             bodyProperties = new BodyProperties(new DynamicBodyProperties(result1, result2, result3), bodyProperties.StaticProperties);
             return(true);
         }
         bodyProperties = new BodyProperties();
         return(false);
     }
     bodyProperties = new BodyProperties();
     return(false);
 }
 public override void Deserialize(MBObjectManager objectManager, XmlNode node)
 {
     base.Deserialize(objectManager, node);
     foreach (XmlNode childNode in node.ChildNodes)
     {
         if (childNode.Name == "BodyPropertiesMin")
         {
             BodyProperties.FromXmlNode(childNode, out this._bodyPropertyMin);
         }
         else if (childNode.Name == "BodyPropertiesMax")
         {
             BodyProperties.FromXmlNode(childNode, out this._bodyPropertyMax);
         }
     }
     if ((double)this._bodyPropertyMax.Age <= 0.0)
     {
         this._bodyPropertyMax = this._bodyPropertyMin;
     }
     if ((double)this._bodyPropertyMin.Age > 0.0)
     {
         return;
     }
     this._bodyPropertyMin = this._bodyPropertyMax;
 }