MGameplayAbility
- Module
- Game
- Header
#include "Gameplay/MGameplayAbility.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
FGameplayTag | abilityTag | Identity + gating. Set in the subclass constructor or by the granting code. |
std::vector<FGameplayTag> | activationRequiredTags | owner must have ALL |
std::vector<FGameplayTag> | activationBlockedTags | owner must have NONE |
GameplayEffectSpec | cost | Cost = an instant effect applied on commit (empty = free). Cooldown = a duration effect granting cooldownTag for cooldownDuration seconds. |
FGameplayTag | cooldownTag | |
float | cooldownDuration | Default 0.0f. |
std::vector<FGameplayTag> | activationCues | Cues fired when the ability activates (OnActive) and ends (Removed). |
std::vector<FGameplayTag> | cancelAbilitiesWithTag | UE's CancelAbilitiesWithTag / BlockAbilitiesWithTag / ActivationOwnedTags: on activation, end running abilities matching the first; while active, refuse abilities matching the second and give the owner the third. |
std::vector<FGameplayTag> | blockAbilitiesWithTag | |
std::vector<FGameplayTag> | activationOwnedTags | |
std::vector<FGameplayTag> | triggerEventTags | Activates the ability when a gameplay event with a matching tag is sent to the owner (UE's ability triggers). The event is in GetTriggerEventData() during ActivateAbility. |
Constructors
| Signature | Name | Description |
|---|---|---|
MGameplayAbility() = default | MGameplayAbility | |
virtual ~MGameplayAbility() = default | ~MGameplayAbility | |
MGameplayAbility(const MGameplayAbility&) = delete | MGameplayAbility | Move-only: owns latent tasks (unique_ptr) and is held by unique_ptr in the ASC. |
Public functions
| Returns | Name | Description |
|---|---|---|
MGameplayAbility& | operator= | |
const FGameplayEventData& | GetTriggerEventData | |
bool | CanActivate | Can the ability start right now? Checks required/blocked tags, the cooldown tag, and cost affordability. |
void | ActivateAbility | The ability's logic. |
void | EndAbility | Tear down: cancels remaining tasks, clears the active flag, fires the Removed cues. |
void | CommitCost | Pay the cost (instant effect) and start the cooldown (duration effect). |
void | CommitCooldown | |
bool | CommitAbility | |
bool | IsActive | |
void | RequestEndAbility | A task (or the ability itself) asks to end. |
bool | ConsumePendingEnd | |
void | TickAbility | Driven by the ASC each frame while active — ticks tasks, then prunes finished ones. |
void | HandleGameplayEvent | Driven by the ASC when a gameplay event is sent while this ability is active — fans the event out to every live task. |
Function details
MGameplayAbility
MGameplayAbility() = default~MGameplayAbility
virtual ~MGameplayAbility() = defaultMGameplayAbility
MGameplayAbility(const MGameplayAbility&) = deleteMove-only: owns latent tasks (unique_ptr) and is held by unique_ptr in the ASC. Copying an in-flight ability makes no sense.
operator=
MGameplayAbility& operator=(const MGameplayAbility&) = deleteGetTriggerEventData
const FGameplayEventData& GetTriggerEventData() constCanActivate
virtual bool CanActivate(AbilitySystemComponent& asc) constCan the ability start right now? Checks required/blocked tags, the cooldown tag, and cost affordability. Override to add bespoke checks (call the base first).
ActivateAbility
virtual void ActivateAbility(AbilitySystemComponent& asc)The ability's logic. Instant abilities do their work and return; latent abilities spawn tasks (AddTask) and end from a task's onFinished. Override this. Default ends immediately.
EndAbility
virtual void EndAbility(AbilitySystemComponent& asc)Tear down: cancels remaining tasks, clears the active flag, fires the Removed cues. Safe to call more than once. Override for cleanup (call the base last).
CommitCost
void CommitCost(AbilitySystemComponent& asc)Pay the cost (instant effect) and start the cooldown (duration effect). Split so an ability can commit cost on press and cooldown on release.
CommitCooldown
void CommitCooldown(AbilitySystemComponent& asc)CommitAbility
bool CommitAbility(AbilitySystemComponent& asc)IsActive
bool IsActive() constRequestEndAbility
void RequestEndAbility()A task (or the ability itself) asks to end. Deferred rather than immediate so EndAbility never clears the task list while the ASC is iterating it — the ASC drains the request after ticking / after routing an event.
ConsumePendingEnd
bool ConsumePendingEnd()TickAbility
void TickAbility(AbilitySystemComponent& asc, float dt)Driven by the ASC each frame while active — ticks tasks, then prunes finished ones.
HandleGameplayEvent
void HandleGameplayEvent(const FGameplayEventData& data)Driven by the ASC when a gameplay event is sent while this ability is active — fans the event out to every live task.