Example #1
0
        /// <summary>
        /// Apply an attribute affix to the item. The item will consume the affix directly if it can (e.g. weapons may
        /// consume MinDamage directly by adding it to their minimum damage), in which case the affix will not be applied
        /// to the player.
        /// </summary>
        public void AddAffix(AffixDefinition affix, QualityRoll quality)
        {
            if (!isBuilding)
            {
                throw new InvalidOperationException("Must start building before adding affixes.");
            }

            if (affix == null)
            {
                throw new ArgumentNullException("affix");
            }

            // Double-dispatch could be used to avoid the type-sniffing, but this is a lot simpler
            AttributeAffix attributeAffix = affix as AttributeAffix;
            bool           applyToItem    = (attributeAffix != null) && IsApplicableToItem(attributeAffix);

            if (applyToItem)
            {
                ApplyToItem(attributeAffix, quality);
            }
            tempAffixes.Add(new Affix(affix, quality, applyToItem));
        }
Example #2
0
 /// <param name="appliedToItem">Affix was applied directly to an item, so it will do nothing when equipped.</param>
 public Affix(AffixDefinition definition, QualityRoll quality, bool appliedToItem = false)
 {
     affix              = definition;
     this.quality       = quality;
     this.appliedToItem = appliedToItem;
 }