Exemplo n.º 1
0
        public static void AddStatModifier(AbstractStatModifier modifier)
        {
            foreach (var itemIndex in modifier.AffectedItems.Keys)
            {
                var itemStatDef = ItemStatProvider.GetItemStatDef(itemIndex);
                if (itemStatDef == null)
                {
                    throw new KeyNotFoundException($"Affected ItemStatDef with ItemIndex ${itemIndex} not found");
                }

                if (ModifierDefs.TryGetValue(itemStatDef, out var existingEntry))
                {
                    if (!existingEntry.Contains(modifier))
                    {
                        existingEntry.Add(modifier);
                    }
                }
                else
                {
                    ModifierDefs[itemStatDef] = new List <IStatModifier> {
                        modifier
                    };
                }
            }
        }
Exemplo n.º 2
0
        public static List <IStatModifier> GetModifiersForItemIndex(ItemIndex itemIndex)
        {
            var itemStatDef = ItemStatProvider.GetItemStatDef(itemIndex);

            if (itemStatDef == null)
            {
                throw new KeyNotFoundException($"ItemStatDef with ItemIndex ${itemIndex} not found");
            }

            return(GetModifiersForItemDef(itemStatDef));
        }