Пример #1
0
        protected internal override bool RemoveModifier(PerkBase perk)
        {
            Type type = perk.GetType();
            T    oldT = GetValue();

            if (valueModifiers.Remove(type))
            {
                if (CheckChanged(oldT))
                {
                    onChange?.Invoke(oldT);
                }
                return(true);
            }

            return(false);
        }
Пример #2
0
        protected internal override bool AddModifier(PerkBase perk, ValueModifierStore <T> valueModifier, bool overwriteExisting = false)
        {
            Type type = perk.GetType();

            if (valueModifiers.ContainsKey(type) && !overwriteExisting)
            {
                return(false);
            }
            else
            {
                T oldT = GetValue();
                valueModifiers[type] = valueModifier;
                if (CheckChanged(oldT))
                {
                    onChange?.Invoke(oldT);
                }
                return(true);
            }
        }
Пример #3
0
 protected internal override bool HasModifier(PerkBase perk)
 {
     return(valueModifiers.ContainsKey(perk.GetType()));
 }