> For the complete documentation index, see [llms.txt](https://feliperoddd.gitbook.io/gasify/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://feliperoddd.gitbook.io/gasify/ability-system-component-asc.md).

# Ability System Component (ASC)

This is the container that holds all the "gears" of the GameplayAbilitySystem. \
It represents a single character/entity with its **Attributes**/**Abilities** and **Effects**/**Tags** currently applied to it. \
It is also the origin of most things that are executed by the GAS.

<figure><img src="/files/1ncFQKXar6ukRNM2NjEZ" alt=""><figcaption><p>AbilitySystemComponent (ASC) in the inspector.</p></figcaption></figure>

## Attributes

The **Attributes** in this **ASC** and their current values. \
**Attributes** are numeric representations of any mechanic/parameter you are modelling.&#x20;

You can create as many different attributes as you want to represent any numeric mechanic. The only limit is your imagination. This is not constrained to your player, or combat related values, you can create mechanics for other objects aswell, including crafting, vehicles, basebuilding.

*(e.g. Health, MaxHealth, MovementSpeed, CriticalChance, CriticalBonus, Ammo, Dungeon.SpawnRate, Building.MaxRooms, Vehicle.Acceleration, Monster.HitChance, Enemy.AimSpeed)*

Check [Attributes](/gasify/ability-system-component-asc/attributes.md) to create more attributes.

### OnAttributeChanged

Subscribe to this event to update your variables whenever an attribute changes.

```csharp
asc.OnAttributeChanged += (attributeName, oldValue, newValue, ge) => { Debug.Log($"{attributeName.name} {oldValue} -> {newValue} / ge: {ge?.name}"); };
```

### GetAttribute

Use this to grab an attribute value immediately. \
Needs to be called every frame if you need to keep the variable always up to data. \
Prefer OnAttributeChanged.

## Tags

Current **GameplayTags** applied on this **ASC**.\
**GameplayTags** are names used to classify and describe the state of an object.\
They are useful for categorizing and identifying the properties or status of an entity (**ASC**).

*(e.g. Status.Debuff.Stun, Status.Debuff.Poisoned, Movement.Crouching, Movement.Sprinting, Environment.Underwater)*

### OnTagsChanged

This event is triggered everytime the **ASC**'s **tags** are changed.

```csharp
 asc.OnTagsChanged += (newTags, src, tgt) => Debug.Log($"[TAGS] OnTagsChanged! newTags: [{string.Join(", ", newTags.Select(x => x.name))}]");
```

## GrantedGameplayAbilities

List of abilities (GA) the **ASC** can use/activate.

### TryActivate

Attempts to activate a specific **GameplayAbility** by its name, index or reference. It searches for the ability in the list of *grantedGameplayAbilities* and then attempts to activate it on a specified target.

### Grant/Ungrant Ability

Granting an ability instantiates a new copy of the **GameplayAbility** and add that copy to **grantedGameplayAbilities**. Also triggers *OnGameplayAbilityGranted* event.\
Ungranting deactivates the ability and then remove it from **grantedGameplayAbilities.** Also triggers *OnGameplayAbilityUngranted* event.

## AppliedGameplayEffects

Current **GameplayEffects** applied on this ASC.

### ApplyGameplayEffect/RemoveGameplayEffect

The **ApplyGameplayEffect** method is called by **Abilities** (GA). It applies a **GameplayEffect** (GE) to an AbilitySystemComponent (ASC). It sets the source and target for the effect, then checks if the effect meets the tag requirements. If the requirements are met, it applies the effect and triggers *OnGameplayEffectApplied*. **ApplyGameplayEffect** can also be called 'manually' if you want to apply an effect (GE) without an ability.

The **RemoveGameplayEffect** method removes a gameplay effect from the ASC. It first checks if the effect is present in the ASC. If found, it removes the effect, refreshes attribute modifiers, applies attribute modifier values, and triggers *OnGameplayEffectRemoved*.

## Events

There are events that you can listen for and react to changes on the **ASC**.

*OnGameplayEffectApplied, OnGameplayEffectRemoved*\
Triggered when GameplayEffects are applied or removed.

*OnTagsChanged*\
Triggered when the applied tag list of the ASC changes.

*OnGameplayAbilityGranted, OnGameplayAbilityUngranted*\
Triggered when an ability is granted or ungranted.\
\
*OnGameplayAbilityPreActivate, OnGameplayAbilityActivated, OnGameplayAbilityTryActivate, OnGameplayAbilityDeactivated, OnGameplayAbilityFailedActivation*\
Triggered when activating/deactivating abilities.\
\
*OnAttributeChanged, OnPreAttributeChange*\
Triggered from changes in attributes.
