Ability Component

AbilityComponent is the intermediary between owner (player or AI) and Ability (spell).
Ability can be any kind of spell such as Fireball, Buff, Healing, Spawning Minions etc.

Ability Component observes state of the owner and ability such as - if ability is casting, if input is pressed, recently used ability anim montage, ability transform etc.
Based on state of ability it triggers events that owner can react to.

Player doesnt call any functions directly on Ability, instead he does it through AbilityComponent.
For example when player is pressing or releasing Ability input, it doesn't call directly events from Ability blueprint
instead it calls functions from AbilityComponent, which in turn informs about it Ability itself.

There are various functions on AbilityComponent that owner can use to either get info about current Ability or to modify it.

Ability Component can have only 1 active ability at a time that will be observed and managed.
So all functions getting info about Ability, such as GetAbilityCost, IsAbilityUsingCrosshair, GetEffectTransform etc. are always related to this single active ability.

Function FinishAbility takes parameter of type E_AbilityEndResult to determine the reason why Ability ends.

  • Finished - ability has succesfully ended casting
  • Interrupted - ability was interrupted e.g when owner gets stunned
  • Canceled - ability was canceled by owner, for example by pressing input stop casting
  • OutOfMana - there was not enough mana to keep casting ability
  • Destroyed - ability has been destroyed, for example when changed to new one

To simplify communication between AbilityComponent and Owner
Owner must implement interface I_AbilityComponent along with its functions

This is how it is implemented on Player Blueprint