Example #1
0
        private protected override bool AddActiveModifier <T>(PerkModifierBase <T> modifier, T value, bool overwriteExisting = false)
        {
            if (modifier.AddModifier(this, value, overwriteExisting))
            {
                currentlyActiveModifiers.Add(modifier);
                return(true);
            }

            return(false);
        }
Example #2
0
        private protected override bool HasActiveModifier <T>(PerkModifierBase <T> modifier)
        {
            bool retVal = modifier.HasModifier(this);

            if (!retVal && currentlyActiveModifiers.Contains(modifier))
            {
                currentlyActiveModifiers.Remove(modifier);
            }
            else if (retVal && !currentlyActiveModifiers.Contains(modifier))
            {
                currentlyActiveModifiers.Add(modifier);
            }

            return(retVal);
        }
Example #3
0
 private protected abstract bool HasActiveModifier <T>(PerkModifierBase <T> modifier);
Example #4
0
 private protected abstract bool AddActiveModifier <T>(PerkModifierBase <T> modifier, T value, bool overwriteExisting = false);
Example #5
0
 protected bool HasModifier <T>(PerkModifierBase <T> modifier)
 {
     return(HasActiveModifier <T>(modifier));
 }
Example #6
0
 protected bool RemoveModifierFromPerk <T>(PerkModifierBase <T> modifier)
 {
     return(RemoveActiveModifier <T>(modifier));
 }
Example #7
0
 protected bool UpdatePerkModifier <T>(PerkModifierBase <T> modifier, T value)
 {
     return(AddActiveModifier(modifier, value, true));
 }
Example #8
0
        //for most perks that adust a modifier, you can simply say: when this is active, apply this modifier. when it's not, remove it.
        //To make this more convenient, we've provided a means to do this automatically. You can also manually remove one of these if a perk dynamically
        //changes, or update them to new values if your perk does that, too, or check if it exists if needed.
        //To use these: put them in your code responsible for activating the perk.



        //Like all variables, be aware that any changes to these will only exist for the lifetime of the perk, and that different types of perks have different lifespans
        //for example, conditional perks have a lifespan as long as their parent creature - they are simply inactive when the creature doesn't mean the conditions for that
        //perk. Standard perks and timed perks (aka status effects), meanwhile, only live as long as the creature has them - they are destroyed when the creature loses that
        //perk.
        //Thus, for any standard/timed perks, if you want an adjusted value on all subsequent times that perk is obtained, you'll need to store that data somewhere it will
        //persist, (likely the extended creature data section) then reload it during construction. Meanwhile, if you only want a temporary effect on a conditional perk,
        //handle this whenever you handle the enable and disable related checks.

        protected bool AddModifierToPerk <T>(PerkModifierBase <T> modifier, T value, bool overwriteExisting = false)
        {
            return(AddActiveModifier(modifier, value, overwriteExisting));
        }
Example #9
0
 private protected override bool RemoveActiveModifier <T>(PerkModifierBase <T> modifier)
 {
     currentlyActiveModifiers.Remove(modifier);
     return(modifier.RemoveModifier(this));
 }