> 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/gameplay-effect-ge/behaviour-geb.md).

# Behaviour (GEB)

Any mechanic/behaviour not covered by manipulating **attributes, tags**, or **GEC**s, can still be implemented with a **GameplayEffectBehaviour (GEB)**. (e.g. A mind control ability: We want to swap the controller input for the ASC. We do it by putting the code that swaps controllers in a GEB)\
\
A **GEB** has several hooks so you can add any code behavior you want at certain parts of the ability processing:<br>

```csharp
OnInstant(GameplayEffect ge) // OnInstant is only triggered from Instant/Periodic GEs. Meanwhile, the other methods are only triggered from Duration/Infinite GEs.
OnAddThis(GameplayEffect ge) // When the effect with this GEB applies on the ASC. e.g. Mind control, switch the movement controller here.
OnRemoveThis(GameplayEffect ge) // When the effect with this GEB is removed on the ASC. e.g. Mind control, return the original movement controller here.

OnAnyGameplayEffectApplied(GameplayEffect ge) // When any GE is added.
OnAnyGameplayEffectRemoved(GameplayEffect ge) // When any GE is removed.
OnAnyGameplayEffectsChanged(List<GameplayEffect> ges) // When any GE is applied or removed. e.g. Ability Cooldown Modifying GEB, recalculate the ability cooldown duration here.

OnAttributeChanged(AttributeName attributeName, float oldValue, float newValue, GameplayEffect ge)  

SerializeAdditionalData() //Multiplayer serialization
DeserializeAdditionalData() //Multiplayer serialization
```

Example of an GEB that applies another GE, when the current GE is removed:

```csharp
public class ApplyEffectOnRemoval : GameplayEffectBehaviour {
	[ReadOnly] public AbilitySystemComponent targetASC;

	public GameplayEffectSO geSO;

	public string geSO_Name;
	public override void SerializeAdditionalData() {
		geSO_Name = geSO.name;
	}
	public override void DeserializeAdditionalData() {
		geSO = GameplayEffectSOLibrary.Instance.GetByName(geSO_Name);
	}

	public override void OnAddThis(GameplayEffect ge) {
		targetASC = ge.target;
	}

	public override void OnRemoveThis(GameplayEffect ge) {
		targetASC.ApplyGameplayEffect(targetASC, targetASC, geSO.ge.Instantiate(), ge.applyGUID);
	}
}
```

<figure><img src="/files/VYSgnPK5seVw0y7whAPw" alt="" width="275"><figcaption></figcaption></figure>
