コード例 #1
0
 public bool RemovePerk(Type type)
 {
     if (type == typeof(PerkBase) || type == typeof(ConditionalPerk) || type.IsSubclassOf(typeof(ConditionalPerk)))
     {
         return(false);
     }
     if (perks.ContainsKey(type))
     {
         PerkBase removed = perks[type];
         removed.Deactivate();
         return(perks.Remove(type));
     }
     return(false);
 }
コード例 #2
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);
        }
コード例 #3
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);
            }
        }
コード例 #4
0
 bool IRemovableModifier.RemoveModifier(PerkBase perk) => RemoveModifier(perk);
コード例 #5
0
 protected internal abstract bool HasModifier(PerkBase perk);
コード例 #6
0
 protected internal abstract bool RemoveModifier(PerkBase perk);
コード例 #7
0
        //these are internal. we expose these indirectly through PerkBase. this way, we can guarentee the perk modifiers are always up to date, and you don't
        //have to manually add and remove them all the time - simply tell the perk to do it, and it'll automatically add and remove when activated or deactivated, respectively.

        protected internal abstract bool AddModifier(PerkBase perk, T valueModifier, bool overwriteExisting = false);
コード例 #8
0
 protected internal override bool HasModifier(PerkBase perk)
 {
     return(valueModifiers.ContainsKey(perk.GetType()));
 }