Esempio n. 1
0
        public PreferredContainer(XElement element)
        {
            Primary          = XMLExtensions.GetAttributeStringArray(element, "primary", new string[0]).ToHashSet();
            Secondary        = XMLExtensions.GetAttributeStringArray(element, "secondary", new string[0]).ToHashSet();
            SpawnProbability = element.GetAttributeFloat("spawnprobability", 0.0f);
            MinAmount        = element.GetAttributeInt("minamount", 0);
            MaxAmount        = Math.Max(MinAmount, element.GetAttributeInt("maxamount", 0));
            MaxCondition     = element.GetAttributeFloat("maxcondition", 100f);
            MinCondition     = element.GetAttributeFloat("mincondition", 0f);

            if (element.Attribute("spawnprobability") == null)
            {
                //if spawn probability is not defined but amount is, assume the probability is 1
                if (MaxAmount > 0)
                {
                    SpawnProbability = 1.0f;
                }
            }
            else if (element.Attribute("minamount") == null && element.Attribute("maxamount") == null)
            {
                //spawn probability defined but amount isn't, assume amount is 1
                MinAmount        = MaxAmount = 1;
                SpawnProbability = element.GetAttributeFloat("spawnprobability", 0.0f);
            }
        }
 public WreckAIConfig(XElement element)
 {
     SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
     ForbiddenAmmunition    = XMLExtensions.GetAttributeStringArray(element, "ForbiddenAmmunition", new string[0], convertToLowerInvariant: true);
 }