public static List <Affliction> ParseAfflictions(CharacterTalent characterTalent, XElement afflictionElements)
        {
            if (afflictionElements == null)
            {
                DebugConsole.ThrowError("Affliction list was not found in talent " + characterTalent.DebugIdentifier);
                return(null);
            }

            List <Affliction> afflictions = new List <Affliction>();

            // similar logic to affliction creation in statuseffects
            // might be worth unifying

            foreach (XElement afflictionElement in afflictionElements.Elements())
            {
                string           afflictionIdentifier = afflictionElement.GetAttributeString("identifier", "").ToLowerInvariant();
                AfflictionPrefab afflictionPrefab     = AfflictionPrefab.List.FirstOrDefault(ap => ap.Identifier.ToLowerInvariant() == afflictionIdentifier);
                if (afflictionPrefab == null)
                {
                    DebugConsole.ThrowError("Error in CharacterTalent (" + characterTalent.DebugIdentifier + ") - Affliction prefab with the identifier \"" + afflictionIdentifier + "\" not found.");
                    continue;
                }

                Affliction afflictionInstance = afflictionPrefab.Instantiate(afflictionElement.GetAttributeFloat(1.0f, "amount", "strength"));
                afflictionInstance.Probability = afflictionElement.GetAttributeFloat(1.0f, "probability");
                afflictions.Add(afflictionInstance);
            }

            return(afflictions);
        }
예제 #2
0
        public GeneticMaterial(Item item, XElement element)
            : base(item, element)
        {
            string nameId = element.GetAttributeString("nameidentifier", "");

            if (!string.IsNullOrEmpty(nameId))
            {
                materialName = TextManager.Get(nameId);
            }
            if (!string.IsNullOrEmpty(Effect))
            {
                selectedEffect = AfflictionPrefab.Prefabs.Where(a =>
                                                                a.Identifier.Equals(Effect, StringComparison.OrdinalIgnoreCase) ||
                                                                a.AfflictionType.Equals(Effect, StringComparison.OrdinalIgnoreCase)).GetRandom();
            }
        }
 public AfflictionPsychosis(AfflictionPrefab prefab, float strength) : base(prefab, strength)
 {
 }