# GameFeatures

## What is Game Features

The Game Features and Modular Gameplay plugins help developers create standalone features for their projects. Building features with these plugins offers several benefits, including keeping your project's codebase clean and readable, and avoiding accidental interactions or dependencies between unrelated features. This is particularly important when developing live products that change their feature sets over time. [Official Documentation](https://docs.unrealengine.com/5.1/en-US/game-features-and-modular-gameplay-in-unreal-engine/)

By default, there are four `game features action` available for you.

| Name                     | Functionality                                                                                                                                                                                                                                                                       |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Add Cheats               | Action extend the Cheat Manager, creating new "cheat codes" or extending existing ones. Cheat codes are helpful for debugging, and are automatically removed from shipping builds. The \~ (tilde) key opens the console where you can enter these codes while running your project. |
| Add Components           | Actions take a list of Actor subclasses and add a set of Components to them on an opt-in basis. This is the most common way to use the Game Features and Modular Gameplay plugins, since Components are well-suited to encapsulating a wide range of behaviors.                     |
| Add Data Registry        | Actions add one or more Data Registries to the project. Data Registries are efficient places to store and retrieve globally-registered data.                                                                                                                                        |
| Add Data Registry Source | Actions add one or more Data Tables to existing Data                                                                                                                                                                                                                                |

In CommonGAS, we provided you GameFeatureAction for GameplayAbilitySystem taken from [ValleyOfTheAncientDemo](https://www.unrealengine.com/marketplace/en-US/product/ancient-game-01) and [LyraGameSample](https://www.unrealengine.com/marketplace/en-US/product/lyra)

| Name                    | Functionality                                                                                                             |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| Add Abilities           | Add gameplay abilities and gameplay effects when enabled and remove gameplay abilities and gameplay effects when disabled |
| Add InputMappingContext | Add an InputMappingContext when enabled and remove an InputMappingContext when disabled                                   |

## GCCGameFeatureAction\_AddAbilities

GameFeatureAction `Add Abilities`responsibles for granting abilities and gameplay effects to actors of a specified type when a game feature is enabled and removing abilities and gameplay effects when a game features is disabled.

![Image](https://khxisaki.github.io/CommonGASDocs/img/gamefeatureaddability.png)

![Image](https://khxisaki.github.io/CommonGASDocs/img/gamefeaturedata_addabilities.png)

| Name              | Functionality                                                                                      |
| ----------------- | -------------------------------------------------------------------------------------------------- |
| Granted Abilities | Applying a gameplay ability with an input action to apply with specified actor                     |
| Granted Attribute | Applying a attribute set with an data table to initialize gameplay attributes with specified actor |

### Granted Abilities <a href="#granted-abilities" id="granted-abilities"></a>

![Image](https://khxisaki.github.io/CommonGASDocs/img/gamefeatureaddabilities_grantedabilities.png)

| Name         | Functionality             |
| ------------ | ------------------------- |
| Ability Type | UGameplayAbility to apply |
| Input Action | UInputAction to apply     |

### Granted Attributes <a href="#granted-attributes" id="granted-attributes"></a>

![Image](https://khxisaki.github.io/CommonGASDocs/img/gamefeatureaddabilities_grantedattribute.png)

| Name                | Functionality                                      |
| ------------------- | -------------------------------------------------- |
| Attribute Set Type  | UAttributeSet to grant                             |
| Initialization Data | Data table reference to initialize attributes with |

## GCCGameFeatureAction\_AddInputMappingContext

`AddInputMappingContext` adds `InputMappingContext` to local players' EnhancedInput system when a game feature is enabled and remove `InputMappingContext` when a game feature is disabled.

`AddInputMappingContext` also work in tandem with `Add Abilities` game feature action when an Ability is granted alongside an Input Action

![Image](https://khxisaki.github.io/CommonGASDocs/img/gamefeaturesaction_addinputmapping.png)

| Name          | Functionality                                                                                           |
| ------------- | ------------------------------------------------------------------------------------------------------- |
| Input Mapping | Input Mapping Context to apply                                                                          |
| Priority      | Higher priority InputMappingContext will be prioritized instead of lower priority Input Mapping Context |
