/// <summary>
        /// Takes the original, unboosted attributes, all the accumulated boosts aside from the primary-secondary
        /// interactions, and compiles them in-place. Will apply all the boosts and primary-secondary
        /// effects to produce final values for all the attributes.
        /// </summary>
        public void ApplyEnhancementsAndBuild(IndexedAttributes attributes, Dictionary <Attribute, StatBooster> boosters)
        {
            var primaryAttributes = boosters.Keys.Where(att => !secondaryAttributes.Contains(att));

            BuildAttributes(primaryAttributes, attributes, boosters);
            ApplyAndBuild(attributes, boosters);
        }
 void BuildAttributes(IEnumerable <Attribute> keys, IndexedAttributes attributes,
                      Dictionary <Attribute, StatBooster> boosters)
 {
     foreach (Attribute key in keys)
     {
         BuildAttribute(key, attributes, boosters);
     }
 }
        void Awake()
        {
            finalAttributes = new IndexedAttributes();
            equipContext    = new PlayerEquipContext();
            boostApplyer    = new AttributeBoostApplyer();

            // We're using a normal dictionary, so it won't autopopulate with all the values of Attribute, so we copy
            // the keys from baseAttributes, and take the opportunity to initialize the stat boosters.
            statBoosters = new Dictionary <Attribute, StatBooster>();
            foreach (Attribute key in AllKeys)
            {
                statBoosters.Add(key, new StatBooster());
            }

            InventoryChangedEventHandler(Enumerable.Empty <Item>());
        }
        void ApplyAndBuild(IndexedAttributes attributes, Dictionary <Attribute, StatBooster> boosters)
        {
            foreach (Attribute attribute in primaryAttributes) // must occur before the health boost
            {
                ApplyAdditiveBoost(boosters[attribute], attributes[Attribute.AllAttributes]);
                BuildAttribute(attribute, attributes, boosters);
            }

            foreach (Attribute attribute in resistances)
            {
                ApplyAdditiveBoost(boosters[attribute], attributes[Attribute.AllResistance]);
                BuildAttribute(attribute, attributes, boosters);
            }

            ApplyHealthBoost(boosters[Attribute.Health], attributes[Attribute.Vitality], attributes[Attribute.HealthPerVitality]);
            BuildAttribute(Attribute.Health, attributes, boosters);
        }
 void BuildAttribute(Attribute attribute, IndexedAttributes attributes, Dictionary <Attribute, StatBooster> boosters)
 {
     attributes[attribute] = boosters[attribute].Boost(attributes[attribute]);
 }