Effects
See also: Effect settings, Ability effects
Effects are what you abilities do when they are executed. You are encouraged to create your own effects that suit your specific game, and free to implement them as you wish. If you want to see some examples of custom effects, refer to Examples.
When an ability is cast (or when a projectile hits) the framework will resolve the target(s) of the ability and apply effects. The built in effects are applied by checking for an specific component-interface (f.eg. IDamageable
) on the target and telling that component-implementation to execute it's behaviour.
All effects derive from the base class AbilityEffectSO
. Every class in your project that derives from this base can be applied as an effect to an ability, and will show up in the effects tab.
To apply effects you either have to add the pre-supplied Ability target-component to a GameObject or implement the IAbilityTarget
-interface in one of your own MonoBehaviours
.
You can see all effects in the project by going to Tools->SPAM Framework->Effects.
All interfaces that pre-supplied effects utilize can be found in AbilitySystem/ExternalSystems.
The pre-supplied "Deal Damage" effect looks like this (editor-only parts stripped out for brevity):
public class DamageEffectSO : AbilityEffectSO
{
// Effect specific data. Here you put all the values that can vary between different instances of the same effect
[SerializeField] private int _damageValue;
// This shows up in the editor window when creating an effect
protected override string _metaHelpDescription =>
$"Deals damage to the target. Requires the target to have an IDamageable-component.";
// This is the implementation for actually applying the effect to a target
public override void ApplyTo(IAbilityTarget target,
Vector3 abilityPos,
IAbilityData ability,
AbilityInvoker invoker)
{
var damageable = target.Transform.GetComponent<IDamageable>();
if (damageable == null) return;
damageable.Damage(_damageValue);
}
}