Committing to share, unfinished
parent
780062a8ed
commit
56dc78db07
|
|
@ -0,0 +1,4 @@
|
|||
// Copyright
|
||||
|
||||
|
||||
#include "AbilitySystem/StartupData/VRStartupAbilitySystemData.h"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
// Copyright
|
||||
|
||||
|
||||
#include "AbilitySystem/VRAbilitySystemComponent.h"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
// Copyright
|
||||
|
||||
|
||||
#include "Player/VRPlayerController.h"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#include "VRGASTypes.h"
|
||||
|
||||
#include "Abilities/GameplayAbility.h"
|
||||
|
||||
bool FVRAbilitySet::IsValid() const
|
||||
{
|
||||
return AbilityClass;
|
||||
}
|
||||
|
||||
bool FVRAbilitySet::IsValidInput() const
|
||||
{
|
||||
return InputTag.IsValid() && AbilityClass;
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright
|
||||
|
||||
|
||||
#include "VRGASUtils.h"
|
||||
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "GameplayAbilitySpec.h"
|
||||
#include "Abilities/GameplayAbility.h"
|
||||
|
||||
void UVRGASUtils::BatchGrantAbilities(const TArray<TSubclassOf<UGameplayAbility>>& InAbilitiesToGrant, UAbilitySystemComponent* InAbilitySystemComponent, int32 ApplyLevel, bool bDebugLog)
|
||||
{
|
||||
if (InAbilitiesToGrant.IsEmpty()) return;
|
||||
|
||||
for (const TSubclassOf<UGameplayAbility>& Ability : InAbilitiesToGrant)
|
||||
{
|
||||
if (!Ability) continue;
|
||||
|
||||
FGameplayAbilitySpec AbilitySpec(Ability);
|
||||
AbilitySpec.SourceObject = InAbilitySystemComponent->GetAvatarActor();
|
||||
AbilitySpec.Level = ApplyLevel;
|
||||
|
||||
InAbilitySystemComponent->GiveAbility(AbilitySpec);
|
||||
|
||||
if (bDebugLog)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("UWarriorUtils::BatchGrantAbilities - Successfully Granted ability %s"), *AbilitySpec.Handle.ToString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool UVRGASUtils::ApplyEffectToTarget(AActor* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level)
|
||||
{
|
||||
// Get the Ability System Component of the target
|
||||
// We set LookForComponent to true in case someone didn't implement the Ability System Interface
|
||||
UAbilitySystemComponent* TargetASC = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Target, true);
|
||||
|
||||
if (!TargetASC)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("ApplyEffectToTarget: Target Actor does not have an Ability System Component"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GameplayEffectClass)
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("ApplyEffectToTarget: GameplayEffectClass is null"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return ApplyEffectToTargetASC(TargetASC, GameplayEffectClass, SourceObject, Level);
|
||||
}
|
||||
|
||||
bool UVRGASUtils::ApplyEffectToTargetASC(UAbilitySystemComponent* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level)
|
||||
{
|
||||
check(Target);
|
||||
check(GameplayEffectClass);
|
||||
|
||||
FGameplayEffectContextHandle EffectContextHandle = Target->MakeEffectContext();
|
||||
EffectContextHandle.AddSourceObject(SourceObject);
|
||||
|
||||
const FGameplayEffectSpecHandle EffectSpec = Target->MakeOutgoingSpec(GameplayEffectClass, Level, EffectContextHandle);
|
||||
const FActiveGameplayEffectHandle ActiveGameplayEffectHandle = Target->ApplyGameplayEffectSpecToSelf(*EffectSpec.Data.Get());
|
||||
// return if application was successful
|
||||
return ActiveGameplayEffectHandle.WasSuccessfullyApplied();
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayEffect.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "VRStartupAbilitySystemData.generated.h"
|
||||
|
||||
|
||||
struct FVRAbilitySet;
|
||||
class UGameplayAbility;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class VRGAS_API UVRStartupAbilitySystemData : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Starup Data|Abilities")
|
||||
TArray<UGameplayAbility> StartupAbilities;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Starup Data|Abilities")
|
||||
TArray<FVRAbilitySet> StartupAbilitySets;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Startup Data|Attributes")
|
||||
UGameplayEffect AttributeInitEffect;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Startup Data|Attributes")
|
||||
float AttributeInitLevel = 1.f;
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "VRAbilitySystemComponent.generated.h"
|
||||
|
||||
DECLARE_MULTICAST_DELEGATE_OneParam(FEffectAssetTags, const FGameplayTagContainer& /*AssetTags*/);
|
||||
DECLARE_MULTICAST_DELEGATE(FAbilitiesGiven);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class VRGAS_API UVRAbilitySystemComponent : public UAbilitySystemComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
void AbilityActorInfoSet();
|
||||
|
||||
FEffectAssetTags EffectAssetTags;
|
||||
FAbilitiesGiven OnAbilitiesGiven;
|
||||
|
||||
bool bStartupAbilitiesGiven = false;
|
||||
|
||||
// Add startup abilities
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "VRPlayerController.generated.h"
|
||||
|
||||
class UVRInputConfig;
|
||||
class UInputMappingContext;
|
||||
class UAbilitySystemComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class VRGAS_API AVRPlayerController : public APlayerController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AVRPlayerController();
|
||||
|
||||
protected:
|
||||
// TODO: Implement controller
|
||||
virtual void SetupInputComponent() override;
|
||||
virtual void OnPossess(APawn* InPawn) override;
|
||||
|
||||
#pragma region InputConfig
|
||||
UPROPERTY(EditDefaultsOnly, Category = Input)
|
||||
TObjectPtr<UInputMappingContext> InputMappingContext;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = Input)
|
||||
TObjectPtr<UVRInputConfig> InputConfig;
|
||||
#pragma endregion
|
||||
|
||||
#pragma region GAS
|
||||
UPROPERTY()
|
||||
TWeakObjectPtr<UAbilitySystemComponent> CachedAbilitySystemComponent;
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "Ability System", meta = (HideSelfPin))
|
||||
UAbilitySystemComponent* GetAbilitySystemComponent();
|
||||
#pragma endregion
|
||||
};
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
|
||||
class UGameplayAbility;
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FVRAbilitySet
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (Categories = "InputTag"))
|
||||
FGameplayTag InputTag;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
TSubclassOf<UGameplayAbility> AbilityClass;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
uint32 AbilityLevel = 1.f;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
bool IsValidInput() const;
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "VRGASUtils.generated.h"
|
||||
|
||||
class UGameplayEffect;
|
||||
class UAbilitySystemComponent;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class VRGAS_API UVRGASUtils : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Utils|Ability System")
|
||||
static void BatchGrantAbilities(const TArray<TSubclassOf<UGameplayAbility>>& InAbilitiesToGrant,
|
||||
UAbilitySystemComponent* InAbilitySystemComponent,
|
||||
int32 ApplyLevel, bool bDebugLog = false);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Utils|Ability System")
|
||||
static bool ApplyEffectToTarget(AActor* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level = 1.f);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Utils|Ability System")
|
||||
static bool ApplyEffectToTargetASC(UAbilitySystemComponent* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level = 1.f);
|
||||
|
||||
};
|
||||
Loading…
Reference in New Issue