Do batch grant ability sets
parent
54e9efd1e0
commit
c68562eca6
|
|
@ -6,6 +6,8 @@
|
||||||
#include "AbilitySystemComponent.h"
|
#include "AbilitySystemComponent.h"
|
||||||
#include "AbilitySystemGlobals.h"
|
#include "AbilitySystemGlobals.h"
|
||||||
#include "GameplayAbilitySpec.h"
|
#include "GameplayAbilitySpec.h"
|
||||||
|
#include "Logging.h"
|
||||||
|
#include "VRGASTypes.h"
|
||||||
#include "Abilities/GameplayAbility.h"
|
#include "Abilities/GameplayAbility.h"
|
||||||
|
|
||||||
void UVRGASUtils::BatchGrantAbilities(const TArray<TSubclassOf<UGameplayAbility>>& InAbilitiesToGrant, UAbilitySystemComponent* InAbilitySystemComponent, int32 ApplyLevel, bool bDebugLog)
|
void UVRGASUtils::BatchGrantAbilities(const TArray<TSubclassOf<UGameplayAbility>>& InAbilitiesToGrant, UAbilitySystemComponent* InAbilitySystemComponent, int32 ApplyLevel, bool bDebugLog)
|
||||||
|
|
@ -29,6 +31,29 @@ void UVRGASUtils::BatchGrantAbilities(const TArray<TSubclassOf<UGameplayAbility>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UVRGASUtils::BatchGrantAbilitySets(const TArray<FVRAbilitySet>& AbilitySetsToGrant, UAbilitySystemComponent* InAbilitySystemComponent, bool bDebugLog)
|
||||||
|
{
|
||||||
|
if (AbilitySetsToGrant.IsEmpty()) return;
|
||||||
|
|
||||||
|
for (const FVRAbilitySet& AbilitySet : AbilitySetsToGrant)
|
||||||
|
{
|
||||||
|
if (!AbilitySet.IsValid()) continue;
|
||||||
|
|
||||||
|
FGameplayAbilitySpec AbilitySpec(AbilitySet.AbilityClass);
|
||||||
|
AbilitySpec.SourceObject = InAbilitySystemComponent->GetAvatarActor();
|
||||||
|
AbilitySpec.Level = AbilitySet.AbilityLevel;
|
||||||
|
if (AbilitySet.IsValidInput())
|
||||||
|
AbilitySpec.DynamicAbilityTags.AddTag(AbilitySet.InputTag);
|
||||||
|
|
||||||
|
InAbilitySystemComponent->GiveAbility(AbilitySpec);
|
||||||
|
|
||||||
|
if (bDebugLog)
|
||||||
|
{
|
||||||
|
UE_LOG(VRGAS_Log, Log, TEXT("Successfully given ability %s from Ability Set"), *AbilitySpec.Handle.ToString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool UVRGASUtils::ApplyEffectToTarget(AActor* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level)
|
bool UVRGASUtils::ApplyEffectToTarget(AActor* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level)
|
||||||
{
|
{
|
||||||
// Get the Ability System Component of the target
|
// Get the Ability System Component of the target
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
#include "VRGASUtils.generated.h"
|
#include "VRGASUtils.generated.h"
|
||||||
|
|
||||||
|
struct FVRAbilitySet;
|
||||||
class UGameplayAbility;
|
class UGameplayAbility;
|
||||||
class UGameplayEffect;
|
class UGameplayEffect;
|
||||||
class UAbilitySystemComponent;
|
class UAbilitySystemComponent;
|
||||||
|
|
@ -24,6 +25,10 @@ public:
|
||||||
UAbilitySystemComponent* InAbilitySystemComponent,
|
UAbilitySystemComponent* InAbilitySystemComponent,
|
||||||
int32 ApplyLevel, bool bDebugLog = false);
|
int32 ApplyLevel, bool bDebugLog = false);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Utils|Ability System")
|
||||||
|
static void BatchGrantAbilitySets(const TArray<FVRAbilitySet>& AbilitySetsToGrant,
|
||||||
|
UAbilitySystemComponent* InAbilitySystemComponent, bool bDebugLog = false);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Utils|Ability System")
|
UFUNCTION(BlueprintCallable, Category = "Utils|Ability System")
|
||||||
static bool ApplyEffectToTarget(AActor* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level = 1.f);
|
static bool ApplyEffectToTarget(AActor* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level = 1.f);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue