AbilitySystemComponent
- Module
- Game
- Header
#include "Gameplay/AbilitySystemComponent.h"- Namespace
Mowo
Constructors
| Signature | Name | Description |
|---|---|---|
AbilitySystemComponent() = default | AbilitySystemComponent | |
AbilitySystemComponent(const AbilitySystemComponent&) = delete | AbilitySystemComponent | Move-only: owns granted ability instances (unique_ptr). |
AbilitySystemComponent(AbilitySystemComponent&&) = default | AbilitySystemComponent |
Public functions
| Returns | Name | Description |
|---|---|---|
AbilitySystemComponent& | operator= | |
AbilitySystemComponent& | operator= | |
void | SetOwnerActor | Owning actor — cues/damage report it as the cue source. |
MObject* | GetOwnerActor | |
void | InitAttribute | Attributes |
float | GetAttribute | current (aggregated) value |
float | GetAttributeBase | |
AttributeSet& | Attributes | |
const AttributeSet& | Attributes | |
void | AddAttributeClamp | Clamp rules Register (or replace) a clamp for attr. |
void | ClearAttributeClamps | |
uint32_t | ApplyEffect | Effects Apply an effect. |
bool | CanApplyEffect | Would ApplyEffect accept this spec right now? |
int | RemoveEffectsWithTags | Removes active effects whose asset or granted tags match any of tags. |
int | GetStackCount | |
const std::vector<ActiveGameplayEffect>& | GetActiveEffects | |
const FAbilitySystemStats& | GetStats | |
bool | RemoveEffect | |
int | RemoveEffectsWithId | returns how many were removed |
int | ActiveEffectCount | |
float | TagRemainingSeconds | Seconds left on the active effect that grants tag — the LONGEST when several do, since that is when the owner actually stops having it. |
int | CountEffectsWithId | |
bool | HasTag | Tags (hierarchical) |
void | AddTag | ref-counted |
void | RemoveTag | |
bool | HasAllTags | |
bool | HasAnyTags | |
FGameplayTagContainer | GetOwnedTags | The owned tags (count > 0) as a container, for FGameplayTagQuery. |
bool | IsAbilityBlocked | Ability blocking (UE's BlockAbilitiesWithTag): while an active ability blocks a tag, no ability whose tag matches it can activate. |
int | CancelAbilitiesWithTags | Ends every active class ability whose tag matches one of tags. |
void | NotifyAbilityEnded | Called by MGameplayAbility::EndAbility: drops the tags the ability blocked and owned while it ran. |
void | GrantAbility | Abilities (lambda specs — the trivial path) |
bool | HasAbility | |
bool | IsOnCooldown | |
bool | CanActivateAbility | Activatable = granted, required tags present, no blocked tags, off cooldown, and the cost is affordable (no Add modifier would push an attribute < 0). |
bool | TryActivateAbility | Checks CanActivate, then applies cost + cooldown + runs onActivate. |
MGameplayAbility* | GrantAbilityObject | Abilities (class-based MGameplayAbility — the data-authored path) Grant an ability instance. |
bool | HasAbilityObject | |
MGameplayAbility* | FindAbilityObject | |
bool | CanActivateAbilityObject | |
bool | TryActivateAbilityObject | Activate a class ability: CanActivate → CommitAbility (cost+cooldown) → ActivateAbility. |
bool | IsAbilityObjectActive | |
void | SendGameplayEvent | Gameplay events — routed to every active class ability's live tasks (a WaitGameplayEvent task finishes on a match). |
void | SendGameplayEvent | |
void | ExecuteGameplayCue | Fire a cue through the dispatcher with this ASC as the source. |
uint16_t | PredictActivateAbility | Client-side prediction On a client the player owns no authority, but waiting a full round-trip before the cost/cooldown/cue land feels laggy. |
uint16_t | PredictActivateAbilityObject | |
void | ConfirmPrediction | Server confirmed the prediction: drop the retained baseline (the local result stands; replicated attributes converge it to the exact value). |
void | RollbackPrediction | Server rejected the prediction: restore the captured baseline and drop the record. |
bool | HasPendingPrediction | |
int | PendingPredictionCount | |
void | Tick | Advance durations, run periodic effects, expire, tick abilities, recompute. |
const std::vector<GameplayAbilitySpec>& | GetGrantedAbilities | Read-only view of the granted set — the net layer resolves wire ability ids against it. |
Function details
AbilitySystemComponent
AbilitySystemComponent() = defaultAbilitySystemComponent
AbilitySystemComponent(const AbilitySystemComponent&) = deleteMove-only: owns granted ability instances (unique_ptr). Held by value on MAbilitySystemComponent, never copied.
AbilitySystemComponent
AbilitySystemComponent(AbilitySystemComponent&&) = defaultoperator=
AbilitySystemComponent& operator=(const AbilitySystemComponent&) = deleteoperator=
AbilitySystemComponent& operator=(AbilitySystemComponent&&) = defaultSetOwnerActor
void SetOwnerActor(MObject* owner)Owning actor — cues/damage report it as the cue source. Optional.
GetOwnerActor
MObject* GetOwnerActor() constInitAttribute
void InitAttribute(FName attr, float base)Attributes
GetAttribute
float GetAttribute(FName attr) constcurrent (aggregated) value
GetAttributeBase
float GetAttributeBase(FName attr) constAttributes
AttributeSet& Attributes()Attributes
const AttributeSet& Attributes() constAddAttributeClamp
void AddAttributeClamp(FName attr, float minValue, FName maxAttr = FName())Clamp rules Register (or replace) a clamp for attr. Applied immediately and on every subsequent base change / recompute.
ClearAttributeClamps
void ClearAttributeClamps()ApplyEffect
uint32_t ApplyEffect(const GameplayEffectSpec& spec, const AbilitySystemComponent* source = nullptr)Effects Apply an effect. Instant → modifies base now (returns 0). Duration/Infinite → adds an active effect, or a stack to an existing one (returns its handle), and recomputes current. Refused (returns 0, nothing changes) when an active effect grants immunity to its asset tags or the target fails its application tag requirements. source is the applier: its attributes back AttributeBased magnitudes and it keys by-source stacks.
CanApplyEffect
bool CanApplyEffect(const GameplayEffectSpec& spec) constWould ApplyEffect accept this spec right now?
RemoveEffectsWithTags
int RemoveEffectsWithTags(const std::vector<FGameplayTag>& tags)Removes active effects whose asset or granted tags match any of tags.
GetStackCount
int GetStackCount(FGameplayTag effectId) constGetActiveEffects
const std::vector<ActiveGameplayEffect>& GetActiveEffects() constGetStats
const FAbilitySystemStats& GetStats() constRemoveEffect
bool RemoveEffect(uint32_t handle)RemoveEffectsWithId
int RemoveEffectsWithId(FGameplayTag id)returns how many were removed
ActiveEffectCount
int ActiveEffectCount() constTagRemainingSeconds
float TagRemainingSeconds(FGameplayTag tag) constSeconds left on the active effect that grants tag — the LONGEST when several do, since that is when the owner actually stops having it. A cooldown is exactly this shape (an effect granting a cooldown tag for a duration), so it is what a client needs to grey out a button. 0 when nothing grants the tag or the granter has no duration.
CountEffectsWithId
int CountEffectsWithId(FGameplayTag id) constHasTag
bool HasTag(FGameplayTag tag) constTags (hierarchical)
AddTag
void AddTag(FGameplayTag tag)ref-counted
RemoveTag
void RemoveTag(FGameplayTag tag)HasAllTags
bool HasAllTags(const std::vector<FGameplayTag>& tags) constHasAnyTags
bool HasAnyTags(const std::vector<FGameplayTag>& tags) constGetOwnedTags
FGameplayTagContainer GetOwnedTags() constThe owned tags (count > 0) as a container, for FGameplayTagQuery.
IsAbilityBlocked
bool IsAbilityBlocked(FGameplayTag abilityTag) constAbility blocking (UE's BlockAbilitiesWithTag): while an active ability blocks a tag, no ability whose tag matches it can activate.
CancelAbilitiesWithTags
int CancelAbilitiesWithTags(const std::vector<FGameplayTag>& tags)Ends every active class ability whose tag matches one of tags.
NotifyAbilityEnded
void NotifyAbilityEnded(const MGameplayAbility& ability)Called by MGameplayAbility::EndAbility: drops the tags the ability blocked and owned while it ran.
GrantAbility
void GrantAbility(const GameplayAbilitySpec& ability)Abilities (lambda specs — the trivial path)
HasAbility
bool HasAbility(FGameplayTag abilityTag) constIsOnCooldown
bool IsOnCooldown(FGameplayTag abilityTag) constCanActivateAbility
bool CanActivateAbility(FGameplayTag abilityTag) constActivatable = granted, required tags present, no blocked tags, off cooldown, and the cost is affordable (no Add modifier would push an attribute < 0).
TryActivateAbility
bool TryActivateAbility(FGameplayTag abilityTag)Checks CanActivate, then applies cost + cooldown + runs onActivate. Returns whether it activated.
GrantAbilityObject
MGameplayAbility* GrantAbilityObject(std::unique_ptr<MGameplayAbility> ability)Abilities (class-based MGameplayAbility — the data-authored path) Grant an ability instance. Re-granting the same tag replaces it. Takes ownership.
HasAbilityObject
bool HasAbilityObject(FGameplayTag abilityTag) constFindAbilityObject
MGameplayAbility* FindAbilityObject(FGameplayTag abilityTag) constCanActivateAbilityObject
bool CanActivateAbilityObject(FGameplayTag abilityTag) constTryActivateAbilityObject
bool TryActivateAbilityObject(FGameplayTag abilityTag)Activate a class ability: CanActivate → CommitAbility (cost+cooldown) → ActivateAbility. Latent abilities stay active and tick until they end.
IsAbilityObjectActive
bool IsAbilityObjectActive(FGameplayTag abilityTag) constSendGameplayEvent
void SendGameplayEvent(const FGameplayEventData& data)Gameplay events — routed to every active class ability's live tasks (a WaitGameplayEvent task finishes on a match).
SendGameplayEvent
void SendGameplayEvent(FGameplayTag eventTag, MObject* instigator = nullptr, float magnitude = 0.0f)ExecuteGameplayCue
void ExecuteGameplayCue(FGameplayTag cueTag, EGameplayCueEvent event, float magnitude = 0.0f, MObject* instigator = nullptr)Fire a cue through the dispatcher with this ASC as the source.
PredictActivateAbility
uint16_t PredictActivateAbility(FGameplayTag abilityTag)Client-side prediction On a client the player owns no authority, but waiting a full round-trip before the cost/cooldown/cue land feels laggy. These predict an activation LOCALLY the instant the input arrives, and reconcile against the server's verdict: a confirm keeps the local result, a reject rolls every touched attribute + tag + effect back to the captured pre-activation baseline. The server stays authoritative — a predicted activation never changes anything the server does not also do. PredictActivateAbility captures the baseline, runs the local activation, and returns a non-zero prediction key when it applied (0 = the local CanActivate check failed, so nothing was predicted and there is nothing to reconcile). Works for both lambda-spec and class-based abilities.
PredictActivateAbilityObject
uint16_t PredictActivateAbilityObject(FGameplayTag abilityTag)ConfirmPrediction
void ConfirmPrediction(uint16_t key)Server confirmed the prediction: drop the retained baseline (the local result stands; replicated attributes converge it to the exact value).
RollbackPrediction
void RollbackPrediction(uint16_t key)Server rejected the prediction: restore the captured baseline and drop the record. A stale/unknown key is a no-op.
HasPendingPrediction
bool HasPendingPrediction(uint16_t key) constPendingPredictionCount
int PendingPredictionCount() constTick
void Tick(float dt)Advance durations, run periodic effects, expire, tick abilities, recompute.
GetGrantedAbilities
const std::vector<GameplayAbilitySpec>& GetGrantedAbilities() constRead-only view of the granted set — the net layer resolves wire ability ids against it.