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 override void Equip(Character character)
        {
            if (character == null)
            {
                return;
            }
            IsActive = true;

            if (targetCharacter != null)
            {
                return;
            }

            if (tainted)
            {
                if (selectedTaintedEffect != null)
                {
                    float selectedTaintedEffectStrength = item.ConditionPercentage / 100.0f * selectedTaintedEffect.MaxStrength;
                    character.CharacterHealth.ApplyAffliction(null, selectedTaintedEffect.Instantiate(selectedTaintedEffectStrength));
                    var existingAffliction = character.CharacterHealth.GetAllAfflictions().FirstOrDefault(a => a.Prefab == selectedTaintedEffect);
                    if (existingAffliction != null)
                    {
                        existingAffliction.Strength = selectedTaintedEffectStrength;
                    }
                    targetCharacter = character;
#if SERVER
                    item.CreateServerEvent(this);
#endif
                }
            }
            if (selectedEffect != null)
            {
                ApplyStatusEffects(ActionType.OnWearing, 1.0f);
                float selectedEffectStrength = item.ConditionPercentage / 100.0f * selectedEffect.MaxStrength;
                character.CharacterHealth.ApplyAffliction(null, selectedEffect.Instantiate(selectedEffectStrength));
                var existingAffliction = character.CharacterHealth.GetAllAfflictions().FirstOrDefault(a => a.Prefab == selectedEffect);
                if (existingAffliction != null)
                {
                    existingAffliction.Strength = selectedEffectStrength;
                }
                targetCharacter = character;
#if SERVER
                item.CreateServerEvent(this);
#endif
            }
            foreach (Item containedItem in item.ContainedItems)
            {
                containedItem.GetComponent <GeneticMaterial>()?.Equip(character);
            }
        }