// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Containers/Array.h" #include "Containers/Map.h" #include "Containers/SparseArray.h" #include "GameplayAbilitySpec.h" #include "Subsystems/WorldSubsystem.h" #include "Templates/SubclassOf.h" #include "UObject/UObjectGlobals.h" #include "LyraGlobalAbilitySystem.generated.h" class UGameplayAbility; class UGameplayEffect; class ULyraAbilitySystemComponent; class UObject; struct FActiveGameplayEffectHandle; struct FFrame; struct FGameplayAbilitySpecHandle; USTRUCT() struct FGlobalAppliedAbilityList { GENERATED_BODY() UPROPERTY() TMap, FGameplayAbilitySpecHandle> Handles; void AddToASC(TSubclassOf Ability, ULyraAbilitySystemComponent* ASC); void RemoveFromASC(ULyraAbilitySystemComponent* ASC); void RemoveFromAll(); }; USTRUCT() struct FGlobalAppliedEffectList { GENERATED_BODY() UPROPERTY() TMap, FActiveGameplayEffectHandle> Handles; void AddToASC(TSubclassOf Effect, ULyraAbilitySystemComponent* ASC); void RemoveFromASC(ULyraAbilitySystemComponent* ASC); void RemoveFromAll(); }; UCLASS() class ULyraGlobalAbilitySystem : public UWorldSubsystem { GENERATED_BODY() public: ULyraGlobalAbilitySystem(); UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category="Lyra") void ApplyAbilityToAll(TSubclassOf Ability); UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category="Lyra") void ApplyEffectToAll(TSubclassOf Effect); UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Lyra") void RemoveAbilityFromAll(TSubclassOf Ability); UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Lyra") void RemoveEffectFromAll(TSubclassOf Effect); /** Register an ASC with global system and apply any active global effects/abilities. */ void RegisterASC(ULyraAbilitySystemComponent* ASC); /** Removes an ASC from the global system, along with any active global effects/abilities. */ void UnregisterASC(ULyraAbilitySystemComponent* ASC); private: UPROPERTY() TMap, FGlobalAppliedAbilityList> AppliedAbilities; UPROPERTY() TMap, FGlobalAppliedEffectList> AppliedEffects; UPROPERTY() TArray> RegisteredASCs; };