private AttributeValue?GetCapturedAttribute(GameplayEffectSpec spec)
        {
            if (CaptureAttributeWhen == ECaptureAttributeWhen.OnApplication && CaptureAttributeFrom == ECaptureAttributeFrom.Source)
            {
                return(spec.SourceCapturedAttribute);
            }

            switch (CaptureAttributeFrom)
            {
            case ECaptureAttributeFrom.Source:
                spec.Source.AttributeSystem.GetAttributeValue(CaptureAttributeWhich, out var sourceAttributeValue);
                return(sourceAttributeValue);

            case ECaptureAttributeFrom.Target:
                spec.Target.AttributeSystem.GetAttributeValue(CaptureAttributeWhich, out var targetAttributeValue);
                return(targetAttributeValue);

            default:
                return(null);
            }
        }
 /// <summary>
 /// Function called when the magnitude is calculated, usually after the target has been assigned
 /// </summary>
 /// <param name="spec">Gameplay Effect Spec</param>
 /// <returns></returns>
 public abstract float?CalculateMagnitude(GameplayEffectSpec spec);
 /// <summary>
 /// Function called when the spec is first initialised (e.g. by the Instigator/Source Ability System)
 /// </summary>
 /// <param name="spec">Gameplay Effect Spec</param>
 public abstract void Initialise(GameplayEffectSpec spec);
 public override float?CalculateMagnitude(GameplayEffectSpec spec)
 {
     return(ScalingFunction.Evaluate(GetCapturedAttribute(spec).GetValueOrDefault().CurrentValue));
 }
 public override void Initialise(GameplayEffectSpec spec)
 {
     spec.Source.AttributeSystem.GetAttributeValue(CaptureAttributeWhich, out var sourceAttributeValue);
     spec.SourceCapturedAttribute = sourceAttributeValue;
 }