Is there any particular reason for which Sam didn’t refactor the FilterStrategy too?
I can see an obvious advantage of passing AbilityData to FilterStrategy’s Filter method: be able to identify the caster of this ability, and thus, get any ability more flexible. For instance: abilities could also be used by enemies.
namespace RPG.Abilities
{
public abstract class FilterStrategy : ScriptableObject
{
public abstract IEnumerable<GameObject> Filter(AbilityData abilityData);
}
}
And then you can do something like:
namespace RPG.Abilities.Targeting
{
[CreateAssetMenu(menuName = ("RPG/Abilities/Filter/Filter Opponent By Tag"))]
public class FilterOponnentByTagStrategy : FilterStrategy
{
[SerializeField] string player;
[SerializeField] string enemy;
public override IEnumerable<GameObject> Filter(AbilityData abilityData)
{
string tagToCheck = abilityData.User.CompareTag(player) ? enemy : player;
foreach (GameObject objectToFilter in abilityData.Targets)
{
if (objectToFilter.CompareTag(tagToCheck))
yield return objectToFilter;
}
}
}
}
And finally use this filter strategy on any ability. If this ability is casted by an enemy, it will affect only the player and vice-versa.
Obviously, you could go also with a FilterAllyByTagStrategy
and, by tweaking a little bit the code above, be able to have a healing group effect for both players and enemies…