Migration
This commit is contained in:
15
Source/Aura.Target.cs
Normal file
15
Source/Aura.Target.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class AuraTarget : TargetRules
|
||||
{
|
||||
public AuraTarget(TargetInfo Target) : base(Target)
|
||||
{
|
||||
Type = TargetType.Game;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V2;
|
||||
|
||||
ExtraModuleNames.AddRange( new string[] { "Aura" } );
|
||||
}
|
||||
}
|
||||
36
Source/Aura/Aura.Build.cs
Normal file
36
Source/Aura/Aura.Build.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class Aura : ModuleRules
|
||||
{
|
||||
public Aura(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] {
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"InputCore",
|
||||
"EnhancedInput",
|
||||
"GameplayAbilities",
|
||||
// "NetCore"
|
||||
});
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[] {
|
||||
"GameplayTags",
|
||||
"GameplayTasks",
|
||||
"NavigationSystem",
|
||||
"AIModule"
|
||||
});
|
||||
|
||||
// Uncomment if you are using Slate UI
|
||||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
|
||||
// Uncomment if you are using online features
|
||||
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
|
||||
|
||||
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
|
||||
}
|
||||
}
|
||||
6
Source/Aura/Aura.cpp
Normal file
6
Source/Aura/Aura.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Aura.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, Aura, "Aura" );
|
||||
12
Source/Aura/Aura.h
Normal file
12
Source/Aura/Aura.h
Normal file
@@ -0,0 +1,12 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
#define PRINT_DEBUG(text) if(GEngine) GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT(text));
|
||||
// if(GEngine)
|
||||
// GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("Message %f"), value));
|
||||
|
||||
#define ECC_Projectile ECollisionChannel::ECC_GameTraceChannel1
|
||||
#define ECC_CursorHit ECollisionChannel::ECC_GameTraceChannel2
|
||||
22
Source/Aura/Private/AI/AuraAIController.cpp
Normal file
22
Source/Aura/Private/AI/AuraAIController.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// Amasson
|
||||
|
||||
#include "AI/AuraAIController.h"
|
||||
|
||||
AAuraAIController::AAuraAIController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AAuraAIController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
void AAuraAIController::OnPossess(APawn* PossessedPawn)
|
||||
{
|
||||
Super::OnPossess(PossessedPawn);
|
||||
|
||||
if (BehaviorTree)
|
||||
RunBehaviorTree(BehaviorTree);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AI/Services/BTService_FindNearestPlayer.h"
|
||||
#include "AIController.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "BehaviorTree/BTFunctionLibrary.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
|
||||
void UBTService_FindNearestPlayer::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
|
||||
{
|
||||
Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds);
|
||||
|
||||
APawn* OwningPawn = AIOwner->GetPawn();
|
||||
|
||||
if (!OwningPawn)
|
||||
return;
|
||||
|
||||
const FName TargetTag = OwningPawn->ActorHasTag(FName("Enemy")) ? FName("Player") : FName("Enemy");
|
||||
|
||||
TArray<AActor*> ActorsWithTag;
|
||||
UGameplayStatics::GetAllActorsWithTag(OwningPawn, TargetTag, ActorsWithTag);
|
||||
|
||||
float ClosestRange = MaxRange;
|
||||
AActor* ClosestActor = nullptr;
|
||||
for (AActor* ActorWithTag : ActorsWithTag)
|
||||
{
|
||||
if (IsValid(ActorWithTag) && IsValid(OwningPawn))
|
||||
{
|
||||
float Distance = OwningPawn->GetDistanceTo(ActorWithTag);
|
||||
if (Distance < ClosestRange)
|
||||
{
|
||||
ClosestRange = Distance;
|
||||
ClosestActor = ActorWithTag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (ClosestActor)
|
||||
// DrawDebugLine(GetWorld(), OwningPawn->GetActorLocation(), ClosestActor->GetActorLocation(),
|
||||
// FColor::Red, false, 0.5f);
|
||||
|
||||
UBTFunctionLibrary::SetBlackboardValueAsObject(this, TargetToFollowSelector, ClosestActor);
|
||||
UBTFunctionLibrary::SetBlackboardValueAsFloat(this, DistanceToTargetSelector, ClosestRange);
|
||||
}
|
||||
11
Source/Aura/Private/AI/Tasks/BTTask_Attack.cpp
Normal file
11
Source/Aura/Private/AI/Tasks/BTTask_Attack.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AI/Tasks/BTTask_Attack.h"
|
||||
|
||||
EBTNodeResult::Type UBTTask_Attack::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
|
||||
{
|
||||
return Super::ExecuteTask(OwnerComp, NodeMemory);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/Abilities/AuraDamageGameplayAbility.h"
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
|
||||
FGameplayEffectSpecHandle& UAuraDamageGameplayAbility::AssignAbilityLevelDamagesSetByCallerMagnitude(FGameplayEffectSpecHandle& EffectSpecHandle, float Factor) const
|
||||
{
|
||||
for (const TPair<FGameplayTag, FScalableFloat>& Damage : Damages)
|
||||
{
|
||||
UAbilitySystemBlueprintLibrary::AssignTagSetByCallerMagnitude(EffectSpecHandle, Damage.Key, Damage.Value.GetValueAtLevel(GetAbilityLevel()) * Factor);
|
||||
}
|
||||
return EffectSpecHandle;
|
||||
}
|
||||
|
||||
void UAuraDamageGameplayAbility::GetScaledDamages(TMap<FGameplayTag, float>& ScaledDamages, float Level) const
|
||||
{
|
||||
const float TargetLevel = Level < 0 ? GetAbilityLevel() : Level;
|
||||
|
||||
for (const TPair<FGameplayTag, FScalableFloat>& Damage : Damages)
|
||||
{
|
||||
const float ScaledValue = Damage.Value.GetValueAtLevel(TargetLevel);
|
||||
ScaledDamages.Add(Damage.Key, ScaledValue);
|
||||
}
|
||||
}
|
||||
|
||||
TMap<FGameplayTag, float> UAuraDamageGameplayAbility::MultiplyDamagesByFloat(const TMap<FGameplayTag, float>& InDamages, float Factor)
|
||||
{
|
||||
TMap<FGameplayTag, float> NewDamages = InDamages;
|
||||
for (TPair<FGameplayTag, float>& ScaledDamage : NewDamages)
|
||||
{
|
||||
ScaledDamage.Value *= Factor;
|
||||
}
|
||||
return NewDamages;
|
||||
}
|
||||
|
||||
TMap<FGameplayTag, float> UAuraDamageGameplayAbility::MultiplyDamageTypesByFloats(const TMap<FGameplayTag, float>& InDamages, const TMap<FGameplayTag, float>& Factors)
|
||||
{
|
||||
TMap<FGameplayTag, float> NewDamages = InDamages;
|
||||
for (const TPair<FGameplayTag, float>& Factor : Factors)
|
||||
{
|
||||
float *TargetValue = NewDamages.Find(Factor.Key);
|
||||
if (TargetValue)
|
||||
*TargetValue *= Factor.Value;
|
||||
}
|
||||
return NewDamages;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/Abilities/AuraGameplayAbility.h"
|
||||
#include "Interaction/CombatInterface.h"
|
||||
|
||||
|
||||
FTransform UAuraGameplayAbility::MakeProjectileSpawnTransform(FGameplayTag SocketTagName, const FVector& TargetLocation, float Pitch) const
|
||||
{
|
||||
FTransform SpawnTransform;
|
||||
|
||||
AActor* Avatar = GetAvatarActorFromActorInfo();
|
||||
|
||||
if (!IsValid(Avatar))
|
||||
return SpawnTransform;
|
||||
|
||||
if (Avatar->Implements<UCombatInterface>())
|
||||
SpawnTransform.SetLocation(ICombatInterface::Execute_GetCombatSocketLocation(Avatar, SocketTagName));
|
||||
else
|
||||
SpawnTransform.SetLocation(Avatar->GetActorLocation());
|
||||
|
||||
FRotator Rotation = (TargetLocation - SpawnTransform.GetLocation()).Rotation();
|
||||
Rotation.Pitch = Pitch;
|
||||
SpawnTransform.SetRotation(Rotation.Quaternion());
|
||||
|
||||
return SpawnTransform;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AbilitySystem/Abilities/AuraSummonAbility.h"
|
||||
#include "NavigationSystem.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#include "GameFramework/Character.h"
|
||||
|
||||
UAuraSummonAbility::UAuraSummonAbility()
|
||||
{
|
||||
InstancingPolicy = EGameplayAbilityInstancingPolicy::InstancedPerActor;
|
||||
}
|
||||
|
||||
ACharacter* UAuraSummonAbility::SummonCharacter(TSubclassOf<ACharacter> Class, const FVector& Location, float YawOffset)
|
||||
{
|
||||
if (!GetAvatarActorFromActorInfo()->HasAuthority())
|
||||
return nullptr;
|
||||
|
||||
AActor* Owner = GetOwningActorFromActorInfo();
|
||||
AActor* Avatar = GetAvatarActorFromActorInfo();
|
||||
|
||||
FTransform SpawnTransform;
|
||||
|
||||
SpawnTransform.SetLocation(Location);
|
||||
|
||||
FVector SpawnDirection = Location - Avatar->GetActorLocation();
|
||||
SpawnDirection.Z = 0.0f;
|
||||
FRotator Rotation = UKismetMathLibrary::MakeRotFromX(SpawnDirection);
|
||||
Rotation.Yaw += YawOffset;
|
||||
|
||||
SpawnTransform.SetRotation(Rotation.Quaternion());
|
||||
|
||||
FActorSpawnParameters SpawnParameters;
|
||||
SpawnParameters.Owner = Owner;
|
||||
SpawnParameters.Instigator = Cast<APawn>(Avatar);
|
||||
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
|
||||
ACharacter* Character = GetWorld()->SpawnActor<ACharacter>(Class, SpawnTransform, SpawnParameters);
|
||||
|
||||
if (!Character)
|
||||
return nullptr;
|
||||
|
||||
SpawnedCharacters.Add(Character);
|
||||
|
||||
Character->OnDestroyed.AddDynamic(this, &UAuraSummonAbility::SummonDestroyed);
|
||||
|
||||
OnSpawnedCharactersChange.Broadcast(this);
|
||||
|
||||
return Character;
|
||||
}
|
||||
|
||||
void UAuraSummonAbility::SummonDestroyed(AActor* DestroyedActor)
|
||||
{
|
||||
bool bRemovedOne = false;
|
||||
|
||||
if (DestroyedActor)
|
||||
{
|
||||
if (ACharacter* DestroyedCharacter = Cast<ACharacter>(DestroyedActor))
|
||||
{
|
||||
if (SpawnedCharacters.RemoveSingle(DestroyedCharacter))
|
||||
{
|
||||
bRemovedOne = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int32 i = SpawnedCharacters.Num() - 1; i >= 0; --i)
|
||||
{
|
||||
if (!IsValid(SpawnedCharacters[i]))
|
||||
{
|
||||
SpawnedCharacters.RemoveAt(i);
|
||||
bRemovedOne = true;
|
||||
}
|
||||
}
|
||||
if (bRemovedOne)
|
||||
OnSpawnedCharactersChange.Broadcast(this);
|
||||
}
|
||||
|
||||
TArray<FVector> UAuraSummonAbility::GetSpawnLocations()
|
||||
{
|
||||
TArray<FVector> Locations;
|
||||
|
||||
AActor* Avatar = GetAvatarActorFromActorInfo();
|
||||
|
||||
FVector AvatarLocation = Avatar->GetActorLocation();
|
||||
FVector AvatarForward = Avatar->GetActorForwardVector();
|
||||
|
||||
float StepAngle = SpawnSpreadAngle / (SpawnCount - 1);
|
||||
FVector Direction = SpawnCount == 1 ?
|
||||
AvatarForward :
|
||||
AvatarForward.RotateAngleAxis(-SpawnSpreadAngle / 2.0f, FVector::UpVector);
|
||||
|
||||
for (int32 i = 0; i < SpawnCount; i++)
|
||||
{
|
||||
FVector Location = AvatarLocation + Direction * FMath::FRandRange(SpawnMinDistance, SpawnMaxDistance);
|
||||
Direction = Direction.RotateAngleAxis(StepAngle, FVector::UpVector);
|
||||
|
||||
FNavLocation NavLoc;
|
||||
UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetCurrent(GetWorld());
|
||||
if (!NavSystem->ProjectPointToNavigation(Location, NavLoc))
|
||||
continue;
|
||||
|
||||
Location = NavLoc.Location;
|
||||
|
||||
Locations.Add(Location);
|
||||
}
|
||||
|
||||
return Locations;
|
||||
}
|
||||
140
Source/Aura/Private/AbilitySystem/AbilitySystemTypes.cpp
Normal file
140
Source/Aura/Private/AbilitySystem/AbilitySystemTypes.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
|
||||
#include "AbilitySystem/AbilitySystemTypes.h"
|
||||
|
||||
FGameplayEffectContext* FAuraGameplayEffectContext::Duplicate() const
|
||||
{
|
||||
FGameplayEffectContext* NewContext = new FGameplayEffectContext();
|
||||
*NewContext = *this;
|
||||
if (GetHitResult())
|
||||
{
|
||||
// Does a deep copy of the hit result
|
||||
NewContext->AddHitResult(*GetHitResult(), true);
|
||||
}
|
||||
return NewContext;
|
||||
}
|
||||
|
||||
bool FAuraGameplayEffectContext::NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess)
|
||||
{
|
||||
uint32 RepBits = 0;
|
||||
if (Ar.IsSaving())
|
||||
{
|
||||
if (bReplicateInstigator && Instigator.IsValid())
|
||||
{
|
||||
RepBits |= 1 << 0;
|
||||
}
|
||||
if (bReplicateEffectCauser && EffectCauser.IsValid() )
|
||||
{
|
||||
RepBits |= 1 << 1;
|
||||
}
|
||||
if (AbilityCDO.IsValid())
|
||||
{
|
||||
RepBits |= 1 << 2;
|
||||
}
|
||||
if (bReplicateSourceObject && SourceObject.IsValid())
|
||||
{
|
||||
RepBits |= 1 << 3;
|
||||
}
|
||||
if (Actors.Num() > 0)
|
||||
{
|
||||
RepBits |= 1 << 4;
|
||||
}
|
||||
if (HitResult.IsValid())
|
||||
{
|
||||
RepBits |= 1 << 5;
|
||||
}
|
||||
if (bHasWorldOrigin)
|
||||
{
|
||||
RepBits |= 1 << 6;
|
||||
}
|
||||
if (bIsBlockedHit)
|
||||
{
|
||||
RepBits |= 1 << 7;
|
||||
}
|
||||
if (bIsCriticalHit)
|
||||
{
|
||||
RepBits |= 1 << 8;
|
||||
}
|
||||
if (!HitImpulse.IsZero())
|
||||
{
|
||||
RepBits |= 1 << 9;
|
||||
}
|
||||
}
|
||||
|
||||
Ar.SerializeBits(&RepBits, 10);
|
||||
|
||||
if (RepBits & (1 << 0))
|
||||
{
|
||||
Ar << Instigator;
|
||||
}
|
||||
if (RepBits & (1 << 1))
|
||||
{
|
||||
Ar << EffectCauser;
|
||||
}
|
||||
if (RepBits & (1 << 2))
|
||||
{
|
||||
Ar << AbilityCDO;
|
||||
}
|
||||
if (RepBits & (1 << 3))
|
||||
{
|
||||
Ar << SourceObject;
|
||||
}
|
||||
if (RepBits & (1 << 4))
|
||||
{
|
||||
SafeNetSerializeTArray_Default<31>(Ar, Actors);
|
||||
}
|
||||
if (RepBits & (1 << 5))
|
||||
{
|
||||
if (Ar.IsLoading())
|
||||
{
|
||||
if (!HitResult.IsValid())
|
||||
{
|
||||
HitResult = TSharedPtr<FHitResult>(new FHitResult());
|
||||
}
|
||||
}
|
||||
HitResult->NetSerialize(Ar, Map, bOutSuccess);
|
||||
}
|
||||
if (RepBits & (1 << 6))
|
||||
{
|
||||
Ar << WorldOrigin;
|
||||
bHasWorldOrigin = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bHasWorldOrigin = false;
|
||||
}
|
||||
if (RepBits & (1 << 7))
|
||||
{
|
||||
Ar << bIsBlockedHit;
|
||||
}
|
||||
if (RepBits & (1 << 8))
|
||||
{
|
||||
Ar << bIsCriticalHit;
|
||||
}
|
||||
if (RepBits & (1 << 9))
|
||||
{
|
||||
HitImpulse.NetSerialize(Ar, Map, bOutSuccess);
|
||||
}
|
||||
|
||||
if (Ar.IsLoading())
|
||||
{
|
||||
AddInstigator(Instigator.Get(), EffectCauser.Get()); // Just to initialize InstigatorAbilitySystemComponent
|
||||
}
|
||||
|
||||
bOutSuccess = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// bool FAuraGameplayEffectContext::NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess)
|
||||
// {
|
||||
// if (!Super::NetSerialize(Ar, Map, bOutSuccess))
|
||||
// {
|
||||
// bOutSuccess = false;
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// Ar << bIsBlockedHit;
|
||||
// Ar << bIsCriticalHit;
|
||||
|
||||
// bOutSuccess = true;
|
||||
// return true;
|
||||
// }
|
||||
474
Source/Aura/Private/AbilitySystem/AuraAbilitySystemComponent.cpp
Normal file
474
Source/Aura/Private/AbilitySystem/AuraAbilitySystemComponent.cpp
Normal file
@@ -0,0 +1,474 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/Abilities/AuraGameplayAbility.h"
|
||||
#include "GameplayEffect.h"
|
||||
#include "AuraGameplayTags.h"
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemLibrary.h"
|
||||
#include "AbilitySystem/Components/GameplayEffectInterceptor.h"
|
||||
|
||||
void UAuraAbilitySystemComponent::AbilitySystemInitDone()
|
||||
{
|
||||
OnGameplayEffectAppliedDelegateToSelf.AddUObject(this, &UAuraAbilitySystemComponent::ClientOnEffectApplied);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::GrantAbility(const FGameplayAbilityGrant& Grant)
|
||||
{
|
||||
FGameplayAbilitySpec AbilitySpec(Grant.Class, Grant.Level);
|
||||
if (Grant.InputTag.IsValid())
|
||||
AbilitySpec.DynamicAbilityTags.AddTag(Grant.InputTag);
|
||||
if (Grant.ActiveOnGranted)
|
||||
GiveAbilityAndActivateOnce(AbilitySpec);
|
||||
else
|
||||
GiveAbility(AbilitySpec);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::GrantStartupAbilities(const TArray<FGameplayAbilityGrant>& Abilities)
|
||||
{
|
||||
for (const FGameplayAbilityGrant& Ability : Abilities)
|
||||
{
|
||||
GrantAbility(Ability);
|
||||
}
|
||||
bStartupAbilitiesGiven = true;
|
||||
|
||||
ForEachAbilityLambda([this](FGameplayAbilitySpec& AbilitySpec) {
|
||||
OnAbilitySpecChange.Broadcast(this, AbilitySpec);
|
||||
});
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::AbilityInputTagPressed(const FGameplayTag& InputTag)
|
||||
{
|
||||
if (!InputTag.IsValid())
|
||||
return;
|
||||
|
||||
for (FGameplayAbilitySpec& AbilitySpec : GetActivatableAbilities())
|
||||
{
|
||||
if (AbilitySpec.DynamicAbilityTags.HasTagExact(InputTag))
|
||||
{
|
||||
AbilitySpecInputPressed(AbilitySpec);
|
||||
if (AbilitySpec.IsActive())
|
||||
{
|
||||
InvokeReplicatedEvent(EAbilityGenericReplicatedEvent::InputPressed, AbilitySpec.Handle, AbilitySpec.ActivationInfo.GetActivationPredictionKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::AbilityInputTagHeld(const FGameplayTag& InputTag)
|
||||
{
|
||||
if (!InputTag.IsValid())
|
||||
return;
|
||||
|
||||
if (HasMatchingGameplayTag(FAuraGameplayTags::Get().Player_Block_AbilityInput))
|
||||
return;
|
||||
|
||||
for (FGameplayAbilitySpec& AbilitySpec : GetActivatableAbilities())
|
||||
{
|
||||
if (AbilitySpec.DynamicAbilityTags.HasTagExact(InputTag))
|
||||
{
|
||||
if (!AbilitySpec.IsActive())
|
||||
{
|
||||
AbilitySpecInputPressed(AbilitySpec);
|
||||
TryActivateAbility(AbilitySpec.Handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::AbilityInputTagReleased(const FGameplayTag& InputTag)
|
||||
{
|
||||
if (!InputTag.IsValid())
|
||||
return;
|
||||
|
||||
for (FGameplayAbilitySpec& AbilitySpec : GetActivatableAbilities())
|
||||
{
|
||||
if (AbilitySpec.DynamicAbilityTags.HasTagExact(InputTag))
|
||||
{
|
||||
AbilitySpecInputReleased(AbilitySpec);
|
||||
if (AbilitySpec.IsActive())
|
||||
{
|
||||
InvokeReplicatedEvent(EAbilityGenericReplicatedEvent::InputReleased, AbilitySpec.Handle, AbilitySpec.ActivationInfo.GetActivationPredictionKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::ForEachAbilityDelegate(const FForEachAbilityDelegate& Delegate)
|
||||
{
|
||||
FScopedAbilityListLock ActiveScopeLock(*this);
|
||||
for (const FGameplayAbilitySpec& AbilitySpec : GetActivatableAbilities())
|
||||
{
|
||||
Delegate.ExecuteIfBound(AbilitySpec);
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::ForEachAbilityLambda(std::function<void (FGameplayAbilitySpec&)> Func)
|
||||
{
|
||||
FScopedAbilityListLock ActiveScopeLock(*this);
|
||||
for (FGameplayAbilitySpec& AbilitySpec : GetActivatableAbilities())
|
||||
{
|
||||
Func(AbilitySpec);
|
||||
}
|
||||
}
|
||||
|
||||
/** Receiving Effect Interception */
|
||||
FActiveGameplayEffectHandle UAuraAbilitySystemComponent::ApplyGameplayEffectSpecToSelf(const FGameplayEffectSpec& GameplayEffect, FPredictionKey PredictionKey)
|
||||
{
|
||||
for (int32 Index = EffectInterceptors.Num() - 1; Index >= 0; --Index)
|
||||
{
|
||||
if (!IsValid(EffectInterceptors[Index]) || !EffectInterceptors[Index]->Implements<UGameplayEffectInterceptor>())
|
||||
EffectInterceptors.RemoveAt(Index);
|
||||
}
|
||||
|
||||
for (UObject* Interceptor : EffectInterceptors)
|
||||
{
|
||||
bool bIntercepted = false;
|
||||
|
||||
IGameplayEffectInterceptor::Execute_WillApplyGameplayEffectSpec(Interceptor, GameplayEffect, bIntercepted);
|
||||
|
||||
if (bIntercepted)
|
||||
return FActiveGameplayEffectHandle();
|
||||
}
|
||||
|
||||
return Super::ApplyGameplayEffectSpecToSelf(GameplayEffect, PredictionKey);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::AddGameplayEffectInterceptor(UObject* Interceptor)
|
||||
{
|
||||
if (!IsValid(Interceptor) || !Interceptor->Implements<UGameplayEffectInterceptor>())
|
||||
return;
|
||||
|
||||
EffectInterceptors.Add(Interceptor);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::RemoveGameplayEffectInterceptor(UObject* Interceptor)
|
||||
{
|
||||
EffectInterceptors.Remove(Interceptor);
|
||||
}
|
||||
|
||||
|
||||
/** Ability Tags */
|
||||
|
||||
bool UAuraAbilitySystemComponent::AbilityHasIDTag(const UGameplayAbility* Ability)
|
||||
{
|
||||
if (Ability)
|
||||
return Ability->AbilityTags.HasTag(FAuraGameplayTags::Get().Ability_ID);
|
||||
return false;
|
||||
}
|
||||
|
||||
FGameplayTag UAuraAbilitySystemComponent::GetAbilityIDTagFromAbility(const UGameplayAbility* Ability)
|
||||
{
|
||||
if (Ability)
|
||||
{
|
||||
for (FGameplayTag Tag : Ability->AbilityTags)
|
||||
{
|
||||
if (Tag.MatchesTag(FAuraGameplayTags::Get().Ability_ID))
|
||||
{
|
||||
return Tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FGameplayTag::EmptyTag;
|
||||
}
|
||||
|
||||
bool UAuraAbilitySystemComponent::AbilitySpecHasInputTag(const FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
return AbilitySpec.DynamicAbilityTags.HasTag(FAuraGameplayTags::Get().InputTag);
|
||||
}
|
||||
|
||||
FGameplayTag UAuraAbilitySystemComponent::GetInputTagFromAbilitySpec(const FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
for (FGameplayTag Tag : AbilitySpec.DynamicAbilityTags)
|
||||
{
|
||||
if (Tag.MatchesTag(FAuraGameplayTags::Get().InputTag))
|
||||
{
|
||||
return Tag;
|
||||
}
|
||||
}
|
||||
return FGameplayTag::EmptyTag;
|
||||
}
|
||||
|
||||
bool UAuraAbilitySystemComponent::AbilityHasCooldownTag(const UGameplayAbility* Ability)
|
||||
{
|
||||
if (Ability)
|
||||
return Ability->AbilityTags.HasTag(FAuraGameplayTags::Get().Ability_Cooldown);
|
||||
return false;
|
||||
}
|
||||
|
||||
FGameplayTag UAuraAbilitySystemComponent::GetCooldownTagFromAbility(const UGameplayAbility* Ability)
|
||||
{
|
||||
if (Ability)
|
||||
{
|
||||
if (const FGameplayTagContainer* CooldownTags = Ability->GetCooldownTags())
|
||||
{
|
||||
for (FGameplayTag Tag : *CooldownTags)
|
||||
{
|
||||
if (Tag.MatchesTag(FAuraGameplayTags::Get().Ability_Cooldown))
|
||||
{
|
||||
return Tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return FGameplayTag::EmptyTag;
|
||||
}
|
||||
|
||||
bool UAuraAbilitySystemComponent::AbilitySpecHasStatusTag(const FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
return AbilitySpec.DynamicAbilityTags.HasTag(FAuraGameplayTags::Get().Ability_Status);
|
||||
}
|
||||
|
||||
FGameplayTag UAuraAbilitySystemComponent::GetStatusTagFromAbilitySpec(const FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
for (FGameplayTag Tag : AbilitySpec.DynamicAbilityTags)
|
||||
{
|
||||
if (Tag.MatchesTag(FAuraGameplayTags::Get().Ability_Status))
|
||||
{
|
||||
return Tag;
|
||||
}
|
||||
}
|
||||
return FGameplayTag::EmptyTag;
|
||||
}
|
||||
|
||||
bool UAuraAbilitySystemComponent::AbilityHasTypeTag(const UGameplayAbility* Ability)
|
||||
{
|
||||
if (Ability)
|
||||
return Ability->AbilityTags.HasTag(FAuraGameplayTags::Get().Ability_Type);
|
||||
return false;
|
||||
}
|
||||
|
||||
FGameplayTag UAuraAbilitySystemComponent::GetTypeTagFromAbility(const UGameplayAbility* Ability)
|
||||
{
|
||||
if (Ability)
|
||||
{
|
||||
for (FGameplayTag Tag : Ability->AbilityTags)
|
||||
{
|
||||
if (Tag.MatchesTag(FAuraGameplayTags::Get().Ability_Type))
|
||||
{
|
||||
return Tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FGameplayTag::EmptyTag;
|
||||
}
|
||||
|
||||
|
||||
/** End Ability Tags */
|
||||
|
||||
|
||||
/** Attributes Modifications */
|
||||
|
||||
void UAuraAbilitySystemComponent::AddAttributePoints(float Count, const FGameplayTag& AttributeTag)
|
||||
{
|
||||
FGameplayEventData Payload;
|
||||
Payload.EventTag = AttributeTag;
|
||||
Payload.EventMagnitude = Count;
|
||||
UAbilitySystemBlueprintLibrary::SendGameplayEventToActor(GetAvatarActor(), AttributeTag, Payload);
|
||||
}
|
||||
|
||||
|
||||
/** Ability Level */
|
||||
|
||||
void UAuraAbilitySystemComponent::SetLevelForAbilitySpec(FGameplayAbilitySpec& AbilitySpec, int32 NewLevel)
|
||||
{
|
||||
if (AbilitySpec.Level != NewLevel)
|
||||
{
|
||||
AbilitySpec.Level = NewLevel;
|
||||
UpdateStatusTagForAbilitySpec(AbilitySpec);
|
||||
|
||||
ActivateAbilityIfEquippedPassive(AbilitySpec);
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::AddLevelForAbilitySpec(FGameplayAbilitySpec& AbilitySpec, int32 AddLevel)
|
||||
{
|
||||
SetLevelForAbilitySpec(AbilitySpec, AbilitySpec.Level + AddLevel);
|
||||
}
|
||||
|
||||
|
||||
/** Managing Tags */
|
||||
|
||||
FGameplayAbilitySpec* UAuraAbilitySystemComponent::GetAbilitySpecForAbilityIDTag(const FGameplayTag& AbilityIDTag)
|
||||
{
|
||||
FScopedAbilityListLock ActiveScopeLock(*this);
|
||||
for (FGameplayAbilitySpec& AbilitySpec : GetActivatableAbilities())
|
||||
{
|
||||
if (UAuraAbilitySystemComponent::GetAbilityIDTagFromAbility(AbilitySpec.Ability).MatchesTag(AbilityIDTag))
|
||||
{
|
||||
return &AbilitySpec;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::GetAbilitySpecsForInputTag(const FGameplayTag& InputTag, TArray<FGameplayAbilitySpec*>& AbilitySpecs)
|
||||
{
|
||||
FScopedAbilityListLock ActiveScopeLock(*this);
|
||||
for (FGameplayAbilitySpec& AbilitySpec : GetActivatableAbilities())
|
||||
{
|
||||
if (AbilitySpec.DynamicAbilityTags.HasTag(InputTag))
|
||||
{
|
||||
AbilitySpecs.Add(&AbilitySpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Manage Status Tags */
|
||||
|
||||
bool UAuraAbilitySystemComponent::GetStatusTagForAbilityIDTag(const FGameplayTag AbilityIDTag, FGameplayTag& StatusTag)
|
||||
{
|
||||
if (FGameplayAbilitySpec* AbilitySpec = GetAbilitySpecForAbilityIDTag(AbilityIDTag))
|
||||
{
|
||||
FGameplayTag SpecStatusTag = GetStatusTagFromAbilitySpec(*AbilitySpec);
|
||||
if (SpecStatusTag.IsValid())
|
||||
{
|
||||
StatusTag = SpecStatusTag;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** Manage Input Tags */
|
||||
|
||||
void UAuraAbilitySystemComponent::RemoveInputTagFromAbilitySpec(FGameplayAbilitySpec& AbilitySpec, bool bBroadcastUpdate)
|
||||
{
|
||||
if (UAuraAbilitySystemLibrary::RemoveMatchingTagsFromTagContainer(AbilitySpec.DynamicAbilityTags, FAuraGameplayTags::Get().InputTag))
|
||||
{
|
||||
if (AbilitySpec.IsActive())
|
||||
CancelAbilityHandle(AbilitySpec.Handle);
|
||||
|
||||
UpdateStatusTagForAbilitySpec(AbilitySpec, bBroadcastUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::ClearAbilitiesFromInputTag(const FGameplayTag& InputTag)
|
||||
{
|
||||
TArray<FGameplayAbilitySpec*> AbilitySpecs;
|
||||
GetAbilitySpecsForInputTag(InputTag, AbilitySpecs);
|
||||
|
||||
for (FGameplayAbilitySpec* AbilitySpec : AbilitySpecs)
|
||||
{
|
||||
RemoveInputTagFromAbilitySpec(*AbilitySpec);
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::AssignInputTagToAbilitySpec(const FGameplayTag& InputTag, FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
RemoveInputTagFromAbilitySpec(AbilitySpec, false);
|
||||
|
||||
ClearAbilitiesFromInputTag(InputTag);
|
||||
|
||||
AbilitySpec.DynamicAbilityTags.AddTag(InputTag);
|
||||
|
||||
UpdateStatusTagForAbilitySpec(AbilitySpec, true);
|
||||
|
||||
ActivateAbilityIfEquippedPassive(AbilitySpec);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Protected
|
||||
*/
|
||||
|
||||
void UAuraAbilitySystemComponent::UpdateStatusTagForAbilitySpec(FGameplayAbilitySpec& AbilitySpec, bool bBroadcastUpdate)
|
||||
{
|
||||
FGameplayTag StatusTag;
|
||||
if (AbilitySpec.DynamicAbilityTags.HasTag(FAuraGameplayTags::Get().InputTag))
|
||||
StatusTag = FAuraGameplayTags::Get().Ability_Status_Equipped;
|
||||
else if (AbilitySpec.Level > 0)
|
||||
StatusTag = FAuraGameplayTags::Get().Ability_Status_Unlocked;
|
||||
else
|
||||
StatusTag = FAuraGameplayTags::Get().Ability_Status_Eligible;
|
||||
|
||||
SetStatusTagForAbilitySpec(AbilitySpec, StatusTag, bBroadcastUpdate);
|
||||
|
||||
if (bBroadcastUpdate)
|
||||
{
|
||||
const FGameplayTag& AbilityID = GetAbilityIDTagFromAbility(AbilitySpec.Ability);
|
||||
Client_UpdateAbilityStatus(AbilityID, StatusTag, AbilitySpec.Level);
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::SetStatusTagForAbilitySpec(FGameplayAbilitySpec& AbilitySpec, const FGameplayTag& StatusTag, bool bBroadcastUpdate)
|
||||
{
|
||||
UAuraAbilitySystemLibrary::RemoveMatchingTagsFromTagContainer(AbilitySpec.DynamicAbilityTags, FAuraGameplayTags::Get().Ability_Status);
|
||||
AbilitySpec.DynamicAbilityTags.AddTag(StatusTag);
|
||||
MarkAbilitySpecDirty(AbilitySpec);
|
||||
|
||||
if (bBroadcastUpdate && bStartupAbilitiesGiven)
|
||||
OnAbilitySpecChange.Broadcast(this, AbilitySpec);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::ActivateAbilityIfEquippedPassive(FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
bool bIsEquipped = GetStatusTagFromAbilitySpec(AbilitySpec).MatchesTagExact(FAuraGameplayTags::Get().Ability_Status_Equipped);
|
||||
if (!bIsEquipped) return;
|
||||
|
||||
const FGameplayTag AbilityType = GetTypeTagFromAbility(AbilitySpec.Ability);
|
||||
const bool bIsPassiveAbility = AbilityType.MatchesTagExact(FAuraGameplayTags::Get().Ability_Type_Passive);
|
||||
if (!bIsPassiveAbility) return;
|
||||
|
||||
TryActivateAbility(AbilitySpec.Handle);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::OnRep_ActivateAbilities()
|
||||
{
|
||||
Super::OnRep_ActivateAbilities();
|
||||
|
||||
if (!bStartupAbilitiesGiven)
|
||||
{
|
||||
bStartupAbilitiesGiven = true;
|
||||
ForEachAbilityLambda([this](FGameplayAbilitySpec& AbilitySpec) {
|
||||
OnAbilitySpecChange.Broadcast(this, AbilitySpec);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::OnGiveAbility(FGameplayAbilitySpec& Spec)
|
||||
{
|
||||
Super::OnGiveAbility(Spec);
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("OnGiveAbility(%s) [%s]"),
|
||||
*GetAbilityIDTagFromAbility(Spec.Ability).ToString(),
|
||||
*GetInputTagFromAbilitySpec(Spec).ToString()
|
||||
);
|
||||
|
||||
UpdateStatusTagForAbilitySpec(Spec);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::OnRemoveAbility(FGameplayAbilitySpec& Spec)
|
||||
{
|
||||
Super::OnRemoveAbility(Spec);
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("OnRemoveAbility(%s) [%s]"),
|
||||
*GetAbilityIDTagFromAbility(Spec.Ability).ToString(),
|
||||
*GetInputTagFromAbilitySpec(Spec).ToString()
|
||||
);
|
||||
|
||||
if (bStartupAbilitiesGiven)
|
||||
{
|
||||
OnAbilitySpecRemoving.Broadcast(this, Spec);
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::ClientOnEffectApplied_Implementation(UAbilitySystemComponent* ASC, const FGameplayEffectSpec& EffectSpec, FActiveGameplayEffectHandle EffectHandle)
|
||||
{
|
||||
FGameplayTagContainer TagContainer;
|
||||
EffectSpec.GetAllAssetTags(TagContainer);
|
||||
|
||||
OnEffectAssetTags.Broadcast(TagContainer);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemComponent::Client_UpdateAbilityStatus_Implementation(const FGameplayTag& AbilityID, const FGameplayTag& Status, int32 Level)
|
||||
{
|
||||
FGameplayAbilitySpec* AbilitySpec = GetAbilitySpecForAbilityIDTag(AbilityID);
|
||||
if (!AbilitySpec) return;
|
||||
|
||||
AbilitySpec->Level = Level;
|
||||
SetStatusTagForAbilitySpec(*AbilitySpec, Status);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/AuraAbilitySystemGlobals.h"
|
||||
#include "AbilitySystem/AbilitySystemTypes.h"
|
||||
|
||||
FGameplayEffectContext* UAuraAbilitySystemGlobals::AllocGameplayEffectContext() const
|
||||
{
|
||||
return new FAuraGameplayEffectContext();
|
||||
}
|
||||
295
Source/Aura/Private/AbilitySystem/AuraAbilitySystemLibrary.cpp
Normal file
295
Source/Aura/Private/AbilitySystem/AuraAbilitySystemLibrary.cpp
Normal file
@@ -0,0 +1,295 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/AuraAbilitySystemLibrary.h"
|
||||
#include "AbilitySystem/Abilities/AuraDamageGameplayAbility.h"
|
||||
#include "AuraGameplayTags.h"
|
||||
#include "GameplayEffect.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
#include "Player/AuraPlayerController.h"
|
||||
#include "Player/AuraPlayerState.h"
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
|
||||
const TArray<FGameplayTag>& UAuraAbilitySystemLibrary::GetAllDamageTags()
|
||||
{
|
||||
return FAuraGameplayTags::Get().DamageTypes;
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::GetResistanceTagForDamageTag(FGameplayTag DamageTag, FGameplayTag& ResistanceTag, bool& bFound)
|
||||
{
|
||||
if (const FGameplayTag* Ptr = FAuraGameplayTags::Get().DamageResistanceMap.Find(DamageTag))
|
||||
{
|
||||
ResistanceTag = *Ptr;
|
||||
bFound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bFound = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool UAuraAbilitySystemLibrary::IsBlockedHit(const FGameplayEffectContextHandle& EffectContextHandle)
|
||||
{
|
||||
if (const FAuraGameplayEffectContext* AuraEffectContext = static_cast<const FAuraGameplayEffectContext*>(EffectContextHandle.Get()))
|
||||
{
|
||||
return AuraEffectContext->bIsBlockedHit;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::SetIsBlockedHit(FGameplayEffectContextHandle& EffectContextHandle, bool bNewIsBlockedHit)
|
||||
{
|
||||
if (FAuraGameplayEffectContext* AuraEffectContext = static_cast<FAuraGameplayEffectContext*>(EffectContextHandle.Get()))
|
||||
{
|
||||
AuraEffectContext->bIsBlockedHit = bNewIsBlockedHit;
|
||||
}
|
||||
}
|
||||
|
||||
bool UAuraAbilitySystemLibrary::IsCriticalHit(const FGameplayEffectContextHandle& EffectContextHandle)
|
||||
{
|
||||
if (const FAuraGameplayEffectContext* AuraEffectContext = static_cast<const FAuraGameplayEffectContext*>(EffectContextHandle.Get()))
|
||||
{
|
||||
return AuraEffectContext->bIsCriticalHit;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::SetIsCriticalHit(FGameplayEffectContextHandle& EffectContextHandle, bool bNewIsCriticalHit)
|
||||
{
|
||||
if (FAuraGameplayEffectContext* AuraEffectContext = static_cast<FAuraGameplayEffectContext*>(EffectContextHandle.Get()))
|
||||
{
|
||||
AuraEffectContext->bIsCriticalHit = bNewIsCriticalHit;
|
||||
}
|
||||
}
|
||||
|
||||
FVector UAuraAbilitySystemLibrary::GetHitImpulse(const FGameplayEffectContextHandle& EffectContextHandle)
|
||||
{
|
||||
if (const FAuraGameplayEffectContext* AuraEffectContext = static_cast<const FAuraGameplayEffectContext*>(EffectContextHandle.Get()))
|
||||
{
|
||||
return AuraEffectContext->HitImpulse;
|
||||
}
|
||||
return FVector::ZeroVector;
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::SetHitImpulse(FGameplayEffectContextHandle& EffectContextHandle, FVector NewHitImpulse)
|
||||
{
|
||||
if (FAuraGameplayEffectContext* AuraEffectContext = static_cast<FAuraGameplayEffectContext*>(EffectContextHandle.Get()))
|
||||
{
|
||||
AuraEffectContext->HitImpulse = NewHitImpulse;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Attributes */
|
||||
|
||||
|
||||
#define TagDoFunction(AttributeName, CategoryName) \
|
||||
Function.ExecuteIfBound(FAuraGameplayTags::Get().Attributes_##CategoryName##_##AttributeName);
|
||||
|
||||
void UAuraAbilitySystemLibrary::ForEachVitalAttributes(FGameplayTagDelegate Function)
|
||||
{
|
||||
FOREACH_ATTRIBUTE_Vital(TagDoFunction);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::ForEachPrimaryAttributes(FGameplayTagDelegate Function)
|
||||
{
|
||||
FOREACH_ATTRIBUTE_Primary(TagDoFunction);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::ForEachSecondaryAttributes(FGameplayTagDelegate Function)
|
||||
{
|
||||
FOREACH_ATTRIBUTE_Secondary(TagDoFunction);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::ForEachMagicalResistanceAttributes(FGameplayTagDelegate Function)
|
||||
{
|
||||
FOREACH_ATTRIBUTE_MagicalResistance(TagDoFunction);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::ForEachResistanceAttributes(FGameplayTagDelegate Function)
|
||||
{
|
||||
FOREACH_ATTRIBUTE_Resistance(TagDoFunction);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::ForEachMetaAttributes(FGameplayTagDelegate Function)
|
||||
{
|
||||
FOREACH_ATTRIBUTE_Meta(TagDoFunction);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::ForEachReplicatedAttributes(FGameplayTagDelegate Function)
|
||||
{
|
||||
FOREACH_ATTRIBUTE_Replicated(TagDoFunction);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::ForEachStatsAttributes(FGameplayTagDelegate Function)
|
||||
{
|
||||
FOREACH_ATTRIBUTE_Stats(TagDoFunction);
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::ForEachAttributes(FGameplayTagDelegate Function)
|
||||
{
|
||||
FOREACH_ATTRIBUTE_All(TagDoFunction);
|
||||
}
|
||||
|
||||
|
||||
bool UAuraAbilitySystemLibrary::RemoveMatchingTagsFromTagContainer(FGameplayTagContainer& TagContainer, FGameplayTag MatchingTag)
|
||||
{
|
||||
TArray<FGameplayTag> ToRemoveTags;
|
||||
|
||||
for (FGameplayTag Tag : TagContainer)
|
||||
{
|
||||
if (Tag.MatchesTag(MatchingTag))
|
||||
{
|
||||
ToRemoveTags.Add(Tag);
|
||||
}
|
||||
}
|
||||
for (const FGameplayTag& ToRemoveTag : ToRemoveTags)
|
||||
{
|
||||
TagContainer.RemoveTag(ToRemoveTag);
|
||||
}
|
||||
return !ToRemoveTags.IsEmpty();
|
||||
}
|
||||
|
||||
FGameplayTag UAuraAbilitySystemLibrary::GetAbilityIdFromAbilityClass(TSubclassOf<UGameplayAbility> AbilityClass)
|
||||
{
|
||||
return UAuraAbilitySystemComponent::GetAbilityIDTagFromAbility(AbilityClass.GetDefaultObject());
|
||||
}
|
||||
|
||||
FGameplayTag UAuraAbilitySystemLibrary::GetTypeTagFromAbilityClass(TSubclassOf<UGameplayAbility> AbilityClass)
|
||||
{
|
||||
return UAuraAbilitySystemComponent::GetTypeTagFromAbility(AbilityClass.GetDefaultObject());
|
||||
}
|
||||
|
||||
FGameplayTag UAuraAbilitySystemLibrary::GetCooldownTagFromAbilityClass(TSubclassOf<UGameplayAbility> AbilityClass)
|
||||
{
|
||||
return UAuraAbilitySystemComponent::GetCooldownTagFromAbility(AbilityClass.GetDefaultObject());
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::GetAbilityDamagesAtLevel(TSubclassOf<UAuraDamageGameplayAbility> DamageAbilityClass, float Level, TMap<FGameplayTag, float>& Damages)
|
||||
{
|
||||
if (DamageAbilityClass)
|
||||
{
|
||||
UAuraDamageGameplayAbility* DefaultObject = DamageAbilityClass.GetDefaultObject();
|
||||
|
||||
DefaultObject->GetScaledDamages(Damages, Level);
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::GetAbilityCostAtLevel(TSubclassOf<UGameplayAbility> AbilityClass, float Level, TMap<FString, float>& Costs)
|
||||
{
|
||||
if (IsValid(AbilityClass))
|
||||
{
|
||||
UGameplayAbility* DefaultObject = AbilityClass.GetDefaultObject();
|
||||
if (!IsValid(DefaultObject)) return;
|
||||
|
||||
UGameplayEffect* CostEffect = DefaultObject->GetCostGameplayEffect();
|
||||
if (!IsValid(CostEffect)) return;
|
||||
|
||||
for (const FGameplayModifierInfo& Modifier : CostEffect->Modifiers)
|
||||
{
|
||||
float CostMagnitude;
|
||||
Modifier.ModifierMagnitude.GetStaticMagnitudeIfPossible(Level, CostMagnitude);
|
||||
CostMagnitude *= -1;
|
||||
|
||||
FString CostName = Modifier.Attribute.GetName();
|
||||
|
||||
if (float* PreviousValue = Costs.Find(CostName))
|
||||
Costs.Add(CostName, *PreviousValue + CostMagnitude);
|
||||
else
|
||||
Costs.Add(CostName, CostMagnitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float UAuraAbilitySystemLibrary::GetAbilityCooldownTimeAtLevel(TSubclassOf<UGameplayAbility> AbilityClass, float Level)
|
||||
{
|
||||
if (IsValid(AbilityClass))
|
||||
{
|
||||
UGameplayAbility* DefaultObject = AbilityClass.GetDefaultObject();
|
||||
if (!IsValid(DefaultObject)) return 0.0f;
|
||||
|
||||
UGameplayEffect* CooldownEffect = DefaultObject->GetCooldownGameplayEffect();
|
||||
if (!IsValid(CooldownEffect)) return 0.0f;
|
||||
|
||||
float CooldownMagnitude;
|
||||
CooldownEffect->DurationMagnitude.GetStaticMagnitudeIfPossible(Level, CooldownMagnitude);
|
||||
return CooldownMagnitude;
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
||||
/** Extract Infos From Effect Class */
|
||||
|
||||
|
||||
bool UAuraAbilitySystemLibrary::CheckGameplayEffectSpecHasTag(const FGameplayEffectSpec& EffectSpec, FGameplayTag Tag)
|
||||
{
|
||||
FGameplayTagContainer TagContainer;
|
||||
EffectSpec.GetAllAssetTags(TagContainer);
|
||||
return TagContainer.HasTag(Tag);
|
||||
}
|
||||
|
||||
|
||||
void UAuraAbilitySystemLibrary::GetContextFromGameplayEffectSpec(const FGameplayEffectSpec& EffectSpec, FGameplayEffectContextHandle& Context)
|
||||
{
|
||||
Context = EffectSpec.GetContext();
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::ExtractPropertiesFromGameplayEffectContextHandle(const FGameplayEffectContextHandle& Context, FEffectProperties& Props)
|
||||
{
|
||||
Props.EffectContextHandle = Context;
|
||||
Props.SourceASC = Props.EffectContextHandle.GetOriginalInstigatorAbilitySystemComponent();
|
||||
|
||||
if (IsValid(Props.SourceASC) && Props.SourceASC->AbilityActorInfo.IsValid() && Props.SourceASC->AbilityActorInfo->AvatarActor.IsValid())
|
||||
{
|
||||
Props.SourceAvatarActor = Props.SourceASC->AbilityActorInfo->AvatarActor.Get();
|
||||
Props.SourceController = Props.SourceASC->AbilityActorInfo->PlayerController.Get();
|
||||
if (Props.SourceController == nullptr && Props.SourceAvatarActor != nullptr)
|
||||
{
|
||||
if (const APawn* Pawn = Cast<APawn>(Props.SourceAvatarActor))
|
||||
{
|
||||
Props.SourceController = Pawn->GetController();
|
||||
}
|
||||
}
|
||||
if (Props.SourceController)
|
||||
{
|
||||
Props.SourceCharacter = Cast<ACharacter>(Props.SourceController->GetPawn());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FActiveGameplayEffectHandle UAuraAbilitySystemLibrary::ApplyGameplayEffectWithParameters(const FGameplayEffectParameters& EffectParams, UAbilitySystemComponent* SourceASC, UAbilitySystemComponent* TargetASC)
|
||||
{
|
||||
if (!IsValid(EffectParams.Class))
|
||||
return FActiveGameplayEffectHandle();
|
||||
|
||||
if (!IsValid(SourceASC))
|
||||
SourceASC = TargetASC;
|
||||
|
||||
if (!IsValid(TargetASC))
|
||||
return FActiveGameplayEffectHandle();
|
||||
|
||||
FGameplayEffectContextHandle EffectContext = SourceASC->MakeEffectContext();
|
||||
EffectContext.AddSourceObject(SourceASC->GetAvatarActor());
|
||||
|
||||
if (!EffectParams.HitCollision.ImpactPoint.IsZero())
|
||||
EffectContext.AddHitResult(EffectParams.HitCollision);
|
||||
|
||||
if (!EffectParams.HitImpulse.IsZero())
|
||||
SetHitImpulse(EffectContext, EffectParams.HitImpulse);
|
||||
|
||||
if (IsValid(EffectParams.SourceAbility))
|
||||
EffectContext.SetAbility(EffectParams.SourceAbility);
|
||||
|
||||
const FGameplayEffectSpecHandle SpecHandle = SourceASC->MakeOutgoingSpec(EffectParams.Class, EffectParams.Level, EffectContext);
|
||||
|
||||
for (const TPair<FGameplayTag, float>& SetByCallerMagnitude : EffectParams.SetByCallerMagnitudes)
|
||||
{
|
||||
UAbilitySystemBlueprintLibrary::AssignTagSetByCallerMagnitude(SpecHandle, SetByCallerMagnitude.Key, SetByCallerMagnitude.Value);
|
||||
}
|
||||
|
||||
return SourceASC->ApplyGameplayEffectSpecToTarget(*SpecHandle.Data, TargetASC);
|
||||
}
|
||||
180
Source/Aura/Private/AbilitySystem/AuraAttributeSet.cpp
Normal file
180
Source/Aura/Private/AbilitySystem/AuraAttributeSet.cpp
Normal file
@@ -0,0 +1,180 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GameplayEffectExtension.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
#include "AuraGameplayTags.h"
|
||||
#include "Interaction/CombatInterface.h"
|
||||
#include "Interaction/PlayerInterface.h"
|
||||
#include "Player/AuraPlayerController.h"
|
||||
#include "AbilitySystem/AuraAttributeList.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemLibrary.h"
|
||||
#include "AbilitySystem/Components/LevelingExperienceComponent.h"
|
||||
|
||||
UAuraAttributeSet::UAuraAttributeSet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void UAuraAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||
{
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
||||
#define DeclareAttributeReplication(AttributeName, CategoryName) \
|
||||
DOREPLIFETIME_CONDITION_NOTIFY(UAuraAttributeSet, AttributeName, COND_None, REPNOTIFY_Always);
|
||||
|
||||
FOREACH_ATTRIBUTE_Replicated(DeclareAttributeReplication);
|
||||
}
|
||||
|
||||
#define ImplementAttribute_OnRep(AttributeName, CategoryName) \
|
||||
void UAuraAttributeSet::OnRep_##AttributeName(const FGameplayAttributeData& Old##AttributeName) const \
|
||||
{ \
|
||||
GAMEPLAYATTRIBUTE_REPNOTIFY(UAuraAttributeSet, AttributeName, Old##AttributeName); \
|
||||
}
|
||||
|
||||
FOREACH_ATTRIBUTE_Replicated(ImplementAttribute_OnRep)
|
||||
|
||||
void UAuraAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue)
|
||||
{
|
||||
Super::PreAttributeChange(Attribute, NewValue);
|
||||
}
|
||||
|
||||
void UAuraAttributeSet::PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue)
|
||||
{
|
||||
Super::PostAttributeChange(Attribute, OldValue, NewValue);
|
||||
|
||||
if (Attribute == GetMaxHealthAttribute())
|
||||
{
|
||||
float HealthPercent = GetHealth() / OldValue;
|
||||
SetHealth(HealthPercent * NewValue);
|
||||
}
|
||||
if (Attribute == GetMaxManaAttribute())
|
||||
{
|
||||
float ManaPercent = GetMana() / OldValue;
|
||||
SetMana(ManaPercent * NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAttributeSet::PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data)
|
||||
{
|
||||
Super::PostGameplayEffectExecute(Data);
|
||||
|
||||
if (Data.EvaluatedData.Attribute == GetHealthAttribute())
|
||||
{
|
||||
SetHealth(FMath::Clamp(GetHealth(), 0.0f, GetMaxHealth()));
|
||||
}
|
||||
if (Data.EvaluatedData.Attribute == GetManaAttribute())
|
||||
{
|
||||
SetMana(FMath::Clamp(GetMana(), 0.0f, GetMaxMana()));
|
||||
}
|
||||
if (Data.EvaluatedData.Attribute == GetIncomingDamageAttribute())
|
||||
{
|
||||
HandleModificationData_IncomingDamage(Data);
|
||||
}
|
||||
if (Data.EvaluatedData.Attribute == GetIncomingXPAttribute())
|
||||
{
|
||||
HandleModificationData_IncomingXP(Data);
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAttributeSet::HandleModificationData_IncomingDamage(const FGameplayEffectModCallbackData& Data)
|
||||
{
|
||||
FEffectProperties Props;
|
||||
ExtractEffectModProperties(Data, Props);
|
||||
|
||||
const float LocalIncomingDamage = GetIncomingDamage();
|
||||
SetIncomingDamage(0.0f);
|
||||
|
||||
if (LocalIncomingDamage > 0.0f)
|
||||
{
|
||||
const bool Alive = GetHealth() > 0.0f;
|
||||
const float NewHealth = GetHealth() - LocalIncomingDamage;
|
||||
SetHealth(FMath::Clamp(NewHealth, 0, GetMaxHealth()));
|
||||
|
||||
bool bFatal = NewHealth <= 0.0f;
|
||||
|
||||
if (Alive && bFatal)
|
||||
{
|
||||
if (ICombatInterface* CombatInterface = Cast<ICombatInterface>(Props.TargetAvatarActor))
|
||||
{
|
||||
SendXPEvent(Props, ICombatInterface::Execute_GetDeathExperience(Props.TargetAvatarActor));
|
||||
ICombatInterface::Execute_Die(Props.TargetAvatarActor, Data.EffectSpec);
|
||||
CombatInterface->GetOnDeathDelegate().Broadcast(Props.TargetAvatarActor, Data.EffectSpec);
|
||||
}
|
||||
}
|
||||
AAuraPlayerController* SourcePC = IsValid(Props.SourceController) ? Cast<AAuraPlayerController>(Props.SourceController) : nullptr;
|
||||
AAuraPlayerController* TargetPC = IsValid(Props.TargetController) ? Cast<AAuraPlayerController>(Props.TargetController) : nullptr;
|
||||
if (SourcePC || TargetPC)
|
||||
{
|
||||
FFloatingDamage FloatingDamage;
|
||||
FloatingDamage.Target = Props.TargetCharacter;
|
||||
FloatingDamage.Damages = LocalIncomingDamage;
|
||||
FloatingDamage.bIsBlockedHit = UAuraAbilitySystemLibrary::IsBlockedHit(Props.EffectContextHandle);
|
||||
FloatingDamage.bIsCriticalHit = UAuraAbilitySystemLibrary::IsCriticalHit(Props.EffectContextHandle);
|
||||
if (SourcePC)
|
||||
SourcePC->Client_ShowFloatingDamages(FloatingDamage);
|
||||
if (TargetPC)
|
||||
TargetPC->Client_ShowReceivedDamages(FloatingDamage);
|
||||
}
|
||||
|
||||
FGameplayEventData Payload;
|
||||
Payload.EventTag = FAuraGameplayTags::Get().Event_AbilitySystem_DamageApplied;
|
||||
Payload.Instigator = Props.SourceAvatarActor;
|
||||
Payload.Target = Props.TargetAvatarActor;
|
||||
Payload.OptionalObject = Data.EffectSpec.GetContext().GetAbility();
|
||||
Payload.ContextHandle = Props.EffectContextHandle;
|
||||
Payload.EventMagnitude = LocalIncomingDamage;
|
||||
UAbilitySystemBlueprintLibrary::SendGameplayEventToActor(
|
||||
Props.SourceAvatarActor,
|
||||
FAuraGameplayTags::Get().Event_AbilitySystem_DamageApplied,
|
||||
Payload
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void UAuraAttributeSet::HandleModificationData_IncomingXP(const FGameplayEffectModCallbackData& Data)
|
||||
{
|
||||
FEffectProperties Props;
|
||||
ExtractEffectModProperties(Data, Props);
|
||||
|
||||
const float LocalIncomingXP = GetIncomingXP();
|
||||
SetIncomingXP(0.0f);
|
||||
|
||||
if (Props.TargetAvatarActor->Implements<UPlayerInterface>())
|
||||
{
|
||||
if (ULevelingExperienceComponent* LevelingExperience = IPlayerInterface::Execute_GetLevelingExperienceComponent(Props.TargetAvatarActor))
|
||||
{
|
||||
LevelingExperience->AddToExperience(LocalIncomingXP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAttributeSet::SendXPEvent(const FEffectProperties& Props, int32 DeathXp)
|
||||
{
|
||||
FGameplayEventData Payload;
|
||||
|
||||
Payload.EventTag = FAuraGameplayTags::Get().Attributes_Meta_IncomingXP;
|
||||
Payload.EventMagnitude = DeathXp;
|
||||
|
||||
UAbilitySystemBlueprintLibrary::SendGameplayEventToActor(
|
||||
Props.SourceAvatarActor,
|
||||
FAuraGameplayTags::Get().Attributes_Meta_IncomingXP,
|
||||
Payload);
|
||||
}
|
||||
|
||||
void UAuraAttributeSet::ExtractEffectModProperties(const FGameplayEffectModCallbackData& Data, FEffectProperties& Props) const
|
||||
{
|
||||
UAuraAbilitySystemLibrary::ExtractPropertiesFromGameplayEffectContextHandle(Data.EffectSpec.GetContext(), Props);
|
||||
|
||||
if (Data.Target.AbilityActorInfo.IsValid() && Data.Target.AbilityActorInfo->AvatarActor.IsValid())
|
||||
{
|
||||
Props.TargetAvatarActor = Data.Target.AbilityActorInfo->AvatarActor.Get();
|
||||
Props.TargetController = Data.Target.AbilityActorInfo->PlayerController.Get();
|
||||
Props.TargetCharacter = Cast<ACharacter>(Props.TargetAvatarActor);
|
||||
Props.TargetASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(Props.TargetAvatarActor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AbilitySystem/Components/GameplayEffectInterceptor.h"
|
||||
|
||||
// Add default functionality here for any IGameplayEffectInterceptor functions that are not pure virtual.
|
||||
@@ -0,0 +1,127 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AbilitySystem/Components/LevelingExperienceComponent.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
#include "AbilitySystem/Data/LevelingInfo.h"
|
||||
|
||||
ULevelingExperienceComponent::ULevelingExperienceComponent()
|
||||
{
|
||||
PrimaryComponentTick.bCanEverTick = false;
|
||||
SetIsReplicatedByDefault(true);
|
||||
}
|
||||
|
||||
void ULevelingExperienceComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
UpdateLevel(false);
|
||||
}
|
||||
|
||||
void ULevelingExperienceComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||
{
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
||||
DOREPLIFETIME_CONDITION_NOTIFY(ULevelingExperienceComponent, Level, COND_None, REPNOTIFY_Always)
|
||||
DOREPLIFETIME_CONDITION_NOTIFY(ULevelingExperienceComponent, Experience, COND_None, REPNOTIFY_Always);
|
||||
}
|
||||
|
||||
void ULevelingExperienceComponent::AddToLevel(int32 AddLevel, bool KeepProgressPercent)
|
||||
{
|
||||
SetLevel(Level + AddLevel, KeepProgressPercent);
|
||||
}
|
||||
|
||||
void ULevelingExperienceComponent::SetLevel(int32 NewLevel, bool KeepProgressPercent)
|
||||
{
|
||||
if (LevelingInfo)
|
||||
{
|
||||
int32 MinExperience, MaxExperience;
|
||||
LevelingInfo->GetExperienceBoundsAtLevel(FMath::Min(NewLevel, LevelingInfo->MaxLevel), MinExperience, MaxExperience);
|
||||
|
||||
int32 TargetXP = KeepProgressPercent ?
|
||||
MinExperience + GetExperienceProgress() * (MaxExperience - MinExperience) :
|
||||
FMath::Clamp(Experience, MinExperience, MaxExperience - 1);
|
||||
|
||||
SetExperience(TargetXP);
|
||||
}
|
||||
else
|
||||
{
|
||||
Level = NewLevel;
|
||||
OnLevelChanged.Broadcast(Level);
|
||||
}
|
||||
}
|
||||
|
||||
void ULevelingExperienceComponent::AddToExperience(int32 AddExperience)
|
||||
{
|
||||
SetExperience(Experience + AddExperience);
|
||||
}
|
||||
|
||||
void ULevelingExperienceComponent::SetExperience(int32 NewExperience)
|
||||
{
|
||||
if (NewExperience != Experience)
|
||||
{
|
||||
bool IsForward = NewExperience > Experience;
|
||||
Experience = NewExperience;
|
||||
UpdateLevel(IsForward);
|
||||
OnExperienceChanged.Broadcast(Experience, GetExperienceProgress());
|
||||
}
|
||||
}
|
||||
|
||||
float ULevelingExperienceComponent::GetExperienceProgress() const
|
||||
{
|
||||
if (LevelingInfo)
|
||||
{
|
||||
int32 MinExperience, MaxExperience;
|
||||
if (CachedLevel == Level)
|
||||
{
|
||||
MinExperience = CachedMinExperience;
|
||||
MaxExperience = CachedMaxExperience;
|
||||
}
|
||||
else
|
||||
LevelingInfo->GetExperienceBoundsAtLevel(Level, MinExperience, MaxExperience);
|
||||
|
||||
return float(Experience - MinExperience) / float(MaxExperience - MinExperience);
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void ULevelingExperienceComponent::UpdateLevel(bool ForwardOnly)
|
||||
{
|
||||
if (LevelingInfo)
|
||||
{
|
||||
bool NeedToCheckNewLevel = true;
|
||||
if (Level == CachedLevel && ForwardOnly && Experience < CachedMaxExperience)
|
||||
NeedToCheckNewLevel = false;
|
||||
|
||||
if (NeedToCheckNewLevel)
|
||||
{
|
||||
int32 NewLevel = LevelingInfo->FindLevelForXP(Experience, ForwardOnly ? Level : 0);
|
||||
if (Level != NewLevel)
|
||||
{
|
||||
Level = NewLevel;
|
||||
UpdateCacheLevel();
|
||||
OnLevelChanged.Broadcast(Level);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ULevelingExperienceComponent::OnRep_Level(int32 OldLevel) const
|
||||
{
|
||||
if (Level != OldLevel)
|
||||
OnLevelChanged.Broadcast(Level);
|
||||
}
|
||||
|
||||
void ULevelingExperienceComponent::OnRep_Experience(int32 OldExperience) const
|
||||
{
|
||||
OnExperienceChanged.Broadcast(Experience, GetExperienceProgress());
|
||||
}
|
||||
|
||||
void ULevelingExperienceComponent::UpdateCacheLevel()
|
||||
{
|
||||
if (LevelingInfo)
|
||||
{
|
||||
CachedLevel = Level;
|
||||
LevelingInfo->GetExperienceBoundsAtLevel(CachedLevel, CachedMinExperience, CachedMaxExperience);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AbilitySystem/Components/PerkPointsComponent.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
|
||||
UPerkPointsComponent::UPerkPointsComponent()
|
||||
{
|
||||
PrimaryComponentTick.bCanEverTick = false;
|
||||
SetIsReplicatedByDefault(true);
|
||||
}
|
||||
|
||||
void UPerkPointsComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||
{
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
||||
DOREPLIFETIME_CONDITION_NOTIFY(UPerkPointsComponent, AttributePoints, COND_OwnerOnly, REPNOTIFY_OnChanged)
|
||||
DOREPLIFETIME_CONDITION_NOTIFY(UPerkPointsComponent, AbilityPoints, COND_OwnerOnly, REPNOTIFY_OnChanged)
|
||||
}
|
||||
|
||||
|
||||
/** Attribute Points */
|
||||
|
||||
void UPerkPointsComponent::AddToAttributePoints(int32 AddingPoints)
|
||||
{
|
||||
SetAttributePoints(AttributePoints + AddingPoints);
|
||||
}
|
||||
|
||||
int32 UPerkPointsComponent::SpendAttributePoints(int32 Count)
|
||||
{
|
||||
int32 SpentCount = FMath::Min(Count, AttributePoints);
|
||||
|
||||
if (SpentCount)
|
||||
{
|
||||
AddToAttributePoints(-SpentCount);
|
||||
}
|
||||
return SpentCount;
|
||||
}
|
||||
|
||||
void UPerkPointsComponent::SetAttributePoints(int32 NewPoints)
|
||||
{
|
||||
if (AttributePoints != NewPoints)
|
||||
{
|
||||
AttributePoints = NewPoints;
|
||||
OnAttributePointsChangedDelegate.Broadcast(AttributePoints);
|
||||
}
|
||||
}
|
||||
|
||||
void UPerkPointsComponent::OnRep_AttributePoints(int32 OldAttributePoints) const
|
||||
{
|
||||
OnAttributePointsChangedDelegate.Broadcast(AttributePoints);
|
||||
}
|
||||
|
||||
|
||||
/** Skill Points */
|
||||
|
||||
void UPerkPointsComponent::AddToAbilityPoints(int32 AddingPoints)
|
||||
{
|
||||
SetAbilityPoints(AbilityPoints + AddingPoints);
|
||||
}
|
||||
|
||||
int32 UPerkPointsComponent::SpendAbilityPoints(int32 Count)
|
||||
{
|
||||
int32 SpentCount = FMath::Min(Count, AbilityPoints);
|
||||
|
||||
if (SpentCount)
|
||||
{
|
||||
AddToAbilityPoints(-SpentCount);
|
||||
}
|
||||
return SpentCount;
|
||||
}
|
||||
|
||||
void UPerkPointsComponent::SetAbilityPoints(int32 NewPoints)
|
||||
{
|
||||
if (AbilityPoints != NewPoints)
|
||||
{
|
||||
AbilityPoints = NewPoints;
|
||||
OnAbilityPointsChangedDelegate.Broadcast(AbilityPoints);
|
||||
}
|
||||
}
|
||||
|
||||
void UPerkPointsComponent::OnRep_AbilityPoints(int32 OldAbilityPoints) const
|
||||
{
|
||||
OnAbilityPointsChangedDelegate.Broadcast(AbilityPoints);
|
||||
}
|
||||
36
Source/Aura/Private/AbilitySystem/Data/AbilityBook.cpp
Normal file
36
Source/Aura/Private/AbilitySystem/Data/AbilityBook.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AbilitySystem/Data/AbilityBook.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
|
||||
const TMap<FGameplayTag, FAuraAbilityInfo>& UAbilityBook::GetAbilities()
|
||||
{
|
||||
if (!DictionaryInitialized)
|
||||
{
|
||||
for (FAuraAbilityInfo& AbilityInfo : AllAbilities)
|
||||
{
|
||||
FGameplayTag AbilityID = UAuraAbilitySystemComponent::GetAbilityIDTagFromAbility(AbilityInfo.Ability.GetDefaultObject());
|
||||
Abilities.Add(AbilityID, AbilityInfo);
|
||||
}
|
||||
DictionaryInitialized = true;
|
||||
}
|
||||
return Abilities;
|
||||
}
|
||||
|
||||
const FAuraAbilityRequirement* UAbilityBook::GetRequirementsForAbilityLevel(FGameplayTag AbilityID, int32 Level)
|
||||
{
|
||||
// Level 1 = RequirementsForLevels[0]
|
||||
// Level 2 = RequirementsForLevels[1]
|
||||
if (const FAuraAbilityInfo* AbilityInfo = GetAbilities().Find(AbilityID))
|
||||
{
|
||||
int32 LevelIndex = Level - 1;
|
||||
if (LevelIndex >= 0 && LevelIndex < AbilityInfo->RequirementsForLevels.Num())
|
||||
{
|
||||
const FAuraAbilityRequirement* RequirementPtr = &(AbilityInfo->RequirementsForLevels[LevelIndex]);
|
||||
|
||||
return RequirementPtr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
20
Source/Aura/Private/AbilitySystem/Data/AttributeInfo.cpp
Normal file
20
Source/Aura/Private/AbilitySystem/Data/AttributeInfo.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/Data/AttributeInfo.h"
|
||||
|
||||
FAuraAttributeInfo UAttributeInfo::FindAttributeInfoForTag(const FGameplayTag& AttributeTag, bool bLogNotFound) const
|
||||
{
|
||||
for (const FAuraAttributeInfo& Info : AttributeInformation)
|
||||
{
|
||||
if (Info.AttributeTag.MatchesTagExact(AttributeTag))
|
||||
return Info;
|
||||
}
|
||||
|
||||
if (bLogNotFound)
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("Can't find attribute info for tag [%s]"), *AttributeTag.ToString());
|
||||
}
|
||||
|
||||
return FAuraAttributeInfo();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/Data/CharacterClassInfo.h"
|
||||
|
||||
5
Source/Aura/Private/AbilitySystem/Data/EffectInfo.cpp
Normal file
5
Source/Aura/Private/AbilitySystem/Data/EffectInfo.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AbilitySystem/Data/EffectInfo.h"
|
||||
|
||||
34
Source/Aura/Private/AbilitySystem/Data/LevelingInfo.cpp
Normal file
34
Source/Aura/Private/AbilitySystem/Data/LevelingInfo.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AbilitySystem/Data/LevelingInfo.h"
|
||||
|
||||
int32 ULevelingInfo::FindLevelForXP(int32 ExperiencePoints, int32 MinLevel) const
|
||||
{
|
||||
int32 Level = MinLevel;
|
||||
|
||||
while (Level < MaxLevel)
|
||||
{
|
||||
int32 RequiredExperience = static_cast<int32>(ExperienceCurve.GetValueAtLevel(Level + 1));
|
||||
if (ExperiencePoints < RequiredExperience)
|
||||
{
|
||||
break;
|
||||
}
|
||||
++Level;
|
||||
}
|
||||
return Level;
|
||||
}
|
||||
|
||||
void ULevelingInfo::GetExperienceBoundsAtLevel(int32 Level, int32& MinExperience, int32& MaxExperience) const
|
||||
{
|
||||
if (Level >= MaxLevel)
|
||||
{
|
||||
MinExperience = static_cast<int32>(ExperienceCurve.GetValueAtLevel(MaxLevel));
|
||||
MaxExperience = MinExperience + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
MinExperience = static_cast<int32>(ExperienceCurve.GetValueAtLevel(Level));
|
||||
MaxExperience = static_cast<int32>(ExperienceCurve.GetValueAtLevel(Level + 1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/EffectCalculation/ExecCalc_AttributeBased.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
|
||||
void UExecCalc_AttributeBased::GetCapturedAttributesMagnitudes(const FGameplayEffectCustomExecutionParameters& ExecutionParams, TArray<float>& Attributes) const
|
||||
{
|
||||
const FGameplayEffectSpec& EffectSpec = ExecutionParams.GetOwningSpec();
|
||||
|
||||
const FGameplayTagContainer* SourceTag = EffectSpec.CapturedSourceTags.GetAggregatedTags();
|
||||
const FGameplayTagContainer* TargetTag = EffectSpec.CapturedTargetTags.GetAggregatedTags();
|
||||
|
||||
FAggregatorEvaluateParameters EvaluationParameters;
|
||||
EvaluationParameters.SourceTags = SourceTag;
|
||||
EvaluationParameters.TargetTags = TargetTag;
|
||||
|
||||
for (FGameplayEffectAttributeCaptureDefinition AttributeCaptureDefinition : RelevantAttributesToCapture)
|
||||
{
|
||||
float AttributeValue = 0.0f;
|
||||
ExecutionParams.AttemptCalculateCapturedAttributeMagnitude(AttributeCaptureDefinition, EvaluationParameters, AttributeValue);
|
||||
Attributes.Add(AttributeValue);
|
||||
}
|
||||
}
|
||||
|
||||
void UExecCalc_AttributeBased::AddExecutionOutputs(const TArray<FGameplayModifierEvaluatedData>& EvaluatedDatas, FGameplayEffectCustomExecutionOutput& OutExecutionOutput) const
|
||||
{
|
||||
for (const FGameplayModifierEvaluatedData& EvaluatedData : EvaluatedDatas)
|
||||
{
|
||||
OutExecutionOutput.AddOutputModifier(EvaluatedData);
|
||||
}
|
||||
}
|
||||
|
||||
void UExecCalc_AttributeBased::GetContext(const FGameplayEffectCustomExecutionParameters& ExecutionParams, FGameplayEffectContextHandle& Context) const
|
||||
{
|
||||
Context = ExecutionParams.GetOwningSpec().GetContext();
|
||||
}
|
||||
|
||||
float UExecCalc_AttributeBased::GetSetByCallerTagMagnitude(const FGameplayEffectCustomExecutionParameters& ExecutionParams, FGameplayTag DataTag, bool WarnIfNotFound, float Default) const
|
||||
{
|
||||
return ExecutionParams.GetOwningSpec().GetSetByCallerMagnitude(DataTag, WarnIfNotFound, Default);
|
||||
}
|
||||
|
||||
const TMap<FGameplayTag, float>& UExecCalc_AttributeBased::GetSetByCallerTagMagnitudes(const FGameplayEffectCustomExecutionParameters& ExecutionParams) const
|
||||
{
|
||||
return ExecutionParams.GetOwningSpec().SetByCallerTagMagnitudes;
|
||||
}
|
||||
|
||||
FGameplayModifierEvaluatedData UExecCalc_AttributeBased::MakeModifierEvaluatedData_IncomingDamage(EGameplayModOp::Type Operation, float Value) const
|
||||
{
|
||||
return FGameplayModifierEvaluatedData(UAuraAttributeSet::GetIncomingDamageAttribute(), Operation, Value);
|
||||
}
|
||||
|
||||
// #define MakeModifierImpl(AttributeName, CategoryName) \
|
||||
// FGameplayModifierEvaluatedData UExecCalc_AttributeBased::MakeModifierEvaluatedData_##AttributeName(EGameplayModOp::Type Operation, float Value) const \
|
||||
// { \
|
||||
// return FGameplayModifierEvaluatedData(UAuraAttributeSet::Get##AttributeName##Attribute(), Operation, Value); \
|
||||
// } \
|
||||
|
||||
// FOREACH_ATTRIBUTE_All(MakeModifierImpl)
|
||||
@@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/EffectCalculation/MMC_AttributeBased.h"
|
||||
|
||||
|
||||
void UMMC_AttributeBased::GetCapturedAttributesMagnitudes(const FGameplayEffectSpec& EffectSpec, TArray<float>& Attributes) const
|
||||
{
|
||||
const FGameplayTagContainer* SourceTag = EffectSpec.CapturedSourceTags.GetAggregatedTags();
|
||||
const FGameplayTagContainer* TargetTag = EffectSpec.CapturedTargetTags.GetAggregatedTags();
|
||||
|
||||
FAggregatorEvaluateParameters EvaluationParameters;
|
||||
EvaluationParameters.SourceTags = SourceTag;
|
||||
EvaluationParameters.TargetTags = TargetTag;
|
||||
|
||||
for (FGameplayEffectAttributeCaptureDefinition AttributeCaptureDefinition : RelevantAttributesToCapture)
|
||||
{
|
||||
float AttributeValue = 0.0f;
|
||||
GetCapturedAttributeMagnitude(AttributeCaptureDefinition, EffectSpec, EvaluationParameters, AttributeValue);
|
||||
Attributes.Add(AttributeValue);
|
||||
}
|
||||
}
|
||||
|
||||
void UMMC_AttributeBased::GetContext(const FGameplayEffectSpec& EffectSpec, FGameplayEffectContextHandle& Context) const
|
||||
{
|
||||
Context = EffectSpec.GetContext();
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AbilitySystem/Tasks/TargetDataUnderMouse.h"
|
||||
#include "Player/AuraPlayerController.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
|
||||
UTargetDataUnderMouse* UTargetDataUnderMouse::CreateTargetDataUnderMouse(UGameplayAbility* OwningAbility)
|
||||
{
|
||||
UTargetDataUnderMouse* MyObj = NewAbilityTask<UTargetDataUnderMouse>(OwningAbility);
|
||||
|
||||
return MyObj;
|
||||
}
|
||||
|
||||
void UTargetDataUnderMouse::Activate()
|
||||
{
|
||||
const bool bIsLocallyControlled = Ability->GetCurrentActorInfo()->IsLocallyControlled();
|
||||
|
||||
if (bIsLocallyControlled)
|
||||
{
|
||||
SendMouseCursorData();
|
||||
}
|
||||
else
|
||||
{
|
||||
FGameplayAbilitySpecHandle SpecHandle = GetAbilitySpecHandle();
|
||||
FPredictionKey ActivationKey = GetActivationPredictionKey();
|
||||
UAbilitySystemComponent *ASC = AbilitySystemComponent.Get();
|
||||
ASC->AbilityTargetDataSetDelegate(SpecHandle, ActivationKey).AddLambda([this, SpecHandle, ActivationKey](const FGameplayAbilityTargetDataHandle& DataHandle, FGameplayTag ActivationTag) {
|
||||
AbilitySystemComponent->ConsumeAllReplicatedData(SpecHandle, ActivationKey);
|
||||
if (ShouldBroadcastAbilityTaskDelegates())
|
||||
{
|
||||
ValidData.Broadcast(DataHandle);
|
||||
}
|
||||
});
|
||||
if (!ASC->CallReplicatedTargetDataDelegatesIfSet(SpecHandle, ActivationKey))
|
||||
{
|
||||
SetWaitingOnRemotePlayerData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UTargetDataUnderMouse::SendMouseCursorData()
|
||||
{
|
||||
FScopedPredictionWindow ScopedPrediction(AbilitySystemComponent.Get());
|
||||
|
||||
APlayerController* PC = Ability->GetCurrentActorInfo()->PlayerController.Get();
|
||||
|
||||
if (!PC)
|
||||
{
|
||||
if (ShouldBroadcastAbilityTaskDelegates())
|
||||
NoData.Broadcast();
|
||||
return;
|
||||
}
|
||||
|
||||
FHitResult Hit;
|
||||
if (AAuraPlayerController* AuraPC = Cast<AAuraPlayerController>(PC))
|
||||
Hit = AuraPC->GetCursorHit();
|
||||
else
|
||||
PC->GetHitResultUnderCursor(ECC_Visibility, false, Hit);
|
||||
|
||||
FGameplayAbilityTargetDataHandle DataHandle;
|
||||
FGameplayAbilityTargetData_SingleTargetHit* Data = new FGameplayAbilityTargetData_SingleTargetHit();
|
||||
Data->HitResult = Hit;
|
||||
|
||||
DataHandle.Add(Data);
|
||||
AbilitySystemComponent->ServerSetReplicatedTargetData(
|
||||
GetAbilitySpecHandle(),
|
||||
GetActivationPredictionKey(),
|
||||
DataHandle,
|
||||
FGameplayTag(),
|
||||
AbilitySystemComponent->ScopedPredictionKey
|
||||
);
|
||||
|
||||
if (ShouldBroadcastAbilityTaskDelegates())
|
||||
ValidData.Broadcast(DataHandle);
|
||||
}
|
||||
89
Source/Aura/Private/Actor/AuraEffectActor.cpp
Normal file
89
Source/Aura/Private/Actor/AuraEffectActor.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Actor/AuraEffectActor.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemLibrary.h"
|
||||
|
||||
AAuraEffectActor::AAuraEffectActor()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AAuraEffectActor::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
bool AAuraEffectActor::ApplyEffectToActor(AActor* Actor)
|
||||
{
|
||||
UAbilitySystemComponent* ASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(Actor);
|
||||
|
||||
return ApplyEffectToAbilitySystemComponent(ASC);
|
||||
}
|
||||
|
||||
bool AAuraEffectActor::ApplyEffectToAbilitySystemComponent(UAbilitySystemComponent* ASC)
|
||||
{
|
||||
if (!IsValid(ASC))
|
||||
return false;
|
||||
|
||||
bool bEffectApplied = false;
|
||||
|
||||
for (FGameplayEffectParameters Effect : Effects)
|
||||
{
|
||||
if (!IsValid(Effect.Class))
|
||||
continue;
|
||||
|
||||
FActiveGameplayEffectHandle ActiveEffectHandle = UAuraAbilitySystemLibrary::ApplyGameplayEffectWithParameters(Effect, nullptr, ASC);
|
||||
|
||||
bool bIsInstant = Effect.Class->GetDefaultObject<UGameplayEffect>()->DurationPolicy == EGameplayEffectDurationType::Instant;
|
||||
|
||||
if (!bIsInstant)
|
||||
{
|
||||
if (ActiveEffectHandles.Contains(ASC))
|
||||
{
|
||||
ActiveEffectHandles[ASC].Handles.Add(ActiveEffectHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
FEffectHandleArray HandleArray;
|
||||
HandleArray.Handles.Add(ActiveEffectHandle);
|
||||
ActiveEffectHandles.Add(ASC, HandleArray);
|
||||
}
|
||||
}
|
||||
bEffectApplied = true;
|
||||
}
|
||||
|
||||
return bEffectApplied;
|
||||
}
|
||||
|
||||
bool AAuraEffectActor::RemoveEffectFromActor(AActor* Actor)
|
||||
{
|
||||
UAbilitySystemComponent* ASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(Actor);
|
||||
|
||||
return RemoveEffectFromAbilitySystemComponent(ASC);
|
||||
}
|
||||
|
||||
bool AAuraEffectActor::RemoveEffectFromAbilitySystemComponent(UAbilitySystemComponent* ASC)
|
||||
{
|
||||
if (!IsValid(ASC))
|
||||
return false;
|
||||
|
||||
bool bRemovedEffect = false;
|
||||
|
||||
FEffectHandleArray ActiveHandles;
|
||||
if (ActiveEffectHandles.RemoveAndCopyValue(ASC, ActiveHandles))
|
||||
{
|
||||
for (FActiveGameplayEffectHandle Handle : ActiveHandles.Handles)
|
||||
{
|
||||
bRemovedEffect |= ASC->RemoveActiveGameplayEffect(Handle, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return bRemovedEffect;
|
||||
}
|
||||
104
Source/Aura/Private/Actor/AuraProjectile.cpp
Normal file
104
Source/Aura/Private/Actor/AuraProjectile.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Actor/AuraProjectile.h"
|
||||
#include "Components/SphereComponent.h"
|
||||
#include "GameFramework/ProjectileMovementComponent.h"
|
||||
#include "Components/ArrowComponent.h"
|
||||
#include "Aura/Aura.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
#include "AuraBlueprintFunctionLibrary.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemLibrary.h"
|
||||
|
||||
AAuraProjectile::AAuraProjectile()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
bReplicates = true;
|
||||
|
||||
InitialLifeSpan = 5.0f;
|
||||
|
||||
Sphere = CreateDefaultSubobject<USphereComponent>("Sphere");
|
||||
SetRootComponent(Sphere);
|
||||
|
||||
Sphere->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
||||
Sphere->SetCollisionObjectType(ECC_Projectile);
|
||||
Sphere->SetCollisionResponseToAllChannels(ECR_Ignore);
|
||||
Sphere->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
||||
Sphere->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
||||
Sphere->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
||||
|
||||
ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>("ProjectileMovement");
|
||||
ProjectileMovement->InitialSpeed = 550.0f;
|
||||
ProjectileMovement->MaxSpeed = 550.0f;
|
||||
ProjectileMovement->ProjectileGravityScale = 0.0f;
|
||||
|
||||
ArrowComponent = CreateDefaultSubobject<UArrowComponent>("Arrow");
|
||||
ArrowComponent->SetupAttachment(GetRootComponent());
|
||||
}
|
||||
|
||||
void AAuraProjectile::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
if (HasAuthority())
|
||||
Sphere->OnComponentBeginOverlap.AddDynamic(this, &AAuraProjectile::OnSphereOverlap);
|
||||
}
|
||||
|
||||
bool AAuraProjectile::ShouldImpact_Implementation(const FHitResult& HitResult)
|
||||
{
|
||||
if (IsValid(HitResult.GetActor()) && IsValid(GetInstigator()))
|
||||
{
|
||||
return UAuraBlueprintFunctionLibrary::AreActorsEnemies(HitResult.GetActor(), GetInstigator());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AAuraProjectile::Impact_Implementation(const FHitResult& HitResult)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AAuraProjectile::Overlapped_Implementation(const FHitResult& HitResult)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AAuraProjectile::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& HitResult)
|
||||
{
|
||||
AActor* HitActor = HitResult.GetActor();
|
||||
if (ShouldImpact(HitResult))
|
||||
{
|
||||
if (HitActor && HitActor->GetClass()->ImplementsInterface(UProjectileReactionInterface::StaticClass()))
|
||||
IProjectileReactionInterface::Execute_ImpactedByProjectile(HitResult.GetActor(), this, HitResult);
|
||||
OnImpact.Broadcast(this, HitResult);
|
||||
Impact(HitResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HitActor && HitActor->GetClass()->ImplementsInterface(UProjectileReactionInterface::StaticClass()))
|
||||
IProjectileReactionInterface::Execute_OverlappedByProjectile(HitResult.GetActor(), this, HitResult);
|
||||
Overlapped(HitResult);
|
||||
}
|
||||
}
|
||||
|
||||
TArray<FActiveGameplayEffectHandle> AAuraProjectile::ApplyEffects(UAbilitySystemComponent* TargetASC, const FHitResult& Collision) const
|
||||
{
|
||||
TArray<FActiveGameplayEffectHandle> EffectHandles;
|
||||
|
||||
if (!(HasAuthority() && IsValid(TargetASC)))
|
||||
return EffectHandles;
|
||||
|
||||
UAbilitySystemComponent* SourceASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(GetInstigator());
|
||||
|
||||
for (const FGameplayEffectParameters& Effect : AppliedEffects)
|
||||
{
|
||||
FGameplayEffectParameters CollidingEffect = Effect;
|
||||
CollidingEffect.HitImpulse = GetVelocity();
|
||||
CollidingEffect.HitCollision = Collision;
|
||||
CollidingEffect.SourceAbility = InstigatorAbility;
|
||||
EffectHandles.Add(UAuraAbilitySystemLibrary::ApplyGameplayEffectWithParameters(CollidingEffect, SourceASC, TargetASC));
|
||||
}
|
||||
|
||||
return EffectHandles;
|
||||
}
|
||||
90
Source/Aura/Private/AsyncTask/InspectCooldownTask.cpp
Normal file
90
Source/Aura/Private/AsyncTask/InspectCooldownTask.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AsyncTask/InspectCooldownTask.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
|
||||
UInspectCooldownTask* UInspectCooldownTask::InspectCooldown(UAbilitySystemComponent* AbilitySystemComponent, FGameplayTag InCooldownTag)
|
||||
{
|
||||
UInspectCooldownTask *NewTask = NewObject<UInspectCooldownTask>();
|
||||
NewTask->ASC = AbilitySystemComponent;
|
||||
NewTask->CooldownTag = InCooldownTag;
|
||||
|
||||
if (!IsValid(AbilitySystemComponent) || !InCooldownTag.IsValid())
|
||||
{
|
||||
NewTask->EndTask();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AbilitySystemComponent->RegisterGameplayTagEvent(InCooldownTag, EGameplayTagEventType::NewOrRemoved)
|
||||
.AddUObject(NewTask, &UInspectCooldownTask::CooldownTagChanged);
|
||||
|
||||
AbilitySystemComponent->OnActiveGameplayEffectAddedDelegateToSelf
|
||||
.AddUObject(NewTask, &UInspectCooldownTask::OnActiveEffectAdded);
|
||||
|
||||
return NewTask;
|
||||
}
|
||||
|
||||
void UInspectCooldownTask::EndTask()
|
||||
{
|
||||
if (!IsValid(ASC)) return;
|
||||
|
||||
ASC->RegisterGameplayTagEvent(CooldownTag, EGameplayTagEventType::NewOrRemoved)
|
||||
.RemoveAll(this);
|
||||
|
||||
SetReadyToDestroy();
|
||||
MarkAsGarbage();
|
||||
}
|
||||
|
||||
void UInspectCooldownTask::CooldownTagChanged(const FGameplayTag ChangedTag, int32 NewCount)
|
||||
{
|
||||
if (NewCount == 0)
|
||||
{
|
||||
CooldownEnd.Broadcast(0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void UInspectCooldownTask::OnActiveEffectAdded(UAbilitySystemComponent* TargetASC, const FGameplayEffectSpec& SpecApplied, FActiveGameplayEffectHandle ActiveEffectHandle)
|
||||
{
|
||||
if (EffectHasCooldownTag(SpecApplied))
|
||||
{
|
||||
BroadcastEffectCooldownTime();
|
||||
}
|
||||
}
|
||||
|
||||
bool UInspectCooldownTask::EffectHasCooldownTag(const FGameplayEffectSpec& EffectSpec)
|
||||
{
|
||||
FGameplayTagContainer GrantedTags;
|
||||
EffectSpec.GetAllGrantedTags(GrantedTags);
|
||||
|
||||
if (GrantedTags.HasTagExact(CooldownTag))
|
||||
return true;
|
||||
|
||||
FGameplayTagContainer AssetTags;
|
||||
EffectSpec.GetAllAssetTags(AssetTags);
|
||||
|
||||
if (AssetTags.HasTagExact(CooldownTag))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void UInspectCooldownTask::BroadcastEffectCooldownTime()
|
||||
{
|
||||
FGameplayEffectQuery GameplayEffectQuery = FGameplayEffectQuery::MakeQuery_MatchAnyOwningTags(CooldownTag.GetSingleTagContainer());
|
||||
TArray<TPair<float,float>> TimesRemaining = ASC->GetActiveEffectsTimeRemainingAndDuration(GameplayEffectQuery);
|
||||
|
||||
if (TimesRemaining.Num() > 0)
|
||||
{
|
||||
TPair<float, float> MaxTimeRemaining(0, 0);
|
||||
for (TPair<float, float> TimeRemaining : TimesRemaining)
|
||||
{
|
||||
if (TimeRemaining.Key > MaxTimeRemaining.Key)
|
||||
{
|
||||
MaxTimeRemaining = TimeRemaining;
|
||||
}
|
||||
}
|
||||
|
||||
CooldownStart.Broadcast(MaxTimeRemaining.Key, MaxTimeRemaining.Value);
|
||||
}
|
||||
}
|
||||
20
Source/Aura/Private/AuraAssetManager.cpp
Normal file
20
Source/Aura/Private/AuraAssetManager.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AuraAssetManager.h"
|
||||
#include "AuraGameplayTags.h"
|
||||
#include "AbilitySystemGlobals.h"
|
||||
|
||||
UAuraAssetManager& UAuraAssetManager::Get()
|
||||
{
|
||||
check(GEngine);
|
||||
return *Cast<UAuraAssetManager>(GEngine->AssetManager);
|
||||
}
|
||||
|
||||
void UAuraAssetManager::StartInitialLoading()
|
||||
{
|
||||
Super::StartInitialLoading();
|
||||
|
||||
FAuraGameplayTags::InitializeNativeGameplayTags();
|
||||
UAbilitySystemGlobals::Get().InitGlobalData();
|
||||
}
|
||||
64
Source/Aura/Private/AuraBlueprintFunctionLibrary.cpp
Normal file
64
Source/Aura/Private/AuraBlueprintFunctionLibrary.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "AuraBlueprintFunctionLibrary.h"
|
||||
#include "Interaction/CombatInterface.h"
|
||||
|
||||
void UAuraBlueprintFunctionLibrary::RegisterComponent(UActorComponent* Component)
|
||||
{
|
||||
if (Component)
|
||||
{
|
||||
Component->RegisterComponent();
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraBlueprintFunctionLibrary::UnregisterComponent(UActorComponent* Component)
|
||||
{
|
||||
if (Component)
|
||||
{
|
||||
Component->UnregisterComponent();
|
||||
Component->DestroyComponent();
|
||||
}
|
||||
}
|
||||
|
||||
bool UAuraBlueprintFunctionLibrary::AreActorsEnemies(AActor* FirstActor, AActor* SecondActor)
|
||||
{
|
||||
if (!IsValid(FirstActor) || !IsValid(SecondActor))
|
||||
return false;
|
||||
|
||||
if (FirstActor->ActorHasTag("Player"))
|
||||
{
|
||||
return SecondActor->ActorHasTag("Enemy");
|
||||
}
|
||||
else if (SecondActor->ActorHasTag("Player"))
|
||||
{
|
||||
return FirstActor->ActorHasTag("Enemy");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UAuraBlueprintFunctionLibrary::AddOnDeathCallback(UObject* CombatInterfaceObject, FOnDeathDelegateSignature Callback)
|
||||
{
|
||||
if (IsValid(CombatInterfaceObject))
|
||||
{
|
||||
if (ICombatInterface* CI = Cast<ICombatInterface>(CombatInterfaceObject))
|
||||
{
|
||||
FOnDeathBroadcastSignature& OnDeath = CI->GetOnDeathDelegate();
|
||||
|
||||
OnDeath.Add(Callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraBlueprintFunctionLibrary::RemoveOnDeathCallback(UObject* CombatInterfaceObject, FOnDeathDelegateSignature Callback)
|
||||
{
|
||||
if (IsValid(CombatInterfaceObject))
|
||||
{
|
||||
if (ICombatInterface* CI = Cast<ICombatInterface>(CombatInterfaceObject))
|
||||
{
|
||||
FOnDeathBroadcastSignature& OnDeath = CI->GetOnDeathDelegate();
|
||||
|
||||
OnDeath.Remove(Callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
305
Source/Aura/Private/AuraGameplayTags.cpp
Normal file
305
Source/Aura/Private/AuraGameplayTags.cpp
Normal file
@@ -0,0 +1,305 @@
|
||||
|
||||
#include "AuraGameplayTags.h"
|
||||
#include "GameplayTagsManager.h"
|
||||
#include <string.h>
|
||||
|
||||
FAuraGameplayTags FAuraGameplayTags::GameplayTags;
|
||||
|
||||
|
||||
void FAuraGameplayTags::InitializeNativeGameplayTags()
|
||||
{
|
||||
UGameplayTagsManager& Manager(UGameplayTagsManager::Get());
|
||||
|
||||
// MARK: Attributes
|
||||
|
||||
#define INITIALIZE_ATTRIBUTE_TAG(AttributeName, CategoryName) \
|
||||
GameplayTags.Attributes_##CategoryName##_##AttributeName = Manager.AddNativeGameplayTag( \
|
||||
FName(FString::Printf(TEXT("Attributes.%s.%s"), TEXT(#CategoryName), TEXT(#AttributeName))), \
|
||||
FString("Attribute identifier tag") \
|
||||
);
|
||||
|
||||
FOREACH_ATTRIBUTE_All(INITIALIZE_ATTRIBUTE_TAG);
|
||||
|
||||
// MARK: Inputs
|
||||
|
||||
GameplayTags.InputTag = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag"),
|
||||
FString("Root Input Tag")
|
||||
);
|
||||
|
||||
GameplayTags.InputTag_LMB = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.LMB"),
|
||||
FString("Input Tag for ability LMB")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_LMB);
|
||||
|
||||
GameplayTags.InputTag_RMB = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.RMB"),
|
||||
FString("Input Tag for ability RMB")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_RMB);
|
||||
|
||||
GameplayTags.InputTag_1 = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.1"),
|
||||
FString("Input Tag for ability 1")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_1);
|
||||
|
||||
GameplayTags.InputTag_2 = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.2"),
|
||||
FString("Input Tag for ability 2")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_2);
|
||||
|
||||
GameplayTags.InputTag_3 = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.3"),
|
||||
FString("Input Tag for ability 3")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_3);
|
||||
|
||||
GameplayTags.InputTag_4 = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.4"),
|
||||
FString("Input Tag for ability 4")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_4);
|
||||
|
||||
GameplayTags.InputTag_Q = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.Q"),
|
||||
FString("Input Tag for ability Q")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_Q);
|
||||
|
||||
GameplayTags.InputTag_E = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.E"),
|
||||
FString("Input Tag for ability E")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_E);
|
||||
|
||||
GameplayTags.InputTag_R = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.R"),
|
||||
FString("Input Tag for ability R")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_R);
|
||||
|
||||
GameplayTags.InputTag_F = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.F"),
|
||||
FString("Input Tag for ability F")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_F);
|
||||
|
||||
GameplayTags.InputTag_Space = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.Space"),
|
||||
FString("Input Tag for ability Space")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_Space);
|
||||
|
||||
GameplayTags.InputTag_Passive_1 = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.Passive.1"),
|
||||
FString("Key tag for passive 1")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_Passive_1);
|
||||
|
||||
GameplayTags.InputTag_Passive_2 = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.Passive.2"),
|
||||
FString("Key tag for passive 2")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_Passive_2);
|
||||
|
||||
GameplayTags.InputTag_Passive_3 = Manager.AddNativeGameplayTag(
|
||||
FName("InputTag.Passive.3"),
|
||||
FString("Key tag for passive 3")
|
||||
);
|
||||
GameplayTags.InputTags.Add(GameplayTags.InputTag_Passive_3);
|
||||
|
||||
|
||||
// MARK: Event
|
||||
|
||||
GameplayTags.Event = Manager.AddNativeGameplayTag(
|
||||
FName("Event"),
|
||||
FString("Root tag for event to send to an actor")
|
||||
);
|
||||
|
||||
GameplayTags.Event_AbilitySystem_DamageApplied = Manager.AddNativeGameplayTag(
|
||||
FName("Event.AbilitySystem.DamageApplied"),
|
||||
FString("Event that the actor has applied damages")
|
||||
);
|
||||
|
||||
|
||||
// MARK: Damages
|
||||
|
||||
GameplayTags.Damage = Manager.AddNativeGameplayTag(
|
||||
FName("Damage"),
|
||||
FString("Brut damages identifier")
|
||||
);
|
||||
GameplayTags.DamageTypes.Add(GameplayTags.Damage);
|
||||
|
||||
GameplayTags.Damage_Physical = Manager.AddNativeGameplayTag(
|
||||
FName("Damage.Physical"),
|
||||
FString("Physical damages identifier")
|
||||
);
|
||||
GameplayTags.DamageTypes.Add(GameplayTags.Damage_Physical);
|
||||
|
||||
GameplayTags.Damage_Magical = Manager.AddNativeGameplayTag(
|
||||
FName("Damage.Magical"),
|
||||
FString("Magical damages identifier")
|
||||
);
|
||||
GameplayTags.DamageTypes.Add(GameplayTags.Damage_Magical);
|
||||
|
||||
GameplayTags.Damage_Magical_Fire = Manager.AddNativeGameplayTag(
|
||||
FName("Damage.Magical.Fire"),
|
||||
FString("Fire damages identifier")
|
||||
);
|
||||
GameplayTags.DamageTypes.Add(GameplayTags.Damage_Magical_Fire);
|
||||
|
||||
GameplayTags.Damage_Magical_Ice = Manager.AddNativeGameplayTag(
|
||||
FName("Damage.Magical.Ice"),
|
||||
FString("Ice damages identifier")
|
||||
);
|
||||
GameplayTags.DamageTypes.Add(GameplayTags.Damage_Magical_Ice);
|
||||
|
||||
GameplayTags.Damage_Magical_Shock = Manager.AddNativeGameplayTag(
|
||||
FName("Damage.Magical.Shock"),
|
||||
FString("Shock damages identifier")
|
||||
);
|
||||
GameplayTags.DamageTypes.Add(GameplayTags.Damage_Magical_Shock);
|
||||
|
||||
GameplayTags.Damage_Magical_Shadow = Manager.AddNativeGameplayTag(
|
||||
FName("Damage.Magical.Shadow"),
|
||||
FString("Shadow damages identifier")
|
||||
);
|
||||
GameplayTags.DamageTypes.Add(GameplayTags.Damage_Magical_Shadow);
|
||||
|
||||
GameplayTags.Damage_Magical_Arcane = Manager.AddNativeGameplayTag(
|
||||
FName("Damage.Magical.Arcane"),
|
||||
FString("Arcane damages identifier")
|
||||
);
|
||||
GameplayTags.DamageTypes.Add(GameplayTags.Damage_Magical_Arcane);
|
||||
|
||||
GameplayTags.DamageResistanceMap.Add(GameplayTags.Damage_Physical, GameplayTags.Attributes_Resistance_PhysicalRes);
|
||||
GameplayTags.DamageResistanceMap.Add(GameplayTags.Damage_Magical, GameplayTags.Attributes_Resistance_MagicalRes);
|
||||
GameplayTags.DamageResistanceMap.Add(GameplayTags.Damage_Magical_Fire, GameplayTags.Attributes_Resistance_FireRes);
|
||||
GameplayTags.DamageResistanceMap.Add(GameplayTags.Damage_Magical_Ice, GameplayTags.Attributes_Resistance_IceRes);
|
||||
GameplayTags.DamageResistanceMap.Add(GameplayTags.Damage_Magical_Shock, GameplayTags.Attributes_Resistance_ShockRes);
|
||||
GameplayTags.DamageResistanceMap.Add(GameplayTags.Damage_Magical_Arcane, GameplayTags.Attributes_Resistance_ArcaneRes);
|
||||
GameplayTags.DamageResistanceMap.Add(GameplayTags.Damage_Magical_Shadow, GameplayTags.Attributes_Resistance_ShadowRes);
|
||||
|
||||
// MARK: Effects
|
||||
|
||||
GameplayTags.Effects_HitReact = Manager.AddNativeGameplayTag(
|
||||
FName("Effects.HitReact"),
|
||||
FString("Reacting to an incoming hit")
|
||||
);
|
||||
|
||||
GameplayTags.Debuff = Manager.AddNativeGameplayTag(
|
||||
FName("Debuff"),
|
||||
FString("Effect is a debuff")
|
||||
);
|
||||
|
||||
GameplayTags.Debuff_Stun = Manager.AddNativeGameplayTag(
|
||||
FName("Debuff.Stun"),
|
||||
FString("Effect is a debuff that keep us stunned")
|
||||
);
|
||||
|
||||
GameplayTags.Debuff_Slow = Manager.AddNativeGameplayTag(
|
||||
FName("Debuff.Slow"),
|
||||
FString("Effect is a debuff that keep us slowed")
|
||||
);
|
||||
|
||||
GameplayTags.Debuff_Dot = Manager.AddNativeGameplayTag(
|
||||
FName("Debuff.Dot"),
|
||||
FString("Effect is a debuff deals damages over time. Should have another tag child of `Damage.`")
|
||||
);
|
||||
|
||||
GameplayTags.Debuff_Attributes = Manager.AddNativeGameplayTag(
|
||||
FName("Debuff.Attributes"),
|
||||
FString("Effect is a debuff that modifies attributes. Should have another tag child of `Attributes.`")
|
||||
);
|
||||
|
||||
|
||||
// MARK: Ability
|
||||
|
||||
GameplayTags.Ability_ID = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.ID"),
|
||||
FString("Root ability identifier tag")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Cooldown = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Cooldown"),
|
||||
FString("Root ability cooldown tag")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Status = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Status"),
|
||||
FString("Root ability status")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Status_Locked = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Status.Locked"),
|
||||
FString("Ability not available yet")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Status_Eligible = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Status.Eligible"),
|
||||
FString("Ability can be learn")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Status_Unlocked = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Status.Unlocked"),
|
||||
FString("Ability can be put in action bar")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Status_Equipped = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Status.Equipped"),
|
||||
FString("Ability is set in action bar")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Type = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Type"),
|
||||
FString("Root ability type")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Type_Activable = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Type.Activable"),
|
||||
FString("Ability must be equipped and activated")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Type_Passive = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Type.Passive"),
|
||||
FString("Ability is permanently activated when equipped")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Type_Utility = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Type.Utility"),
|
||||
FString("Ability permanently available as part of the game mechanics")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_Interruptible = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Interruptible"),
|
||||
FString("Ability that can be interrupted")
|
||||
);
|
||||
GameplayTags.Ability_Interruptible_HitReact = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.Interruptible.HitReact"),
|
||||
FString("Ability interrupted with Hit React")
|
||||
);
|
||||
|
||||
GameplayTags.Ability_AI_BasicAttack = Manager.AddNativeGameplayTag(
|
||||
FName("Ability.AI.BasicAttack"),
|
||||
FString("Ability to use when AI tries to basic attack")
|
||||
);
|
||||
|
||||
GameplayTags.Player_Hide_Cursor = Manager.AddNativeGameplayTag(
|
||||
FName("Player.Hide.Cursor"),
|
||||
FString("Hide player cursor")
|
||||
);
|
||||
|
||||
GameplayTags.Player_Block_AbilityInput = Manager.AddNativeGameplayTag(
|
||||
FName("Player.Block.AbilityInput"),
|
||||
FString("Prevent player from using ability with inputs")
|
||||
);
|
||||
|
||||
GameplayTags.Player_Block_CursorTrace = Manager.AddNativeGameplayTag(
|
||||
FName("Player.Block.CursorTrace"),
|
||||
FString("Prevent player from cursor tracing in different interaction systems")
|
||||
);
|
||||
|
||||
}
|
||||
190
Source/Aura/Private/Character/AuraCharacterBase.cpp
Normal file
190
Source/Aura/Private/Character/AuraCharacterBase.cpp
Normal file
@@ -0,0 +1,190 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Character/AuraCharacterBase.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemLibrary.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
#include "AbilitySystem/Data/CharacterClassInfo.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "Player/AuraPlayerController.h"
|
||||
#include "Aura/Aura.h"
|
||||
|
||||
AAuraCharacterBase::AAuraCharacterBase()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
bUseControllerRotationPitch = false;
|
||||
bUseControllerRotationRoll = false;
|
||||
bUseControllerRotationYaw = false;
|
||||
GetCharacterMovement()->bUseControllerDesiredRotation = true;
|
||||
|
||||
GetCapsuleComponent()->SetCollisionResponseToChannel(ECC_Camera, ECR_Ignore);
|
||||
GetCapsuleComponent()->SetGenerateOverlapEvents(false);
|
||||
GetMesh()->SetCollisionResponseToChannel(ECC_Camera, ECR_Ignore);
|
||||
GetMesh()->SetCollisionResponseToChannel(ECC_Projectile, ECR_Overlap);
|
||||
GetMesh()->SetGenerateOverlapEvents(true);
|
||||
|
||||
Weapon = CreateDefaultSubobject<USkeletalMeshComponent>("Weapon");
|
||||
Weapon->SetupAttachment(GetMesh(), FName("WeaponHandSocket"));
|
||||
Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
|
||||
}
|
||||
|
||||
void AAuraCharacterBase::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
checkf(ClassInfo, TEXT("ClassInfo not set for %s"), *GetNameSafe(this));
|
||||
}
|
||||
|
||||
void AAuraCharacterBase::Restart()
|
||||
{
|
||||
Super::Restart();
|
||||
|
||||
AAuraPlayerController* AuraPC = GetController<AAuraPlayerController>();
|
||||
if (IsValid(AuraPC))
|
||||
{
|
||||
AuraPC->PawnRestart(this);
|
||||
}
|
||||
}
|
||||
|
||||
UAbilitySystemComponent* AAuraCharacterBase::GetAbilitySystemComponent() const
|
||||
{
|
||||
return AbilitySystemComponent;
|
||||
}
|
||||
|
||||
|
||||
void AAuraCharacterBase::SetHighlighted_Implementation(bool bNewHighlighted)
|
||||
{
|
||||
bHighlighted = bNewHighlighted;
|
||||
}
|
||||
|
||||
void AAuraCharacterBase::GetWorldHoverableInfos_Implementation(FWorldHoverableInfos& Infos)
|
||||
{
|
||||
Infos.Location = FVector(0.5, 0.1, 0.0);
|
||||
Infos.Text = GetClassInfo()->Name;
|
||||
Infos.bScreenSpace = true;
|
||||
}
|
||||
|
||||
bool AAuraCharacterBase::CanBeHovered_Implementation(AController* Controller, const FHitResult& TraceHit)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AAuraCharacterBase::HoveredBegin_Implementation(AController* Controller, const FHitResult& TraceHit)
|
||||
{
|
||||
SetHighlighted(true);
|
||||
}
|
||||
|
||||
void AAuraCharacterBase::HoveredEnd_Implementation(AController* Controller)
|
||||
{
|
||||
SetHighlighted(false);
|
||||
}
|
||||
|
||||
|
||||
void AAuraCharacterBase::InitAbilitySystem()
|
||||
{
|
||||
if (UAuraAbilitySystemComponent* ASC = Cast<UAuraAbilitySystemComponent>(AbilitySystemComponent))
|
||||
{
|
||||
ASC->AbilitySystemInitDone();
|
||||
}
|
||||
AbilitySystemInitialized(AbilitySystemComponent);
|
||||
OnASCRegistered.Broadcast(AbilitySystemComponent);
|
||||
|
||||
// AbilitySystemComponent->OnGameplayEffectAppliedDelegateToSelf.AddUObject(this, &AAuraCharacterBase::OnEffectApplied);
|
||||
AddCharacterBaseEffects();
|
||||
AddCharacterAbilities();
|
||||
ApplyBeginEffects();
|
||||
}
|
||||
|
||||
void AAuraCharacterBase::AbilitySystemInitialized_Implementation(UAbilitySystemComponent* ASC)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// void AAuraCharacterBase::OnEffectApplied_Implementation(UAbilitySystemComponent* ASC, const FGameplayEffectSpec& EffectSpec, FActiveGameplayEffectHandle EffectHandle)
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
void AAuraCharacterBase::RegisterGameplayTagEvent(FGameplayTag EventTag, EGameplayTagEventType::Type TagEventType, FTagCountChangeSignature OnTagCountChanged)
|
||||
{
|
||||
if (AbilitySystemComponent)
|
||||
{
|
||||
AbilitySystemComponent->RegisterGameplayTagEvent(EventTag, TagEventType)
|
||||
.AddLambda([OnTagCountChanged](const FGameplayTag& CallbackTag, int32 NewCount) {
|
||||
OnTagCountChanged.ExecuteIfBound(CallbackTag, NewCount);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraCharacterBase::AddCharacterBaseEffects()
|
||||
{
|
||||
const float PlayerLevel = static_cast<float>(ICombatInterface::Execute_GetPlayerLevel(this));
|
||||
|
||||
UAuraAbilitySystemComponent* AuraASC = Cast<UAuraAbilitySystemComponent>(AbilitySystemComponent);
|
||||
for(const TSubclassOf<UGameplayEffect>& EffectClass : ClassInfo->BaseEffects)
|
||||
{
|
||||
if (IsValid(EffectClass))
|
||||
{
|
||||
FGameplayEffectContextHandle EffectContext = AbilitySystemComponent->MakeEffectContext();
|
||||
EffectContext.AddSourceObject(AbilitySystemComponent->GetAvatarActor());
|
||||
FActiveGameplayEffectHandle EffectHandle = AbilitySystemComponent->ApplyGameplayEffectSpecToSelf(*AbilitySystemComponent->MakeOutgoingSpec(EffectClass, PlayerLevel, EffectContext).Data.Get());
|
||||
if (AuraASC)
|
||||
AuraASC->BaseEffectsHandles.Add(EffectHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraCharacterBase::AddCharacterAbilities()
|
||||
{
|
||||
if (!HasAuthority()) return;
|
||||
|
||||
if (UAuraAbilitySystemComponent* ASC = Cast<UAuraAbilitySystemComponent>(GetAbilitySystemComponent()))
|
||||
{
|
||||
ASC->GrantStartupAbilities(ClassInfo->StartupAbilities);
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraCharacterBase::ApplyBeginEffects()
|
||||
{
|
||||
for(const FGameplayEffectParameters& Effect : ClassInfo->OnBeginEffects)
|
||||
{
|
||||
UAuraAbilitySystemLibrary::ApplyGameplayEffectWithParameters(Effect, nullptr, AbilitySystemComponent);
|
||||
}
|
||||
}
|
||||
|
||||
int32 AAuraCharacterBase::GetDeathExperience_Implementation() const
|
||||
{
|
||||
return ClassInfo->DeathExperience.GetValueAtLevel(ICombatInterface::Execute_GetPlayerLevel(this));
|
||||
}
|
||||
|
||||
FVector AAuraCharacterBase::GetCombatSocketLocation_Implementation(FGameplayTag SocketTagName) const
|
||||
{
|
||||
return GetActorLocation();
|
||||
}
|
||||
|
||||
bool AAuraCharacterBase::IsDead_Implementation() const
|
||||
{
|
||||
if (!IsValid(AttributeSet))
|
||||
return false;
|
||||
|
||||
if (UAuraAttributeSet* AS = Cast<UAuraAttributeSet>(AttributeSet))
|
||||
{
|
||||
return AS->GetHealth() <= 0.0f;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FOnASCRegisteredDelegate& AAuraCharacterBase::GetOnASCRegisteredDelegate()
|
||||
{
|
||||
return OnASCRegistered;
|
||||
}
|
||||
|
||||
FOnDeathBroadcastSignature& AAuraCharacterBase::GetOnDeathDelegate()
|
||||
{
|
||||
return OnDeath;
|
||||
}
|
||||
30
Source/Aura/Private/Character/AuraEnemy.cpp
Normal file
30
Source/Aura/Private/Character/AuraEnemy.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Character/AuraEnemy.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
|
||||
AAuraEnemy::AAuraEnemy()
|
||||
{
|
||||
AbilitySystemComponent = CreateDefaultSubobject<UAuraAbilitySystemComponent>("AbilitySystemComponent");
|
||||
AbilitySystemComponent->SetIsReplicated(true);
|
||||
AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Minimal);
|
||||
AttributeSet = CreateDefaultSubobject<UAuraAttributeSet>("AttributeSet");
|
||||
|
||||
Tags.Add(FName("Enemy"));
|
||||
}
|
||||
|
||||
void AAuraEnemy::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
InitAbilitySystem();
|
||||
}
|
||||
|
||||
void AAuraEnemy::InitAbilitySystem()
|
||||
{
|
||||
AbilitySystemComponent->InitAbilityActorInfo(this, this);
|
||||
|
||||
Super::InitAbilitySystem();
|
||||
}
|
||||
78
Source/Aura/Private/Character/AuraPlayerCharacter.cpp
Normal file
78
Source/Aura/Private/Character/AuraPlayerCharacter.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Character/AuraPlayerCharacter.h"
|
||||
#include "Player/AuraPlayerState.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "Player/AuraPlayerController.h"
|
||||
#include "UI/HUD/AuraHUD.h"
|
||||
|
||||
AAuraPlayerCharacter::AAuraPlayerCharacter()
|
||||
{
|
||||
CameraBoom = CreateDefaultSubobject<USpringArmComponent>("CameraBoom");
|
||||
CameraBoom->SetRelativeRotation(FRotator(-60.0f, 0.0f, 0.0f));
|
||||
CameraBoom->SetupAttachment(RootComponent);
|
||||
CameraBoom->bInheritPitch = false;
|
||||
CameraBoom->bInheritRoll = false;
|
||||
CameraBoom->bInheritYaw = false;
|
||||
|
||||
FollowCamera = CreateDefaultSubobject<UCameraComponent>("FollowCamera");
|
||||
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
|
||||
|
||||
if (UCharacterMovementComponent* MovementComponent = GetCharacterMovement())
|
||||
{
|
||||
MovementComponent->bOrientRotationToMovement = true;
|
||||
MovementComponent->bConstrainToPlane = true;
|
||||
MovementComponent->bSnapToPlaneAtStart = true;
|
||||
}
|
||||
|
||||
Tags.Add(FName("Player"));
|
||||
}
|
||||
|
||||
void AAuraPlayerCharacter::PossessedBy(AController* NewController)
|
||||
{
|
||||
Super::PossessedBy(NewController);
|
||||
|
||||
InitAbilitySystem();
|
||||
}
|
||||
|
||||
void AAuraPlayerCharacter::OnRep_PlayerState()
|
||||
{
|
||||
Super::OnRep_PlayerState();
|
||||
|
||||
InitAbilitySystem();
|
||||
}
|
||||
|
||||
int32 AAuraPlayerCharacter::GetPlayerLevel_Implementation() const
|
||||
{
|
||||
if (AAuraPlayerState* PS = GetPlayerState<AAuraPlayerState>())
|
||||
{
|
||||
return PS->GetPlayerLevel();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ULevelingExperienceComponent* AAuraPlayerCharacter::GetLevelingExperienceComponent_Implementation() const
|
||||
{
|
||||
if (AAuraPlayerState* PS = GetPlayerState<AAuraPlayerState>())
|
||||
{
|
||||
return PS->GetLevelingExperience();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AAuraPlayerCharacter::InitAbilitySystem()
|
||||
{
|
||||
if (AAuraPlayerState* AuraPlayerState = GetPlayerState<AAuraPlayerState>())
|
||||
{
|
||||
AbilitySystemComponent = AuraPlayerState->GetAbilitySystemComponent();
|
||||
AbilitySystemComponent->InitAbilityActorInfo(AuraPlayerState, this);
|
||||
AttributeSet = AuraPlayerState->GetAttributeSet();
|
||||
}
|
||||
|
||||
Super::InitAbilitySystem();
|
||||
}
|
||||
5
Source/Aura/Private/Game/AuraGameModeBase.cpp
Normal file
5
Source/Aura/Private/Game/AuraGameModeBase.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Game/AuraGameModeBase.h"
|
||||
|
||||
5
Source/Aura/Private/Game/AuraGameState.cpp
Normal file
5
Source/Aura/Private/Game/AuraGameState.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "Game/AuraGameState.h"
|
||||
|
||||
5
Source/Aura/Private/Input/AuraInputComponent.cpp
Normal file
5
Source/Aura/Private/Input/AuraInputComponent.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Input/AuraInputComponent.h"
|
||||
|
||||
21
Source/Aura/Private/Input/AuraInputConfig.cpp
Normal file
21
Source/Aura/Private/Input/AuraInputConfig.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Input/AuraInputConfig.h"
|
||||
|
||||
const UInputAction* UAuraInputConfig::FindAbilityInputActionForTag(const FGameplayTag& InputTag, bool bLogNotFound) const
|
||||
{
|
||||
for (const FAuraInputAction& AbilityInputAction : AbilityInputActions)
|
||||
{
|
||||
if (AbilityInputAction.InputTag.MatchesTagExact(InputTag))
|
||||
{
|
||||
return AbilityInputAction.InputAction;
|
||||
}
|
||||
}
|
||||
|
||||
if (bLogNotFound)
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("Can't find ability input tag [%s]"), *InputTag.ToString());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
6
Source/Aura/Private/Interaction/CombatInterface.cpp
Normal file
6
Source/Aura/Private/Interaction/CombatInterface.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Interaction/CombatInterface.h"
|
||||
|
||||
// Add default functionality here for any ICombatInterface functions that are not pure virtual.
|
||||
6
Source/Aura/Private/Interaction/PlayerInterface.cpp
Normal file
6
Source/Aura/Private/Interaction/PlayerInterface.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "Interaction/PlayerInterface.h"
|
||||
|
||||
// Add default functionality here for any IPlayerInterface functions that are not pure virtual.
|
||||
34
Source/Aura/Private/Inventory/AuraInventoryComponent.cpp
Normal file
34
Source/Aura/Private/Inventory/AuraInventoryComponent.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "Inventory/AuraInventoryComponent.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Game/AuraGameState.h"
|
||||
#include "Game/AuraGameModeBase.h"
|
||||
#include "Inventory/AuraInventoryDataSource.h"
|
||||
|
||||
|
||||
uint8 UAuraInventoryComponent::GetMaxStackSizeForID(const FName& ID) const
|
||||
{
|
||||
FInventoryItemData Data;
|
||||
FetchSlotData(ID, Data);
|
||||
return Data.MaxStackSize;
|
||||
}
|
||||
|
||||
bool UAuraInventoryComponent::FetchSlotData(const FName& SlotId, FInventoryItemData& Data) const
|
||||
{
|
||||
if (DataSource)
|
||||
{
|
||||
return DataSource->GetDataForItemId(SlotId, Data);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
FLinearColor UAuraInventoryComponent::GetColorFromQuality(EInventoryItemQuality Quality) const
|
||||
{
|
||||
if (DataSource)
|
||||
{
|
||||
return DataSource->GetColorFromQuality(Quality);
|
||||
}
|
||||
return FLinearColor();
|
||||
}
|
||||
24
Source/Aura/Private/Inventory/AuraInventoryDataSource.cpp
Normal file
24
Source/Aura/Private/Inventory/AuraInventoryDataSource.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "Inventory/AuraInventoryDataSource.h"
|
||||
|
||||
|
||||
bool UAuraInventoryDataSource::GetDataForItemId(const FName& ItemId, FInventoryItemData& Data) const
|
||||
{
|
||||
if (IsValid(ItemDataTable))
|
||||
{
|
||||
FInventoryItemData* DataRow = ItemDataTable->FindRow<FInventoryItemData>(ItemId, "Fetch Item Data");
|
||||
if (DataRow)
|
||||
{
|
||||
Data = *DataRow;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
FLinearColor UAuraInventoryDataSource::GetColorFromQuality(EInventoryItemQuality Quality) const
|
||||
{
|
||||
return QualityColors[Quality];
|
||||
}
|
||||
209
Source/Aura/Private/Player/AuraPlayerController.cpp
Normal file
209
Source/Aura/Private/Player/AuraPlayerController.cpp
Normal file
@@ -0,0 +1,209 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Player/AuraPlayerController.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "Input/AuraInputComponent.h"
|
||||
#include "Components/InteractionControllerComponent.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "Character/AuraEnemy.h"
|
||||
#include "AuraGameplayTags.h"
|
||||
#include "Player/Components/AutoRunComponent.h"
|
||||
#include "Components/SplineComponent.h"
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
#include "UI/HUD/AuraHUD.h"
|
||||
|
||||
AAuraPlayerController::AAuraPlayerController()
|
||||
{
|
||||
bReplicates = true;
|
||||
|
||||
InteractionController = CreateDefaultSubobject<UInteractionControllerComponent>("InteractionController");
|
||||
AutoRunComponent = CreateDefaultSubobject<UAutoRunComponent>("AutoRun");
|
||||
}
|
||||
|
||||
void AAuraPlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
if (UEnhancedInputLocalPlayerSubsystem* InputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer()))
|
||||
{
|
||||
checkf(AuraContext, TEXT("BP_AuraPlayerController: Invalid Input Context"));
|
||||
InputSubsystem->AddMappingContext(AuraContext, 0);
|
||||
}
|
||||
|
||||
bShowMouseCursor = true;
|
||||
DefaultMouseCursor = EMouseCursor::Default;
|
||||
|
||||
FInputModeGameAndUI InputModeData;
|
||||
InputModeData.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock);
|
||||
InputModeData.SetHideCursorDuringCapture(false);
|
||||
SetInputMode(InputModeData);
|
||||
}
|
||||
|
||||
void AAuraPlayerController::SetupInputComponent()
|
||||
{
|
||||
Super::SetupInputComponent();
|
||||
|
||||
UAuraInputComponent* AuraInputComponent = CastChecked<UAuraInputComponent>(InputComponent);
|
||||
|
||||
AuraInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ThisClass::Move);
|
||||
AuraInputComponent->BindAbilityActions(AbilityInputConfig, this, &ThisClass::AbilityTagPressed, &ThisClass::AbilityTagReleased, &ThisClass::AbilityTagHeld);
|
||||
AuraInputComponent->BindAction(HoldPositionAction, ETriggerEvent::Triggered, this, &ThisClass::HoldPositionPressed);
|
||||
AuraInputComponent->BindAction(HoldPositionAction, ETriggerEvent::Completed, this, &ThisClass::HoldPositionReleased);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AAuraPlayerController::PawnRestart(APawn* aPawn)
|
||||
{
|
||||
BP_PawnRestart(aPawn);
|
||||
|
||||
AutoRunComponent->SetControlledPawn(aPawn);
|
||||
|
||||
UAbilitySystemComponent* ASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(aPawn);
|
||||
if (IsValid(ASC))
|
||||
{
|
||||
if (IsLocalPlayerController())
|
||||
{
|
||||
ASC->RegisterGameplayTagEvent(FAuraGameplayTags::Get().Player_Hide_Cursor, EGameplayTagEventType::NewOrRemoved)
|
||||
.AddLambda([this](const FGameplayTag& CallbackTag, int32 NewCount) {
|
||||
SetShowMouseCursor(NewCount == 0);
|
||||
});
|
||||
|
||||
ASC->RegisterGameplayTagEvent(FAuraGameplayTags::Get().Player_Block_CursorTrace, EGameplayTagEventType::NewOrRemoved)
|
||||
.AddLambda([this](const FGameplayTag& CallbackTag, int32 NewCount) {
|
||||
if (NewCount > 0)
|
||||
this->InteractionController->Deactivate();
|
||||
else
|
||||
this->InteractionController->Activate();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (AAuraHUD* HUD = GetHUD<AAuraHUD>())
|
||||
{
|
||||
HUD->InitOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AAuraPlayerController::HoldPositionPressed()
|
||||
{
|
||||
AutoRunComponent->HoldPositionPressed();
|
||||
}
|
||||
|
||||
void AAuraPlayerController::HoldPositionReleased()
|
||||
{
|
||||
AutoRunComponent->HoldPositionReleased();
|
||||
}
|
||||
|
||||
const FHitResult& AAuraPlayerController::GetCursorHit() const {
|
||||
return InteractionController->GetCursorHit();
|
||||
}
|
||||
|
||||
AAuraEnemy* AAuraPlayerController::GetHoveredEnemy() const {
|
||||
AActor* HoveredActor = InteractionController->GetHoveredActor();
|
||||
if (IsValid(HoveredActor))
|
||||
return Cast<AAuraEnemy>(HoveredActor);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AAuraPlayerController::Client_ShowFloatingDamages_Implementation(const FFloatingDamage& FloatingDamage)
|
||||
{
|
||||
ShowFloatingDamages(FloatingDamage);
|
||||
}
|
||||
|
||||
void AAuraPlayerController::ShowFloatingDamages_Implementation(const FFloatingDamage& FloatingDamage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AAuraPlayerController::Client_ShowReceivedDamages_Implementation(const FFloatingDamage& ReceivedDamage)
|
||||
{
|
||||
ShowReceivedDamages(ReceivedDamage);
|
||||
}
|
||||
|
||||
void AAuraPlayerController::ShowReceivedDamages_Implementation(const FFloatingDamage& ReceivedDamage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AAuraPlayerController::Move(const struct FInputActionValue& InputActionValue)
|
||||
{
|
||||
const FVector2D InputAxisVector = InputActionValue.Get<FVector2D>();
|
||||
|
||||
if (InputAxisVector.IsNearlyZero())
|
||||
return;
|
||||
|
||||
AutoRunComponent->StopAutoRun();
|
||||
const FRotator Rotation = GetControlRotation();
|
||||
const FRotator YawRotation(0.0f, Rotation.Yaw, 0.0f);
|
||||
const FRotationMatrix RotationMatrix(YawRotation);
|
||||
|
||||
const FVector ForwardVector = RotationMatrix.GetUnitAxis(EAxis::X);
|
||||
const FVector RightVector = RotationMatrix.GetUnitAxis(EAxis::Y);
|
||||
|
||||
if (APawn* ControlledPawn = GetPawn<APawn>())
|
||||
{
|
||||
ControlledPawn->AddMovementInput(ForwardVector, InputAxisVector.Y);
|
||||
ControlledPawn->AddMovementInput(RightVector, InputAxisVector.X);
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraPlayerController::AbilityTagPressed(FGameplayTag InputTag)
|
||||
{
|
||||
if (InputTag.MatchesTagExact(FAuraGameplayTags::Get().InputTag_LMB))
|
||||
{
|
||||
AutoRunComponent->AutoRunKeyPressed(IsValid(GetHoveredEnemy()));
|
||||
}
|
||||
if (UAuraAbilitySystemComponent* ASC = GetASC())
|
||||
{
|
||||
ASC->AbilityInputTagPressed(InputTag);
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraPlayerController::AbilityTagReleased(FGameplayTag InputTag)
|
||||
{
|
||||
if (InputTag.MatchesTagExact(FAuraGameplayTags::Get().InputTag_LMB))
|
||||
{
|
||||
if (AutoRunComponent->ShouldAutoRun())
|
||||
{
|
||||
AutoRunComponent->AutoRunKeyReleased();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (UAuraAbilitySystemComponent* ASC = GetASC())
|
||||
{
|
||||
ASC->AbilityInputTagReleased(InputTag);
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraPlayerController::AbilityTagHeld(FGameplayTag InputTag)
|
||||
{
|
||||
if (InputTag.MatchesTagExact(FAuraGameplayTags::Get().InputTag_LMB))
|
||||
{
|
||||
if (AutoRunComponent->ShouldAutoRun())
|
||||
{
|
||||
AutoRunComponent->AutoRunKeyHold(GetWorld()->GetDeltaSeconds(), GetCursorHit());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (UAuraAbilitySystemComponent* ASC = GetASC())
|
||||
{
|
||||
ASC->AbilityInputTagHeld(InputTag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UAuraAbilitySystemComponent* AAuraPlayerController::GetASC()
|
||||
{
|
||||
if (!AbilitySystemComponent)
|
||||
{
|
||||
if (IAbilitySystemInterface* IASC = Cast<IAbilitySystemInterface>(GetPawn<APawn>()))
|
||||
{
|
||||
AbilitySystemComponent = Cast<UAuraAbilitySystemComponent>(IASC->GetAbilitySystemComponent());
|
||||
}
|
||||
}
|
||||
return AbilitySystemComponent;
|
||||
}
|
||||
275
Source/Aura/Private/Player/AuraPlayerState.cpp
Normal file
275
Source/Aura/Private/Player/AuraPlayerState.cpp
Normal file
@@ -0,0 +1,275 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Player/AuraPlayerState.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
#include "AbilitySystem/Components/LevelingExperienceComponent.h"
|
||||
#include "AbilitySystem/Components/PerkPointsComponent.h"
|
||||
#include "AbilitySystem/Data/LevelingInfo.h"
|
||||
#include "AbilitySystem/Data/AbilityBook.h"
|
||||
#include "AbilitySystem/Data/CharacterClassInfo.h"
|
||||
#include "Character/AuraCharacterBase.h"
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
|
||||
AAuraPlayerState::AAuraPlayerState()
|
||||
{
|
||||
NetUpdateFrequency = 100.0f;
|
||||
|
||||
AbilitySystemComponent = CreateDefaultSubobject<UAuraAbilitySystemComponent>("AbilitySystemComponent");
|
||||
AbilitySystemComponent->SetIsReplicated(true);
|
||||
AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Mixed);
|
||||
AttributeSet = CreateDefaultSubobject<UAuraAttributeSet>("AttributeSet");
|
||||
|
||||
LevelingExperience = CreateDefaultSubobject<ULevelingExperienceComponent>("LevelingExperience");
|
||||
PerkPoints = CreateDefaultSubobject<UPerkPointsComponent>("PerkPoints");
|
||||
}
|
||||
|
||||
void AAuraPlayerState::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
if (LevelingExperience)
|
||||
{
|
||||
LevelingExperience->OnLevelChanged.AddDynamic(this, &AAuraPlayerState::OnLevelChanged);
|
||||
}
|
||||
UpdateAbilityTree();
|
||||
}
|
||||
|
||||
UAbilitySystemComponent* AAuraPlayerState::GetAbilitySystemComponent() const
|
||||
{
|
||||
return AbilitySystemComponent;
|
||||
}
|
||||
|
||||
int32 AAuraPlayerState::GetPlayerLevel() const {
|
||||
if (LevelingExperience)
|
||||
return LevelingExperience->GetPlayerLevel();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AAuraPlayerState::GrantLevelingReward_Implementation(const FLevelingRewardInfo& Reward)
|
||||
{
|
||||
if (IsValid(PerkPoints))
|
||||
{
|
||||
PerkPoints->AddToAttributePoints(Reward.AttributePointsAward);
|
||||
PerkPoints->AddToAbilityPoints(Reward.AbilityPointAward);
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraPlayerState::NetMulticast_PlayLevelUpEffect_Implementation(int32 NewLevel)
|
||||
{
|
||||
PlayLevelUpEffect(NewLevel);
|
||||
}
|
||||
|
||||
void AAuraPlayerState::PlayLevelUpEffect_Implementation(int32 NewLevel)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AAuraPlayerState::Server_SpendAttributesPoint_Implementation(int32 PointsCount, FGameplayTag AttributeTag)
|
||||
{
|
||||
if (!IsValid(PerkPoints)) return;
|
||||
|
||||
int32 SpentPoints = PerkPoints->SpendAttributePoints(PointsCount);
|
||||
if (SpentPoints)
|
||||
{
|
||||
if (UAuraAbilitySystemComponent* AuraASC = Cast<UAuraAbilitySystemComponent>(AbilitySystemComponent))
|
||||
{
|
||||
AuraASC->AddAttributePoints(static_cast<float>(SpentPoints), AttributeTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraPlayerState::OnLevelChanged(int32 NewLevel)
|
||||
{
|
||||
if (HasAuthority())
|
||||
{
|
||||
if (LastLevelReward < NewLevel)
|
||||
NetMulticast_PlayLevelUpEffect(NewLevel);
|
||||
if (LevelingExperience && LevelingExperience->LevelingInfo)
|
||||
{
|
||||
TArray<FLevelingRewardInfo>& LevelRewards(LevelingExperience->LevelingInfo->LevelRewards);
|
||||
while (LastLevelReward < NewLevel)
|
||||
{
|
||||
++LastLevelReward;
|
||||
if (LastLevelReward < LevelRewards.Num())
|
||||
{
|
||||
FLevelingRewardInfo Reward = LevelRewards[LastLevelReward];
|
||||
GrantLevelingReward(Reward);
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateAbilityTree();
|
||||
}
|
||||
if (UAuraAbilitySystemComponent* AuraASC = Cast<UAuraAbilitySystemComponent>(AbilitySystemComponent))
|
||||
{
|
||||
for (FActiveGameplayEffectHandle& EffectHandle : AuraASC->BaseEffectsHandles)
|
||||
{
|
||||
AuraASC->SetActiveGameplayEffectLevel(EffectHandle, NewLevel);
|
||||
// AuraASC->SetActiveGameplayEffectLevelUsingQuery()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Ability Management */
|
||||
|
||||
static UAbilityBook* GetAbilityBook(APawn* Pawn)
|
||||
{
|
||||
if (AAuraCharacterBase* AuraCharacter = Cast<AAuraCharacterBase>(Pawn))
|
||||
{
|
||||
if (AuraCharacter->GetClassInfo())
|
||||
return AuraCharacter->GetClassInfo()->AbilitiesBook;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool AAuraPlayerState::MeetAbilityRequirement(const FAuraAbilityRequirement& Requirement) const
|
||||
{
|
||||
if (GetPlayerLevel() < Requirement.MiminalPlayerLevel)
|
||||
return false;
|
||||
|
||||
for (const FGameplayAbilityGrant& RequiredAbility : Requirement.RequiredAbilities)
|
||||
{
|
||||
FGameplayTag AbilityID = UAuraAbilitySystemComponent::GetAbilityIDTagFromAbility(RequiredAbility.Class.GetDefaultObject());
|
||||
if (FGameplayAbilitySpec* AbilitySpec = AbilitySystemComponent->GetAbilitySpecForAbilityIDTag(AbilityID))
|
||||
{
|
||||
if (AbilitySpec->Level < RequiredAbility.Level)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FString AAuraPlayerState::AbilityRequirementRichText(const FAuraAbilityRequirement& Requirement, const FString& ValidBalise, const FString& WrongBalise) const
|
||||
{
|
||||
UAbilityBook* AbilityBook = GetAbilityBook(GetPawn());
|
||||
FString Result;
|
||||
|
||||
Result += FString::Printf(TEXT("<%s>Level %d</>\n"),
|
||||
*(GetPlayerLevel() >= Requirement.MiminalPlayerLevel ? ValidBalise : WrongBalise),
|
||||
Requirement.MiminalPlayerLevel);
|
||||
|
||||
for (const FGameplayAbilityGrant& RequiredAbility : Requirement.RequiredAbilities)
|
||||
{
|
||||
bool bAbilityValid = true;
|
||||
FGameplayTag AbilityID = UAuraAbilitySystemComponent::GetAbilityIDTagFromAbility(RequiredAbility.Class.GetDefaultObject());
|
||||
if (FGameplayAbilitySpec* AbilitySpec = AbilitySystemComponent->GetAbilitySpecForAbilityIDTag(AbilityID))
|
||||
{
|
||||
if (AbilitySpec->Level < RequiredAbility.Level)
|
||||
bAbilityValid = false;
|
||||
}
|
||||
else
|
||||
bAbilityValid = false;
|
||||
|
||||
FString AbilityName;
|
||||
if (const FAuraAbilityInfo* AbilityInfo = AbilityBook->GetAbilities().Find(AbilityID))
|
||||
AbilityName = AbilityInfo->Name.ToString();
|
||||
else
|
||||
AbilityName = AbilityID.ToString();
|
||||
|
||||
Result += FString::Printf(TEXT("<%s>%s Level %d</>\n"),
|
||||
*(bAbilityValid ? ValidBalise : WrongBalise),
|
||||
*AbilityName,
|
||||
RequiredAbility.Level
|
||||
);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool AAuraPlayerState::CanUpgradeAbility(FGameplayTag AbilityID) const
|
||||
{
|
||||
if (UAbilityBook *AbilityBook = GetAbilityBook(GetPawn()))
|
||||
{
|
||||
if (FGameplayAbilitySpec* AbilitySpec = AbilitySystemComponent->GetAbilitySpecForAbilityIDTag(AbilityID))
|
||||
{
|
||||
const int32 AbilityNextLevel = AbilitySpec->Level + 1;
|
||||
if (const FAuraAbilityRequirement* Requirement = AbilityBook->GetRequirementsForAbilityLevel(AbilityID, AbilityNextLevel))
|
||||
{
|
||||
return MeetAbilityRequirement(*Requirement);
|
||||
}
|
||||
// else requirement not found (Level does not exist)
|
||||
}
|
||||
// else no spec
|
||||
}
|
||||
// else no ability book
|
||||
return false;
|
||||
}
|
||||
|
||||
void AAuraPlayerState::Server_UpgradeAbility_Implementation(FGameplayTag AbilityID)
|
||||
{
|
||||
if (!IsValid(PerkPoints)) return;
|
||||
if (!CanUpgradeAbility(AbilityID)) return;
|
||||
|
||||
UAbilityBook *AbilityBook = GetAbilityBook(GetPawn());
|
||||
|
||||
if (FGameplayAbilitySpec* AbilitySpec = AbilitySystemComponent->GetAbilitySpecForAbilityIDTag(AbilityID))
|
||||
{
|
||||
int32 SpentPoints = PerkPoints->SpendAbilityPoints(1);
|
||||
if (SpentPoints >= 1)
|
||||
{
|
||||
AbilitySystemComponent->AddLevelForAbilitySpec(*AbilitySpec, 1);
|
||||
UpdateAbilityTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AAuraPlayerState::CanEquipAbility(FGameplayTag AbilityID) const
|
||||
{
|
||||
if (FGameplayAbilitySpec* AbilitySpec = AbilitySystemComponent->GetAbilitySpecForAbilityIDTag(AbilityID))
|
||||
{
|
||||
return AbilitySpec->Level > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AAuraPlayerState::EquipAbility(FGameplayTag AbilityID, FGameplayTag InputTag)
|
||||
{
|
||||
if (FGameplayAbilitySpec* AbilitySpec = AbilitySystemComponent->GetAbilitySpecForAbilityIDTag(AbilityID))
|
||||
{
|
||||
AbilitySystemComponent->AssignInputTagToAbilitySpec(InputTag, *AbilitySpec);
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraPlayerState::UpdateAbilityTree()
|
||||
{
|
||||
if (!HasAuthority() || !AbilitySystemComponent) return;
|
||||
|
||||
// 1. Get all abilities infos
|
||||
UAbilityBook *AbilityBook = GetAbilityBook(GetPawn());
|
||||
if (!AbilityBook) return;
|
||||
TMap<FGameplayTag, FAuraAbilityInfo> LockedAbilities = AbilityBook->GetAbilities();
|
||||
|
||||
// 2. Remove already existings ones
|
||||
AbilitySystemComponent->ForEachAbilityLambda([this, &LockedAbilities](FGameplayAbilitySpec& AbilitySpec) {
|
||||
FGameplayTag AbilityID = UAuraAbilitySystemComponent::GetAbilityIDTagFromAbility(AbilitySpec.Ability);
|
||||
if (AbilityID.IsValid())
|
||||
{
|
||||
LockedAbilities.Remove(AbilityID);
|
||||
}
|
||||
});
|
||||
|
||||
// 3. Check for requirements of remaining abilities to add them
|
||||
for (const TPair<FGameplayTag, FAuraAbilityInfo>& LockedAbility : LockedAbilities)
|
||||
{
|
||||
const FAuraAbilityInfo& AbilityInfo(LockedAbility.Value);
|
||||
|
||||
bool bIsAbilityEligible = false;
|
||||
if (AbilityInfo.RequirementsForLevels.IsEmpty())
|
||||
bIsAbilityEligible = true;
|
||||
else
|
||||
bIsAbilityEligible = MeetAbilityRequirement(AbilityInfo.RequirementsForLevels[0]);
|
||||
|
||||
if (bIsAbilityEligible)
|
||||
{
|
||||
FGameplayAbilityGrant Grant;
|
||||
Grant.Class = AbilityInfo.Ability;
|
||||
Grant.Level = 0;
|
||||
|
||||
AbilitySystemComponent->GrantAbility(Grant);
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Source/Aura/Private/Player/Components/AutoRunComponent.cpp
Normal file
107
Source/Aura/Private/Player/Components/AutoRunComponent.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "Player/Components/AutoRunComponent.h"
|
||||
#include "Components/SplineComponent.h"
|
||||
#include "NavigationSystem.h"
|
||||
#include "NavigationPath.h"
|
||||
|
||||
|
||||
UAutoRunComponent::UAutoRunComponent()
|
||||
{
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
|
||||
PathSpline = CreateDefaultSubobject<USplineComponent>("PathSpline");
|
||||
}
|
||||
|
||||
void UAutoRunComponent::SetControlledPawn(APawn* Pawn)
|
||||
{
|
||||
ControlledPawn = Pawn;
|
||||
}
|
||||
|
||||
void UAutoRunComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
if (bAutoRunning)
|
||||
if (IsValid(ControlledPawn) && IsValid(PathSpline))
|
||||
{
|
||||
const FVector PawnLocation = ControlledPawn->GetActorLocation();
|
||||
const float ClosePointKey = PathSpline->FindInputKeyClosestToWorldLocation(PawnLocation);
|
||||
const FVector LocationOnSpline = PathSpline->GetLocationAtSplineInputKey(ClosePointKey, ESplineCoordinateSpace::World);
|
||||
const FVector SplineDirection = PathSpline->GetDirectionAtSplineInputKey(ClosePointKey, ESplineCoordinateSpace::World);
|
||||
const FVector NextTargetPoint = PathSpline->GetLocationAtSplineInputKey(FMath::CeilToFloat(ClosePointKey + 0.5), ESplineCoordinateSpace::World);
|
||||
FVector DirectionToNextTargetPoint = NextTargetPoint - PawnLocation;
|
||||
|
||||
DirectionToNextTargetPoint.Normalize();
|
||||
|
||||
ControlledPawn->AddMovementInput((SplineDirection + DirectionToNextTargetPoint) / 2);
|
||||
|
||||
if (ClosePointKey >= static_cast<float>(PathSpline->GetNumberOfSplinePoints()) - 1.1)
|
||||
bAutoRunning = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void UAutoRunComponent::StopAutoRun()
|
||||
{
|
||||
bAutoRunning = false;
|
||||
}
|
||||
|
||||
void UAutoRunComponent::AutoRunKeyPressed(bool bTargetingSomething)
|
||||
{
|
||||
bTargeting = bTargetingSomething;
|
||||
FollowTime = 0;
|
||||
bAutoRunning = false;
|
||||
}
|
||||
|
||||
void UAutoRunComponent::AutoRunKeyReleased()
|
||||
{
|
||||
if (!IsValid(ControlledPawn))
|
||||
return;
|
||||
|
||||
if (FollowTime < ShortPressThreshold)
|
||||
{
|
||||
if (UNavigationPath* NavPath = UNavigationSystemV1::FindPathToLocationSynchronously(this, ControlledPawn->GetActorLocation(), CachedDestination))
|
||||
{
|
||||
if (IsValid(PathSpline))
|
||||
{
|
||||
PathSpline->ClearSplinePoints();
|
||||
for (const FVector& PointLoc : NavPath->PathPoints)
|
||||
{
|
||||
PathSpline->AddSplinePoint(PointLoc, ESplineCoordinateSpace::World);
|
||||
}
|
||||
}
|
||||
if (!NavPath->PathPoints.IsEmpty())
|
||||
CachedDestination = NavPath->PathPoints[NavPath->PathPoints.Num() - 1];
|
||||
OnAutoWalkBegin.Broadcast(this, CachedDestination);
|
||||
bAutoRunning = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAutoRunComponent::AutoRunKeyHold(float DeltaTime, const FHitResult& CursorHit)
|
||||
{
|
||||
FollowTime += DeltaTime;
|
||||
|
||||
if (CursorHit.bBlockingHit)
|
||||
{
|
||||
CachedDestination = CursorHit.ImpactPoint;
|
||||
if (IsValid(ControlledPawn))
|
||||
{
|
||||
const FVector WorldDirection = (CachedDestination - ControlledPawn->GetActorLocation()).GetSafeNormal();
|
||||
ControlledPawn->AddMovementInput(WorldDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool UAutoRunComponent::IsAtDestination() const
|
||||
{
|
||||
if (!IsValid(ControlledPawn))
|
||||
return false;
|
||||
|
||||
const float SquaredDistanceToDestination = (ControlledPawn->GetActorLocation() - CachedDestination).SquaredLength();
|
||||
const float SquaredAcceptanceRadius = AutoRunAcceptanceRadius * AutoRunAcceptanceRadius;
|
||||
|
||||
return SquaredDistanceToDestination <= SquaredAcceptanceRadius;
|
||||
}
|
||||
47
Source/Aura/Private/UI/AuraUIBlueprintFunctionLibrary.cpp
Normal file
47
Source/Aura/Private/UI/AuraUIBlueprintFunctionLibrary.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
// Amasson
|
||||
|
||||
#include "UI/AuraUIBlueprintFunctionLibrary.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "UI/HUD/AuraHUD.h"
|
||||
#include "UI/WidgetController/AuraWidgetControllerBase.h"
|
||||
#include "Player/AuraPlayerController.h"
|
||||
#include "Player/AuraPlayerState.h"
|
||||
|
||||
|
||||
UOverlayController* UAuraUIBlueprintFunctionLibrary::GetOverlayController(const UObject* WorldContextObject)
|
||||
{
|
||||
if (APlayerController *PC = UGameplayStatics::GetPlayerController(WorldContextObject, 0))
|
||||
{
|
||||
if (AAuraHUD* Hud = Cast<AAuraHUD>(PC->GetHUD()))
|
||||
{
|
||||
return Hud->GetOverlayController();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UAttributeMenuController* UAuraUIBlueprintFunctionLibrary::GetAttributeMenuController(const UObject* WorldContextObject)
|
||||
{
|
||||
if (APlayerController *PC = UGameplayStatics::GetPlayerController(WorldContextObject, 0))
|
||||
{
|
||||
if (AAuraHUD* Hud = Cast<AAuraHUD>(PC->GetHUD()))
|
||||
{
|
||||
return Hud->GetAttributeMenuController();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UAbilityMenuController* UAuraUIBlueprintFunctionLibrary::GetAbilityMenuController(const UObject* WorldContextObject)
|
||||
{
|
||||
if (APlayerController *PC = UGameplayStatics::GetPlayerController(WorldContextObject, 0))
|
||||
{
|
||||
if (AAuraHUD* Hud = Cast<AAuraHUD>(PC->GetHUD()))
|
||||
{
|
||||
return Hud->GetAbilityMenuController();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** End Widget Controllers */
|
||||
96
Source/Aura/Private/UI/HUD/AuraHUD.cpp
Normal file
96
Source/Aura/Private/UI/HUD/AuraHUD.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "UI/HUD/AuraHUD.h"
|
||||
#include "Player/AuraPlayerController.h"
|
||||
#include "Player/AuraPlayerState.h"
|
||||
#include "UI/ControllableUserWidget.h"
|
||||
#include "UI/WidgetController/OverlayController.h"
|
||||
#include "UI/WidgetController/AttributeMenuController.h"
|
||||
#include "UI/WidgetController/AbilityMenuController.h"
|
||||
|
||||
UOverlayController* AAuraHUD::GetOverlayController()
|
||||
{
|
||||
if (!OverlayController)
|
||||
{
|
||||
UWidgetController* NewWidgetController = UWidgetController::MakeWidgetController(
|
||||
this,
|
||||
OverlayControllerClass,
|
||||
GetActorToObserve()
|
||||
);
|
||||
|
||||
OverlayController = Cast<UOverlayController>(NewWidgetController);
|
||||
}
|
||||
return OverlayController;
|
||||
}
|
||||
|
||||
UAttributeMenuController* AAuraHUD::GetAttributeMenuController()
|
||||
{
|
||||
if (!AttributeMenuController)
|
||||
{
|
||||
UWidgetController* NewWidgetController = UWidgetController::MakeWidgetController(
|
||||
this,
|
||||
AttributeMenuControllerClass,
|
||||
GetActorToObserve()
|
||||
);
|
||||
|
||||
AttributeMenuController = Cast<UAttributeMenuController>(NewWidgetController);
|
||||
}
|
||||
return AttributeMenuController;
|
||||
}
|
||||
|
||||
UAbilityMenuController* AAuraHUD::GetAbilityMenuController()
|
||||
{
|
||||
if (!AbilityMenuController)
|
||||
{
|
||||
UWidgetController* NewWidgetController = UWidgetController::MakeWidgetController(
|
||||
this,
|
||||
AbilityMenuControllerClass,
|
||||
GetActorToObserve()
|
||||
);
|
||||
|
||||
AbilityMenuController = Cast<UAbilityMenuController>(NewWidgetController);
|
||||
}
|
||||
return AbilityMenuController;
|
||||
}
|
||||
|
||||
void AAuraHUD::InitOverlay()
|
||||
{
|
||||
checkf(OverlayWidgetClass, TEXT("BP_AuraHUD: Invalid class for OverlayWidgetClass"));
|
||||
checkf(OverlayControllerClass, TEXT("BP_AuraHUD: Invalid class for OverlayControllerClass"));
|
||||
|
||||
ClearOverlay();
|
||||
|
||||
UOverlayController* WidgetController = GetOverlayController();
|
||||
|
||||
OverlayWidget = CreateWidget<UControllableUserWidget>(GetWorld(), OverlayWidgetClass);
|
||||
|
||||
OverlayWidget->SetWidgetController(WidgetController);
|
||||
WidgetController->BroadcastValues();
|
||||
|
||||
OverlayWidget->AddToViewport();
|
||||
}
|
||||
|
||||
|
||||
void AAuraHUD::ClearOverlay()
|
||||
{
|
||||
if (IsValid(OverlayWidget))
|
||||
OverlayWidget->RemoveFromParent();
|
||||
|
||||
OverlayController = nullptr;
|
||||
OverlayWidget = nullptr;
|
||||
}
|
||||
|
||||
AActor* AAuraHUD::GetActorToObserve() const
|
||||
{
|
||||
AActor* ObservedActor = nullptr;
|
||||
|
||||
APlayerController* PC = GetOwningPlayerController();
|
||||
if (IsValid(PC))
|
||||
{
|
||||
// Type is actor to make ternary operator understand
|
||||
AActor* PS = PC->GetPlayerState<AAuraPlayerState>();
|
||||
ObservedActor = IsValid(PS) ? PS : PC;
|
||||
}
|
||||
|
||||
return ObservedActor;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/AbilityMenuController.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/Data/AbilityBook.h"
|
||||
#include "AbilitySystem/Data/CharacterClassInfo.h"
|
||||
#include "AbilitySystem/Components/LevelingExperienceComponent.h"
|
||||
#include "AbilitySystem/Components/PerkPointsComponent.h"
|
||||
#include "Player/AuraPlayerState.h"
|
||||
#include "Character/AuraCharacterBase.h"
|
||||
|
||||
#include "UI/WidgetController/Components/AbilitiesStatusWCComponent.h"
|
||||
#include "UI/WidgetController/Components/PerkPointsWCComponent.h"
|
||||
|
||||
|
||||
void UAbilityMenuController::Construct()
|
||||
{
|
||||
Super::Construct();
|
||||
|
||||
AbilitiesStatusWcc = AddComponent<UAbilitiesStatusWCComponent>("AbilitiesStatus");
|
||||
PerkPointsWcc = AddComponent<UPerkPointsWCComponent>("PerkPoints");
|
||||
}
|
||||
|
||||
void UAbilityMenuController::ObservedActorSet()
|
||||
{
|
||||
Super::ObservedActorSet();
|
||||
|
||||
AbilityBook = RetrieveAbilityBook();
|
||||
|
||||
UPerkPointsComponent* PerkPoints = IsValid(AuraPlayerState) ? AuraPlayerState->GetPerkPoints() : nullptr;
|
||||
|
||||
if (IsValid(AbilitiesStatusWcc))
|
||||
AbilitiesStatusWcc->Initialize(AuraAbilitySystemComponent, AbilityBook);
|
||||
|
||||
if (IsValid(PerkPointsWcc))
|
||||
PerkPointsWcc->Initialize(PerkPoints);
|
||||
|
||||
}
|
||||
|
||||
bool UAbilityMenuController::CanUpgradeAbility(FGameplayTag AbilityID) const
|
||||
{
|
||||
if (IsValid(AuraPlayerState))
|
||||
{
|
||||
return AuraPlayerState->CanUpgradeAbility(AbilityID);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UAbilityMenuController::CanEquipAbility(FGameplayTag AbilityID) const
|
||||
{
|
||||
if (IsValid(AuraPlayerState))
|
||||
{
|
||||
return AuraPlayerState->CanEquipAbility(AbilityID);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UAbilityMenuController::UpgradeAbility(FGameplayTag AbilityID)
|
||||
{
|
||||
if (AuraPlayerState)
|
||||
{
|
||||
AuraPlayerState->Server_UpgradeAbility(AbilityID);
|
||||
}
|
||||
}
|
||||
|
||||
void UAbilityMenuController::EquipAbility(FGameplayTag AbilityID, FGameplayTag InputTag)
|
||||
{
|
||||
if (AuraPlayerState)
|
||||
{
|
||||
AuraPlayerState->EquipAbility(AbilityID, InputTag);
|
||||
}
|
||||
}
|
||||
|
||||
FString UAbilityMenuController::GetRequirementRichTextForAbility(FGameplayTag AbilityID, int32 Level, FString ValidBalise, FString WrongBalise) const
|
||||
{
|
||||
if (!IsValid(AuraPlayerState) || !IsValid(AbilityBook)) return FString();
|
||||
|
||||
if (const FAuraAbilityRequirement* Requirement = AbilityBook->GetRequirementsForAbilityLevel(AbilityID, Level))
|
||||
{
|
||||
return AuraPlayerState->AbilityRequirementRichText(*Requirement, ValidBalise, WrongBalise);
|
||||
}
|
||||
return FString();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/AttributeMenuController.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
#include "AbilitySystem/Data/AttributeInfo.h"
|
||||
#include "AbilitySystem/Components/PerkPointsComponent.h"
|
||||
#include "Player/AuraPlayerState.h"
|
||||
|
||||
#include "UI/WidgetController/Components/AttributeSetWCComponent.h"
|
||||
#include "UI/WidgetController/Components/PerkPointsWCComponent.h"
|
||||
|
||||
void UAttributeMenuController::Construct()
|
||||
{
|
||||
Super::Construct();
|
||||
|
||||
AttributeSetWcc = AddComponent<UAttributeSetWCComponent>("AttributeSet");
|
||||
PerkPointsWcc = AddComponent<UPerkPointsWCComponent>("PerkPoints");
|
||||
}
|
||||
|
||||
void UAttributeMenuController::ObservedActorSet()
|
||||
{
|
||||
Super::ObservedActorSet();
|
||||
|
||||
UPerkPointsComponent* PerkPoints = IsValid(AuraPlayerState) ? AuraPlayerState->GetPerkPoints() : nullptr;
|
||||
|
||||
if (IsValid(AttributeSetWcc))
|
||||
AttributeSetWcc->Initialize(AuraAbilitySystemComponent, AuraAttributeSet, AttributeInfo);
|
||||
|
||||
if (IsValid(PerkPointsWcc))
|
||||
PerkPointsWcc->Initialize(PerkPoints);
|
||||
}
|
||||
|
||||
void UAttributeMenuController::UpgradeAttribute(FGameplayTag AttributeTag)
|
||||
{
|
||||
if (IsValid(AuraPlayerState))
|
||||
{
|
||||
AuraPlayerState->Server_SpendAttributesPoint(1, AttributeTag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/AuraWidgetControllerBase.h"
|
||||
#include "Character/AuraCharacterBase.h"
|
||||
#include "Player/AuraPlayerState.h"
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
#include "AbilitySystem/Data/CharacterClassInfo.h"
|
||||
|
||||
|
||||
void UAuraWidgetControllerBase::ObservedActorSet()
|
||||
{
|
||||
Super::ObservedActorSet();
|
||||
|
||||
if (IsValid(Pawn))
|
||||
AuraCharacter = Cast<AAuraCharacterBase>(Pawn);
|
||||
|
||||
if (IsValid(PlayerState))
|
||||
AuraPlayerState = Cast<AAuraPlayerState>(PlayerState);
|
||||
|
||||
if (IsValid(AuraCharacter))
|
||||
{
|
||||
if (UAbilitySystemComponent* ASC = AuraCharacter->GetAbilitySystemComponent())
|
||||
AuraAbilitySystemComponent = Cast<UAuraAbilitySystemComponent>(ASC);
|
||||
if (UAttributeSet* AS = AuraCharacter->GetAttributeSet())
|
||||
AuraAttributeSet = Cast<UAuraAttributeSet>(AS);
|
||||
}
|
||||
else if (IsValid(AuraPlayerState))
|
||||
{
|
||||
if (UAbilitySystemComponent* ASC = AuraPlayerState->GetAbilitySystemComponent())
|
||||
AuraAbilitySystemComponent = Cast<UAuraAbilitySystemComponent>(ASC);
|
||||
AuraAttributeSet = AuraPlayerState->GetAttributeSet();
|
||||
}
|
||||
else if (IsValid(Actor))
|
||||
{
|
||||
AuraAbilitySystemComponent = Actor->GetComponentByClass<UAuraAbilitySystemComponent>();
|
||||
AuraAttributeSet = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UAbilityBook* UAuraWidgetControllerBase::RetrieveAbilityBook() const
|
||||
{
|
||||
if (!IsValid(AuraCharacter) || !IsValid(AuraCharacter->GetClassInfo()))
|
||||
return nullptr;
|
||||
|
||||
return AuraCharacter->GetClassInfo()->AbilitiesBook;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/Components/AbilitiesInputWCComponent.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/Data/AbilityBook.h"
|
||||
|
||||
|
||||
void UAbilitiesInputWCComponent::Initialize(UAuraAbilitySystemComponent* ASC, UAbilityBook* AB)
|
||||
{
|
||||
AbilitySystemComponent = ASC;
|
||||
AbilityBook = AB;
|
||||
}
|
||||
|
||||
void UAbilitiesInputWCComponent::BroadcastValues()
|
||||
{
|
||||
if (IsValid(AbilitySystemComponent))
|
||||
{
|
||||
OnAbilitySpecChange(AbilitySystemComponent, FGameplayAbilitySpec());
|
||||
}
|
||||
}
|
||||
|
||||
void UAbilitiesInputWCComponent::BindCallbacksToDependencies()
|
||||
{
|
||||
if (IsValid(AbilitySystemComponent))
|
||||
{
|
||||
AbilitySystemComponent->OnAbilitySpecChange.AddUObject(this, &ThisClass::OnAbilitySpecChange);
|
||||
AbilitySystemComponent->OnAbilitySpecRemoving.AddUObject(this, &ThisClass::OnAbilitySpecRemoving);
|
||||
}
|
||||
}
|
||||
|
||||
void UAbilitiesInputWCComponent::OnAbilitySpecChange(UAuraAbilitySystemComponent* AuraASC, const FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
TSet<FGameplayTag> NewAbilitiesInputTags;
|
||||
|
||||
// FForEachAbilityDelegate BroadcastDelegate;
|
||||
// BroadcastDelegate.BindLambda([this, AuraASC, &NewAbilitiesInputTags](FGameplayAbilitySpec& AbilitySpec)
|
||||
// {
|
||||
// // ...
|
||||
// });
|
||||
// AuraASC->ForEachAbilityDelegate(BroadcastDelegate);
|
||||
|
||||
AuraASC->ForEachAbilityLambda([this, AuraASC, &NewAbilitiesInputTags](FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
FGameplayTag AbilityTag = AuraASC->GetAbilityIDTagFromAbility(AbilitySpec.Ability);
|
||||
FAuraAbilityInfo Info;
|
||||
if (AbilityBook && AbilityTag.IsValid())
|
||||
{
|
||||
const FAuraAbilityInfo* FoundInfo = AbilityBook->GetAbilities().Find(AbilityTag);
|
||||
if (FoundInfo)
|
||||
{
|
||||
Info = *FoundInfo;
|
||||
}
|
||||
}
|
||||
FGameplayTag InputTag = AuraASC->GetInputTagFromAbilitySpec(AbilitySpec);
|
||||
NewAbilitiesInputTags.Add(InputTag);
|
||||
if (InputTag.IsValid())
|
||||
{
|
||||
OnAbilityInputInfoChange.Broadcast(InputTag, Info);
|
||||
}
|
||||
});
|
||||
|
||||
for (const FGameplayTag& InputTag : AbilitiesInputTags)
|
||||
{
|
||||
if (!NewAbilitiesInputTags.Contains(InputTag))
|
||||
{
|
||||
OnAbilityInputRemoved.Broadcast(InputTag);
|
||||
}
|
||||
}
|
||||
AbilitiesInputTags = NewAbilitiesInputTags;
|
||||
}
|
||||
|
||||
void UAbilitiesInputWCComponent::OnAbilitySpecRemoving(UAuraAbilitySystemComponent* AuraASC, const FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
FGameplayTag InputTag = AuraASC->GetInputTagFromAbilitySpec(AbilitySpec);
|
||||
if (InputTag.IsValid())
|
||||
{
|
||||
OnAbilityInputRemoved.Broadcast(InputTag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/Components/AbilitiesStatusWCComponent.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/Data/AbilityBook.h"
|
||||
|
||||
|
||||
void UAbilitiesStatusWCComponent::Initialize(UAuraAbilitySystemComponent* ASC, UAbilityBook* AB)
|
||||
{
|
||||
AbilitySystemComponent = ASC;
|
||||
AbilitiesBook = AB;
|
||||
}
|
||||
|
||||
void UAbilitiesStatusWCComponent::BroadcastValues()
|
||||
{
|
||||
if (AbilitySystemComponent)
|
||||
{
|
||||
AbilitySystemComponent->ForEachAbilityLambda([this](FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
OnAbilitySpecChange(AbilitySystemComponent, AbilitySpec);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void UAbilitiesStatusWCComponent::BindCallbacksToDependencies()
|
||||
{
|
||||
if (AbilitySystemComponent)
|
||||
{
|
||||
AbilitySystemComponent->OnAbilitySpecChange.AddUObject(this, &ThisClass::OnAbilitySpecChange);
|
||||
AbilitySystemComponent->OnAbilitySpecRemoving.AddUObject(this, &ThisClass::OnAbilitySpecRemoving);
|
||||
}
|
||||
}
|
||||
|
||||
void UAbilitiesStatusWCComponent::GetAbilityBookCategories(TSet<FName>& Names) const
|
||||
{
|
||||
if (AbilitiesBook)
|
||||
{
|
||||
for (const TPair<FGameplayTag, FAuraAbilityInfo>& BookLine : AbilitiesBook->GetAbilities())
|
||||
{
|
||||
Names.Add(BookLine.Value.TreeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAbilitiesStatusWCComponent::GetAllAbilitiesInformations(TArray<FAuraAbilityInfo>& AbilityBook) const
|
||||
{
|
||||
if (AbilitiesBook)
|
||||
{
|
||||
for (const TPair<FGameplayTag, FAuraAbilityInfo>& BookLine : AbilitiesBook->GetAbilities())
|
||||
{
|
||||
FAuraAbilityInfo AbilityInfo = BookLine.Value;
|
||||
AbilityBook.Add(AbilityInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAbilitiesStatusWCComponent::OnAbilitySpecChange(UAuraAbilitySystemComponent* AuraASC, const FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
const FGameplayTag AbilityID = AuraASC->GetAbilityIDTagFromAbility(AbilitySpec.Ability);
|
||||
if (AbilityID.IsValid())
|
||||
{
|
||||
const FGameplayTag StatusTag = AuraASC->GetStatusTagFromAbilitySpec(AbilitySpec);
|
||||
int32 Level = AbilitySpec.Level;
|
||||
OnAbilityStatusUpdated.Broadcast(AbilityID, StatusTag, Level);
|
||||
}
|
||||
}
|
||||
|
||||
void UAbilitiesStatusWCComponent::OnAbilitySpecRemoving(UAuraAbilitySystemComponent* AuraASC, const FGameplayAbilitySpec& AbilitySpec)
|
||||
{
|
||||
const FGameplayTag AbilityID = AuraASC->GetAbilityIDTagFromAbility(AbilitySpec.Ability);
|
||||
if (AbilityID.IsValid())
|
||||
{
|
||||
OnAbilityStatusRemoved.Broadcast(AbilityID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/Components/AttributeSetWCComponent.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
#include "AbilitySystem/AuraAttributeList.h"
|
||||
#include "AbilitySystem/Data/AttributeInfo.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "AuraGameplayTags.h"
|
||||
|
||||
|
||||
void UAttributeSetWCComponent::Initialize(UAuraAbilitySystemComponent* ASC, UAuraAttributeSet* AS, UAttributeInfo* AI)
|
||||
{
|
||||
AbilitySystemComponent = ASC;
|
||||
AttributeSet = AS;
|
||||
AttributeInfo = AI;
|
||||
}
|
||||
|
||||
void UAttributeSetWCComponent::BroadcastValues()
|
||||
{
|
||||
if (AttributeSet && AttributeInfo)
|
||||
{
|
||||
#define INITIAL_VALUE_BROADCAST(AttributeName, CategoryName) \
|
||||
FAuraAttributeInfo AttributeName##Info = AttributeInfo->FindAttributeInfoForTag(FAuraGameplayTags::Get().Attributes_##CategoryName##_##AttributeName, true); \
|
||||
AttributeName##Info.AttributeValue = AttributeSet->Get##AttributeName(); \
|
||||
OnAttributeInfoChange.Broadcast(AttributeName##Info);
|
||||
|
||||
FOREACH_ATTRIBUTE_Stats(INITIAL_VALUE_BROADCAST)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void UAttributeSetWCComponent::BindCallbacksToDependencies()
|
||||
{
|
||||
if (AbilitySystemComponent && AttributeSet && AttributeInfo)
|
||||
{
|
||||
|
||||
#define BIND_CALLBACK_ATTRIBUTE(AttributeName, CategoryName) \
|
||||
FAuraAttributeInfo Info##AttributeName = AttributeInfo->FindAttributeInfoForTag(FAuraGameplayTags::Get().Attributes_##CategoryName##_##AttributeName, true); \
|
||||
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AttributeSet->Get##AttributeName##Attribute()) \
|
||||
.AddLambda([this, Info##AttributeName](const FOnAttributeChangeData& Data) { \
|
||||
FAuraAttributeInfo NewInfo = Info##AttributeName; \
|
||||
NewInfo.AttributeValue = Data.NewValue; \
|
||||
OnAttributeInfoChange.Broadcast(NewInfo); \
|
||||
});
|
||||
|
||||
|
||||
FOREACH_ATTRIBUTE_Stats(BIND_CALLBACK_ATTRIBUTE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/Components/ExperienceWCComponent.h"
|
||||
#include "AbilitySystem/Components/LevelingExperienceComponent.h"
|
||||
|
||||
|
||||
void UExperienceWCComponent::Initialize(ULevelingExperienceComponent* LE)
|
||||
{
|
||||
LevelingExperience = LE;
|
||||
}
|
||||
|
||||
void UExperienceWCComponent::BroadcastValues()
|
||||
{
|
||||
if (LevelingExperience)
|
||||
{
|
||||
OnPlayerLevelUpdate.Broadcast(LevelingExperience->GetPlayerLevel());
|
||||
OnPlayerExperienceUpdate.Broadcast(LevelingExperience->GetExperience(), LevelingExperience->GetExperienceProgress());
|
||||
}
|
||||
}
|
||||
|
||||
void UExperienceWCComponent::BindCallbacksToDependencies()
|
||||
{
|
||||
if (LevelingExperience)
|
||||
{
|
||||
LevelingExperience->OnLevelChanged.AddDynamic(this, &ThisClass::OnLevelUpdate);
|
||||
LevelingExperience->OnExperienceChanged.AddDynamic(this, &ThisClass::OnExperienceUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
void UExperienceWCComponent::OnLevelUpdate(int32 NewLevel)
|
||||
{
|
||||
OnPlayerLevelUpdate.Broadcast(NewLevel);
|
||||
}
|
||||
|
||||
void UExperienceWCComponent::OnExperienceUpdate(int32 NewExperience, float NewProgress)
|
||||
{
|
||||
OnPlayerExperienceUpdate.Broadcast(NewExperience, NewProgress);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/Components/PerkPointsWCComponent.h"
|
||||
#include "AbilitySystem/Components/PerkPointsComponent.h"
|
||||
|
||||
|
||||
void UPerkPointsWCComponent::Initialize(UPerkPointsComponent* PP)
|
||||
{
|
||||
PerkPoints = PP;
|
||||
}
|
||||
|
||||
void UPerkPointsWCComponent::BroadcastValues()
|
||||
{
|
||||
if (PerkPoints)
|
||||
{
|
||||
OnAttributePointsChange.Broadcast(PerkPoints->GetAttributePoints());
|
||||
OnAbilityPointsChange.Broadcast(PerkPoints->GetAbilityPoints());
|
||||
}
|
||||
}
|
||||
|
||||
void UPerkPointsWCComponent::BindCallbacksToDependencies()
|
||||
{
|
||||
if (PerkPoints)
|
||||
{
|
||||
PerkPoints->OnAttributePointsChangedDelegate.AddDynamic(this, &ThisClass::OnAttributePointsChanged);
|
||||
PerkPoints->OnAbilityPointsChangedDelegate.AddDynamic(this, &ThisClass::OnAbilityPointsChanged);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void UPerkPointsWCComponent::OnAttributePointsChanged(int32 NewValue)
|
||||
{
|
||||
OnAttributePointsChange.Broadcast(NewValue);
|
||||
}
|
||||
|
||||
void UPerkPointsWCComponent::OnAbilityPointsChanged(int32 NewValue)
|
||||
{
|
||||
OnAbilityPointsChange.Broadcast(NewValue);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/Components/ReceivingEffectWCComponent.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/Data/EffectInfo.h"
|
||||
|
||||
void UReceivingEffectWCComponent::Initialize(UAuraAbilitySystemComponent* ASC, UEffectInfo* EI)
|
||||
{
|
||||
AbilitySystemComponent = ASC;
|
||||
EffectsInformations = EI;
|
||||
}
|
||||
|
||||
void UReceivingEffectWCComponent::BroadcastValues()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void UReceivingEffectWCComponent::BindCallbacksToDependencies()
|
||||
{
|
||||
if (AbilitySystemComponent)
|
||||
{
|
||||
AbilitySystemComponent->OnEffectAssetTags.AddLambda([this](const FGameplayTagContainer& AssetTags) {
|
||||
if (EffectsInformations)
|
||||
{
|
||||
for (const FGameplayTag& AssetTag : AssetTags)
|
||||
{
|
||||
FAuraEffectInfo* Info = EffectsInformations->EffectsInformations.Find(AssetTag);
|
||||
if (Info)
|
||||
{
|
||||
Info->MessageTag = AssetTag;
|
||||
OnNewEffectInfo.Broadcast(*Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/Components/VitalAttributesWCComponent.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
|
||||
|
||||
void UVitalAttributesWCComponent::Initialize(UAuraAbilitySystemComponent* ASC, UAuraAttributeSet* AS)
|
||||
{
|
||||
AbilitySystemComponent = ASC;
|
||||
AttributeSet = AS;
|
||||
}
|
||||
|
||||
void UVitalAttributesWCComponent::BroadcastValues()
|
||||
{
|
||||
if (AttributeSet)
|
||||
{
|
||||
OnHealthChanged.Broadcast(AttributeSet->GetHealth());
|
||||
OnMaxHealthChanged.Broadcast(AttributeSet->GetMaxHealth());
|
||||
OnManaChanged.Broadcast(AttributeSet->GetMana());
|
||||
OnMaxManaChanged.Broadcast(AttributeSet->GetMaxMana());
|
||||
}
|
||||
}
|
||||
|
||||
void UVitalAttributesWCComponent::BindCallbacksToDependencies()
|
||||
{
|
||||
if (AttributeSet && AbilitySystemComponent)
|
||||
{
|
||||
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AttributeSet->GetHealthAttribute())
|
||||
.AddLambda([this](const FOnAttributeChangeData& Data) {
|
||||
OnHealthChanged.Broadcast(Data.NewValue);
|
||||
});
|
||||
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AttributeSet->GetMaxHealthAttribute())
|
||||
.AddLambda([this](const FOnAttributeChangeData& Data) {
|
||||
OnMaxHealthChanged.Broadcast(Data.NewValue);
|
||||
});
|
||||
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AttributeSet->GetManaAttribute())
|
||||
.AddLambda([this](const FOnAttributeChangeData& Data) {
|
||||
OnManaChanged.Broadcast(Data.NewValue);
|
||||
});
|
||||
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AttributeSet->GetMaxManaAttribute())
|
||||
.AddLambda([this](const FOnAttributeChangeData& Data) {
|
||||
OnMaxManaChanged.Broadcast(Data.NewValue);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool UVitalAttributesWCComponent::IsManaRelevant() const
|
||||
{
|
||||
if (!IsValid(AttributeSet))
|
||||
return false;
|
||||
|
||||
return AttributeSet->GetMaxMana() > 0.0f;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Amasson
|
||||
|
||||
|
||||
#include "UI/WidgetController/OverlayController.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
#include "AbilitySystem/Data/AbilityBook.h"
|
||||
#include "AbilitySystem/Data/CharacterClassInfo.h"
|
||||
#include "Player/AuraPlayerState.h"
|
||||
#include "AbilitySystem/Components/LevelingExperienceComponent.h"
|
||||
#include "Character/AuraCharacterBase.h"
|
||||
|
||||
#include "UI/WidgetController/Components/VitalAttributesWCComponent.h"
|
||||
#include "UI/WidgetController/Components/ReceivingEffectWCComponent.h"
|
||||
#include "UI/WidgetController/Components/AbilitiesInputWCComponent.h"
|
||||
#include "UI/WidgetController/Components/ExperienceWCComponent.h"
|
||||
|
||||
void UOverlayController::Construct()
|
||||
{
|
||||
Super::Construct();
|
||||
|
||||
VitalAttributesWcc = AddComponent<UVitalAttributesWCComponent>("VitalAttributes");
|
||||
ReceivingEffectWcc = AddComponent<UReceivingEffectWCComponent>("ReceivingEffect");
|
||||
AbilitiesInputWcc = AddComponent<UAbilitiesInputWCComponent>("AbilitiesInput");
|
||||
ExperienceWcc = AddComponent<UExperienceWCComponent>("Experience");
|
||||
}
|
||||
|
||||
void UOverlayController::ObservedActorSet()
|
||||
{
|
||||
Super::ObservedActorSet();
|
||||
|
||||
AbilityBook = RetrieveAbilityBook();
|
||||
|
||||
if (IsValid(VitalAttributesWcc))
|
||||
VitalAttributesWcc->Initialize(AuraAbilitySystemComponent, AuraAttributeSet);
|
||||
|
||||
if (IsValid(ReceivingEffectWcc))
|
||||
ReceivingEffectWcc->Initialize(AuraAbilitySystemComponent, EffectsInformations);
|
||||
|
||||
if (IsValid(AbilitiesInputWcc))
|
||||
AbilitiesInputWcc->Initialize(AuraAbilitySystemComponent, AbilityBook);
|
||||
|
||||
ULevelingExperienceComponent* LevelingExperience = IsValid(AuraPlayerState) ? AuraPlayerState->GetLevelingExperience() : nullptr;
|
||||
if (IsValid(ExperienceWcc))
|
||||
ExperienceWcc->Initialize(LevelingExperience);
|
||||
}
|
||||
34
Source/Aura/Public/AI/AuraAIController.h
Normal file
34
Source/Aura/Public/AI/AuraAIController.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AIController.h"
|
||||
// #include "DetourCrowdAIController.h"
|
||||
#include "AuraAIController.generated.h"
|
||||
|
||||
class UBehaviorTreeComponent;
|
||||
class UBehaviorTree;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API AAuraAIController : public AAIController //public ADetourCrowdAIController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
AAuraAIController();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
virtual void OnPossess(APawn* PossessedPawn) override;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Behavior")
|
||||
TObjectPtr<UBehaviorTree> BehaviorTree;
|
||||
|
||||
};
|
||||
39
Source/Aura/Public/AI/Services/BTService_FindNearestPlayer.h
Normal file
39
Source/Aura/Public/AI/Services/BTService_FindNearestPlayer.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "BehaviorTree/Services/BTService_BlueprintBase.h"
|
||||
#include "BTService_FindNearestPlayer.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UBTService_FindNearestPlayer : public UBTService_BlueprintBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
|
||||
virtual void TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, EditAnywhere)
|
||||
FBlackboardKeySelector TargetToFollowSelector;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, EditAnywhere)
|
||||
FBlackboardKeySelector DistanceToTargetSelector;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, EditAnywhere)
|
||||
float MaxRange = 2000.0f;
|
||||
|
||||
virtual void OnNodeCreated() {
|
||||
TargetToFollowSelector.AddObjectFilter(this,
|
||||
GET_MEMBER_NAME_CHECKED(UBTService_FindNearestPlayer, TargetToFollowSelector),
|
||||
AActor::StaticClass());
|
||||
|
||||
DistanceToTargetSelector.AddFloatFilter(this,
|
||||
GET_MEMBER_NAME_CHECKED(UBTService_FindNearestPlayer, DistanceToTargetSelector));
|
||||
}
|
||||
|
||||
};
|
||||
19
Source/Aura/Public/AI/Tasks/BTTask_Attack.h
Normal file
19
Source/Aura/Public/AI/Tasks/BTTask_Attack.h
Normal file
@@ -0,0 +1,19 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "BehaviorTree/Tasks/BTTask_BlueprintBase.h"
|
||||
#include "BTTask_Attack.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UBTTask_Attack : public UBTTask_BlueprintBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/GameplayAbility.h"
|
||||
#include "AbilitySystem/Abilities/AuraGameplayAbility.h"
|
||||
#include "AuraDamageGameplayAbility.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraDamageGameplayAbility : public UAuraGameplayAbility
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Damage Ability")
|
||||
FGameplayEffectSpecHandle& AssignAbilityLevelDamagesSetByCallerMagnitude(UPARAM(Ref) FGameplayEffectSpecHandle& EffectSpecHandle, float Factor = 1.0f) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Damage Ability")
|
||||
void GetScaledDamages(TMap<FGameplayTag, float>& ScaledDamages, float Level = -1.0f) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Damage Ability")
|
||||
static TMap<FGameplayTag, float> MultiplyDamagesByFloat(const TMap<FGameplayTag, float>& InDamages, float Factor = 1.0f);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Damage Ability")
|
||||
static TMap<FGameplayTag, float> MultiplyDamageTypesByFloats(const TMap<FGameplayTag, float>& InDamages, const TMap<FGameplayTag, float>& Factors);
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Damage")
|
||||
TMap<FGameplayTag, FScalableFloat> Damages;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/GameplayAbility.h"
|
||||
#include "AuraGameplayAbility.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraGameplayAbility : public UGameplayAbility
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
// virtual void ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Projectile")
|
||||
FTransform MakeProjectileSpawnTransform(FGameplayTag SocketTagName, const FVector& TargetLocation, float Pitch = 0.0f) const;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystem/Abilities/AuraGameplayAbility.h"
|
||||
#include "AuraSummonAbility.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSpawnedCharactersChangeSignature, UAuraSummonAbility*, SummonAbility);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraSummonAbility : public UAuraGameplayAbility
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UAuraSummonAbility();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Summon")
|
||||
ACharacter* SummonCharacter(TSubclassOf<ACharacter> Class, const FVector& Location, float YawOffset = 0);
|
||||
|
||||
UFUNCTION()
|
||||
void SummonDestroyed(AActor* DestroyedActor);
|
||||
|
||||
/* Spawn Locations */
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
TArray<FVector> GetSpawnLocations();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "SummonLocation")
|
||||
int32 SpawnCount = 3;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "SummonLocation")
|
||||
float SpawnMinDistance = 100.0f;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "SummonLocation")
|
||||
float SpawnMaxDistance = 200.0f;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "SummonLocation")
|
||||
float SpawnSpreadAngle = 80.0f;
|
||||
|
||||
/* Spawned Characters */
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "State")
|
||||
TArray<TObjectPtr<ACharacter>> SpawnedCharacters;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FSpawnedCharactersChangeSignature OnSpawnedCharactersChange;
|
||||
|
||||
};
|
||||
152
Source/Aura/Public/AbilitySystem/AbilitySystemTypes.h
Normal file
152
Source/Aura/Public/AbilitySystem/AbilitySystemTypes.h
Normal file
@@ -0,0 +1,152 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayEffectTypes.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "AbilitySystemTypes.generated.h"
|
||||
|
||||
class UAbilitySystemComponent;
|
||||
class UGameplayEffect;
|
||||
|
||||
USTRUCT(BlueprintType, Blueprintable)
|
||||
struct AURA_API FGameplayEffectParameters
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TSubclassOf<UGameplayEffect> Class = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
float Level = 1;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TMap<FGameplayTag, float> SetByCallerMagnitudes;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FVector HitImpulse = FVector::ZeroVector;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FHitResult HitCollision;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
TObjectPtr<UGameplayAbility> SourceAbility;
|
||||
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType, Blueprintable)
|
||||
struct AURA_API FGameplayAbilityGrant
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TSubclassOf<UGameplayAbility> Class = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 Level = 1;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FGameplayTag InputTag = FGameplayTag::EmptyTag;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool ActiveOnGranted = false;
|
||||
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType, Blueprintable)
|
||||
struct FEffectProperties
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FGameplayEffectContextHandle EffectContextHandle;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<UAbilitySystemComponent> SourceASC = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<AActor> SourceAvatarActor = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<AController> SourceController = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<ACharacter> SourceCharacter = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<UAbilitySystemComponent> TargetASC = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<AActor> TargetAvatarActor = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<AController> TargetController = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<ACharacter> TargetCharacter = nullptr;
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FAuraGameplayEffectContext : public FGameplayEffectContext
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
/** Returns the actual struct used for serialization, subclasses must override this! */
|
||||
virtual UScriptStruct* GetScriptStruct() const
|
||||
{
|
||||
return FGameplayEffectContext::StaticStruct();
|
||||
}
|
||||
|
||||
/** Creates a copy of this context, used to duplicate for later modifications */
|
||||
virtual FGameplayEffectContext* Duplicate() const;
|
||||
|
||||
/** Custom serialization, subclasses must override this */
|
||||
virtual bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess);
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
|
||||
bool bIsBlockedHit = false;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
|
||||
bool bIsCriticalHit = false;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
|
||||
FVector HitImpulse = FVector::ZeroVector;
|
||||
|
||||
};
|
||||
|
||||
template<>
|
||||
struct TStructOpsTypeTraits< FAuraGameplayEffectContext > : public TStructOpsTypeTraitsBase2< FAuraGameplayEffectContext >
|
||||
{
|
||||
enum
|
||||
{
|
||||
WithNetSerializer = true,
|
||||
WithCopy = true // Necessary so that TSharedPtr<FHitResult> Data is copied around
|
||||
};
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FFloatingDamage
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TWeakObjectPtr<AActor> Target;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool bIsBlockedHit = false;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool bIsCriticalHit = false;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
float Damages = 0.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FGameplayTagContainer Tags;
|
||||
};
|
||||
111
Source/Aura/Public/AbilitySystem/AuraAbilitySystemComponent.h
Normal file
111
Source/Aura/Public/AbilitySystem/AuraAbilitySystemComponent.h
Normal file
@@ -0,0 +1,111 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AbilitySystemTypes.h"
|
||||
#include "AuraAbilitySystemComponent.generated.h"
|
||||
|
||||
DECLARE_MULTICAST_DELEGATE_OneParam(FEffectAssetTagsSignature, const FGameplayTagContainer&);
|
||||
DECLARE_MULTICAST_DELEGATE_TwoParams(FAbilitySpecChangeSignature, UAuraAbilitySystemComponent*, const FGameplayAbilitySpec&);
|
||||
DECLARE_MULTICAST_DELEGATE_TwoParams(FAbilitySpecRemovingSignature, UAuraAbilitySystemComponent*, const FGameplayAbilitySpec&);
|
||||
DECLARE_DELEGATE_OneParam(FForEachAbilityDelegate, const FGameplayAbilitySpec&)
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraAbilitySystemComponent : public UAbilitySystemComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
FEffectAssetTagsSignature OnEffectAssetTags;
|
||||
FAbilitySpecChangeSignature OnAbilitySpecChange;
|
||||
FAbilitySpecRemovingSignature OnAbilitySpecRemoving;
|
||||
|
||||
/* AbilityActorInfoSet */
|
||||
UFUNCTION()
|
||||
void AbilitySystemInitDone();
|
||||
|
||||
bool bStartupAbilitiesGiven = false;
|
||||
|
||||
void GrantAbility(const FGameplayAbilityGrant& Ability);
|
||||
void GrantStartupAbilities(const TArray<FGameplayAbilityGrant>& Abilities);
|
||||
|
||||
void AbilityInputTagPressed(const FGameplayTag& InputTag);
|
||||
void AbilityInputTagHeld(const FGameplayTag& InputTag);
|
||||
void AbilityInputTagReleased(const FGameplayTag& InputTag);
|
||||
void ForEachAbilityDelegate(const FForEachAbilityDelegate& Delegate);
|
||||
void ForEachAbilityLambda(std::function<void (FGameplayAbilitySpec&)> Func);
|
||||
|
||||
/** Receiving Effect Interception */
|
||||
virtual FActiveGameplayEffectHandle ApplyGameplayEffectSpecToSelf(const FGameplayEffectSpec& GameplayEffect, FPredictionKey PredictionKey = FPredictionKey()) override;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Interceptor")
|
||||
void AddGameplayEffectInterceptor(UObject* Interceptor);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Interceptor")
|
||||
void RemoveGameplayEffectInterceptor(UObject* Interceptor);
|
||||
|
||||
/** Ability Tags */
|
||||
static bool AbilityHasIDTag(const UGameplayAbility* Ability);
|
||||
static FGameplayTag GetAbilityIDTagFromAbility(const UGameplayAbility* Ability);
|
||||
static bool AbilitySpecHasInputTag(const FGameplayAbilitySpec& AbilitySpec);
|
||||
static FGameplayTag GetInputTagFromAbilitySpec(const FGameplayAbilitySpec& AbilitySpec);
|
||||
static bool AbilityHasCooldownTag(const UGameplayAbility* Ability);
|
||||
static FGameplayTag GetCooldownTagFromAbility(const UGameplayAbility* Ability);
|
||||
static bool AbilitySpecHasStatusTag(const FGameplayAbilitySpec& AbilitySpec);
|
||||
static FGameplayTag GetStatusTagFromAbilitySpec(const FGameplayAbilitySpec& AbilitySpec);
|
||||
static bool AbilityHasTypeTag(const UGameplayAbility* Ability);
|
||||
static FGameplayTag GetTypeTagFromAbility(const UGameplayAbility* Ability);
|
||||
/** End Ability Tags */
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Character Class")
|
||||
TArray<FActiveGameplayEffectHandle> BaseEffectsHandles;
|
||||
|
||||
/** Attributes Modifications */
|
||||
void AddAttributePoints(float Count, const FGameplayTag& AttributeTag);
|
||||
|
||||
/** Ability Level */
|
||||
void SetLevelForAbilitySpec(FGameplayAbilitySpec& AbilitySpec, int32 NewLevel);
|
||||
void AddLevelForAbilitySpec(FGameplayAbilitySpec& AbilitySpec, int32 AddLevel);
|
||||
|
||||
/** Managing Tags */
|
||||
FGameplayAbilitySpec* GetAbilitySpecForAbilityIDTag(const FGameplayTag& AbilityIDTag);
|
||||
void GetAbilitySpecsForInputTag(const FGameplayTag& InputTag, TArray<FGameplayAbilitySpec*>& AbilitySpecs);
|
||||
|
||||
/** Manage Status Tags */
|
||||
bool GetStatusTagForAbilityIDTag(const FGameplayTag AbilityIDTag, FGameplayTag& StatusTag);
|
||||
|
||||
/** Manage Input Tags */
|
||||
void RemoveInputTagFromAbilitySpec(FGameplayAbilitySpec& AbilitySpec, bool bBroadcastUpdate = true);
|
||||
void ClearAbilitiesFromInputTag(const FGameplayTag& InputTag);
|
||||
void AssignInputTagToAbilitySpec(const FGameplayTag& InputTag, FGameplayAbilitySpec& AbilitySpec);
|
||||
|
||||
protected:
|
||||
|
||||
void UpdateStatusTagForAbilitySpec(FGameplayAbilitySpec& AbilitySpec, bool bBroadcastUpdate = true);
|
||||
|
||||
void SetStatusTagForAbilitySpec(FGameplayAbilitySpec& AbilitySpec, const FGameplayTag& StatusTag, bool bBroadcastUpdate = true);
|
||||
|
||||
void ActivateAbilityIfEquippedPassive(FGameplayAbilitySpec& AbilitySpec);
|
||||
|
||||
virtual void OnRep_ActivateAbilities() override;
|
||||
virtual void OnGiveAbility(FGameplayAbilitySpec& Spec) override;
|
||||
virtual void OnRemoveAbility(FGameplayAbilitySpec& Spec) override;
|
||||
|
||||
UFUNCTION(Client, Reliable)
|
||||
void ClientOnEffectApplied(UAbilitySystemComponent* AbilitySystemComponent, const FGameplayEffectSpec& EffectSpec, FActiveGameplayEffectHandle EffectHandle);
|
||||
|
||||
UFUNCTION(Client, Reliable)
|
||||
void Client_UpdateAbilityStatus(const FGameplayTag& AbilityID, const FGameplayTag& Status, int32 Level);
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY()
|
||||
TArray<TObjectPtr<UObject>> EffectInterceptors;
|
||||
|
||||
};
|
||||
18
Source/Aura/Public/AbilitySystem/AuraAbilitySystemGlobals.h
Normal file
18
Source/Aura/Public/AbilitySystem/AuraAbilitySystemGlobals.h
Normal file
@@ -0,0 +1,18 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "AuraAbilitySystemGlobals.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraAbilitySystemGlobals : public UAbilitySystemGlobals
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
virtual FGameplayEffectContext* AllocGameplayEffectContext() const override;
|
||||
};
|
||||
119
Source/Aura/Public/AbilitySystem/AuraAbilitySystemLibrary.h
Normal file
119
Source/Aura/Public/AbilitySystem/AuraAbilitySystemLibrary.h
Normal file
@@ -0,0 +1,119 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "AbilitySystemTypes.h"
|
||||
#include "AuraAbilitySystemLibrary.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_DELEGATE_OneParam(FGameplayTagDelegate, const FGameplayTag&, Tag);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraAbilitySystemLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "Aura Gameplay Tag|Damage")
|
||||
static const TArray<FGameplayTag>& GetAllDamageTags();
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "Aura Gameplay Tag|Damage")
|
||||
static void GetResistanceTagForDamageTag(FGameplayTag DamageTag, FGameplayTag& ResistanceTag, bool& bFound);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "AuraAbilitySystemLibrary|Effect Context")
|
||||
static bool IsBlockedHit(const FGameplayEffectContextHandle& EffectContextHandle);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Effect Context")
|
||||
static void SetIsBlockedHit(UPARAM(Ref) FGameplayEffectContextHandle& EffectContextHandle, bool bNewIsBlockedHit);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "AuraAbilitySystemLibrary|Effect Context")
|
||||
static bool IsCriticalHit(const FGameplayEffectContextHandle& EffectContextHandle);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Effect Context")
|
||||
static void SetIsCriticalHit(UPARAM(Ref) FGameplayEffectContextHandle& EffectContextHandle, bool bNewIsCriticalHit);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "AuraAbilitySystemLibrary|Effect Context")
|
||||
static FVector GetHitImpulse(const FGameplayEffectContextHandle& EffectContextHandle);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Effect Context")
|
||||
static void SetHitImpulse(UPARAM(Ref) FGameplayEffectContextHandle& EffectContextHandle, FVector NewHitImpulse);
|
||||
|
||||
|
||||
/** For Each Attributes */
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Attributes")
|
||||
static void ForEachVitalAttributes(FGameplayTagDelegate Function);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Attributes")
|
||||
static void ForEachPrimaryAttributes(FGameplayTagDelegate Function);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Attributes")
|
||||
static void ForEachSecondaryAttributes(FGameplayTagDelegate Function);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Attributes")
|
||||
static void ForEachMagicalResistanceAttributes(FGameplayTagDelegate Function);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Attributes")
|
||||
static void ForEachResistanceAttributes(FGameplayTagDelegate Function);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Attributes")
|
||||
static void ForEachMetaAttributes(FGameplayTagDelegate Function);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Attributes")
|
||||
static void ForEachReplicatedAttributes(FGameplayTagDelegate Function);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Attributes")
|
||||
static void ForEachStatsAttributes(FGameplayTagDelegate Function);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Attributes")
|
||||
static void ForEachAttributes(FGameplayTagDelegate Function);
|
||||
|
||||
/** End For Each Attributes */
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|GameplayTags")
|
||||
static bool RemoveMatchingTagsFromTagContainer(FGameplayTagContainer& TagContainer, FGameplayTag MatchTag);
|
||||
|
||||
|
||||
/** Extract Infos From Ability Class */
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "AuraAbilitySystemLibrary|Abilities")
|
||||
static FGameplayTag GetAbilityIdFromAbilityClass(TSubclassOf<UGameplayAbility> AbilityClass);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "AuraAbilitySystemLibrary|Abilities")
|
||||
static FGameplayTag GetTypeTagFromAbilityClass(TSubclassOf<UGameplayAbility> AbilityClass);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "AuraAbilitySystemLibrary|Abilities")
|
||||
static FGameplayTag GetCooldownTagFromAbilityClass(TSubclassOf<UGameplayAbility> AbilityClass);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "AuraAbilitySystemLibrary|Abilities")
|
||||
static void GetAbilityDamagesAtLevel(TSubclassOf<class UAuraDamageGameplayAbility> DamageAbilityClass, float Level, TMap<FGameplayTag, float>& Damages);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "AuraAbilitySystemLibrary|Abilities")
|
||||
static void GetAbilityCostAtLevel(TSubclassOf<UGameplayAbility> AbilityClass, float Level, TMap<FString, float>& Costs);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "AuraAbilitySystemLibrary|Abilities")
|
||||
static float GetAbilityCooldownTimeAtLevel(TSubclassOf<UGameplayAbility> AbilityClass, float Level);
|
||||
|
||||
|
||||
/** Extract Infos From Effect Class */
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "AuraAbilitySystemLibrary|Effects")
|
||||
static bool CheckGameplayEffectSpecHasTag(const FGameplayEffectSpec& EffectSpec, FGameplayTag Tag);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "AuraAbilitySystemLibrary|Effects")
|
||||
static void GetContextFromGameplayEffectSpec(const FGameplayEffectSpec& EffectSpec, FGameplayEffectContextHandle& Context);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "AuraAbilitySystemLibrary|Effects")
|
||||
static void ExtractPropertiesFromGameplayEffectContextHandle(const FGameplayEffectContextHandle& Context, FEffectProperties& Properties);
|
||||
|
||||
/** Effects */
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "AuraAbilitySystemLibrary|Effects")
|
||||
static FActiveGameplayEffectHandle ApplyGameplayEffectWithParameters(const FGameplayEffectParameters& EffectParams, UAbilitySystemComponent* SourceASC, UAbilitySystemComponent* TargetASC);
|
||||
|
||||
};
|
||||
82
Source/Aura/Public/AbilitySystem/AuraAttributeList.h
Normal file
82
Source/Aura/Public/AbilitySystem/AuraAttributeList.h
Normal file
@@ -0,0 +1,82 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* How to use:
|
||||
* To define an expression that should execute on all attribute
|
||||
*
|
||||
* 1. Create a macro that takes two parameters
|
||||
* #define MyDefinition(AttributeName, CategoryName) \
|
||||
* std::cout << "I love my " << #AttributeName << " that belongs to " << #CategoryName << std::endl; \
|
||||
*
|
||||
* 2. Use the correct FOREACH call
|
||||
* FOREACH_ATTRIBUTE_All(MyDefinition)
|
||||
*
|
||||
* 3. Attributes list are All, Vital, Primary, Secondary, MagicalResistance, Resistance, Meta, Replicated, Stats
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Files using attribute set list boilerplate :
|
||||
* - Public/AbilitySystem/AuraAttributeSet.h
|
||||
* - Public/AbilitySystem/EffectCalculation/ExecCalc_AttributeBased.h
|
||||
* - Private/AbilitySystem/EffectCalculation/ExecCalc_AttributeBased.cpp
|
||||
*/
|
||||
|
||||
#define FOREACH_ATTRIBUTE_Vital(FunctionExpression) \
|
||||
FunctionExpression(Health, Vital) \
|
||||
FunctionExpression(Mana, Vital) \
|
||||
|
||||
#define FOREACH_ATTRIBUTE_Primary(FunctionExpression) \
|
||||
FunctionExpression(Strength, Primary) \
|
||||
FunctionExpression(Intelligence, Primary) \
|
||||
FunctionExpression(Resilience, Primary) \
|
||||
FunctionExpression(Vigor, Primary) \
|
||||
|
||||
#define FOREACH_ATTRIBUTE_Secondary(FunctionExpression) \
|
||||
FunctionExpression(Armor, Secondary) \
|
||||
FunctionExpression(ArmorPenetration, Secondary) \
|
||||
FunctionExpression(BlockChance, Secondary) \
|
||||
FunctionExpression(CriticalHitChance, Secondary) \
|
||||
FunctionExpression(CriticalHitDamage, Secondary) \
|
||||
FunctionExpression(CriticalHitResistance, Secondary) \
|
||||
FunctionExpression(HealthRegeneration, Secondary) \
|
||||
FunctionExpression(ManaRegeneration, Secondary) \
|
||||
FunctionExpression(MaxHealth, Secondary) \
|
||||
FunctionExpression(MaxMana, Secondary) \
|
||||
|
||||
#define FOREACH_ATTRIBUTE_MagicalResistance(FunctionExpression) \
|
||||
FunctionExpression(FireRes, Resistance) \
|
||||
FunctionExpression(IceRes, Resistance) \
|
||||
FunctionExpression(ShockRes, Resistance) \
|
||||
FunctionExpression(ShadowRes, Resistance) \
|
||||
FunctionExpression(ArcaneRes, Resistance) \
|
||||
|
||||
#define FOREACH_ATTRIBUTE_Resistance(FunctionExpression) \
|
||||
FunctionExpression(PhysicalRes, Resistance) \
|
||||
FunctionExpression(MagicalRes, Resistance) \
|
||||
FOREACH_ATTRIBUTE_MagicalResistance(FunctionExpression) \
|
||||
|
||||
#define FOREACH_ATTRIBUTE_Meta(FunctionExpression) \
|
||||
FunctionExpression(IncomingDamage, Meta) \
|
||||
FunctionExpression(IncomingXP, Meta) \
|
||||
|
||||
#define FOREACH_ATTRIBUTE_Replicated(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Vital(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Primary(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Secondary(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Resistance(FunctionExpression) \
|
||||
|
||||
#define FOREACH_ATTRIBUTE_Stats(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Primary(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Secondary(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Resistance(FunctionExpression) \
|
||||
|
||||
#define FOREACH_ATTRIBUTE_All(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Vital(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Primary(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Secondary(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Resistance(FunctionExpression) \
|
||||
FOREACH_ATTRIBUTE_Meta(FunctionExpression) \
|
||||
|
||||
177
Source/Aura/Public/AbilitySystem/AuraAttributeSet.h
Normal file
177
Source/Aura/Public/AbilitySystem/AuraAttributeSet.h
Normal file
@@ -0,0 +1,177 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AbilitySystemTypes.h"
|
||||
#include "AuraAttributeSet.generated.h"
|
||||
|
||||
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraAttributeSet : public UAttributeSet
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UAuraAttributeSet();
|
||||
|
||||
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
||||
|
||||
virtual void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) override;
|
||||
virtual void PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue) override;
|
||||
|
||||
virtual void PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data) override;
|
||||
|
||||
/** Vital Attributes */
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Health, Category = "Vital Attributes")
|
||||
FGameplayAttributeData Health;
|
||||
UFUNCTION() void OnRep_Health(const FGameplayAttributeData& OldHealth) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, Health);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Mana, Category = "Vital Attributes")
|
||||
FGameplayAttributeData Mana;
|
||||
UFUNCTION() void OnRep_Mana(const FGameplayAttributeData& OldMana) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, Mana);
|
||||
|
||||
/** Primary Attributes */
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Strength, Category = "Primary Attributes")
|
||||
FGameplayAttributeData Strength;
|
||||
UFUNCTION() void OnRep_Strength(const FGameplayAttributeData& OldStrength) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, Strength);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Intelligence, Category = "Primary Attributes")
|
||||
FGameplayAttributeData Intelligence;
|
||||
UFUNCTION() void OnRep_Intelligence(const FGameplayAttributeData& OldIntelligence) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, Intelligence);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Resilience, Category = "Primary Attributes")
|
||||
FGameplayAttributeData Resilience;
|
||||
UFUNCTION() void OnRep_Resilience(const FGameplayAttributeData& OldResilience) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, Resilience);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Vigor, Category = "Primary Attributes")
|
||||
FGameplayAttributeData Vigor;
|
||||
UFUNCTION() void OnRep_Vigor(const FGameplayAttributeData& OldVigor) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, Vigor);
|
||||
|
||||
/** Secondary Attributes */
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Armor, Category = "Secondary Attributes")
|
||||
FGameplayAttributeData Armor;
|
||||
UFUNCTION() void OnRep_Armor(const FGameplayAttributeData& OldArmor) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, Armor);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_ArmorPenetration, Category = "Secondary Attributes")
|
||||
FGameplayAttributeData ArmorPenetration;
|
||||
UFUNCTION() void OnRep_ArmorPenetration(const FGameplayAttributeData& OldArmorPenetration) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, ArmorPenetration);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_BlockChance, Category = "Secondary Attributes")
|
||||
FGameplayAttributeData BlockChance;
|
||||
UFUNCTION() void OnRep_BlockChance(const FGameplayAttributeData& OldBlockChance) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, BlockChance);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_CriticalHitChance, Category = "Secondary Attributes")
|
||||
FGameplayAttributeData CriticalHitChance;
|
||||
UFUNCTION() void OnRep_CriticalHitChance(const FGameplayAttributeData& OldCriticalHitChance) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, CriticalHitChance);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_CriticalHitDamage, Category = "Secondary Attributes")
|
||||
FGameplayAttributeData CriticalHitDamage;
|
||||
UFUNCTION() void OnRep_CriticalHitDamage(const FGameplayAttributeData& OldCriticalHitDamage) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, CriticalHitDamage);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_CriticalHitResistance, Category = "Secondary Attributes")
|
||||
FGameplayAttributeData CriticalHitResistance;
|
||||
UFUNCTION() void OnRep_CriticalHitResistance(const FGameplayAttributeData& OldCriticalHitResistance) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, CriticalHitResistance);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_HealthRegeneration, Category = "Secondary Attributes")
|
||||
FGameplayAttributeData HealthRegeneration;
|
||||
UFUNCTION() void OnRep_HealthRegeneration(const FGameplayAttributeData& OldHealthRegeneration) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, HealthRegeneration);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_ManaRegeneration, Category = "Secondary Attributes")
|
||||
FGameplayAttributeData ManaRegeneration;
|
||||
UFUNCTION() void OnRep_ManaRegeneration(const FGameplayAttributeData& OldManaRegeneration) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, ManaRegeneration);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_MaxHealth, Category = "Secondary Attributes")
|
||||
FGameplayAttributeData MaxHealth;
|
||||
UFUNCTION() void OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, MaxHealth);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_MaxMana, Category = "Secondary Attributes")
|
||||
FGameplayAttributeData MaxMana;
|
||||
UFUNCTION() void OnRep_MaxMana(const FGameplayAttributeData& OldMaxMana) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, MaxMana);
|
||||
|
||||
/** Resistance Attributes */
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_PhysicalRes, Category = "Resistance Attributes")
|
||||
FGameplayAttributeData PhysicalRes;
|
||||
UFUNCTION() void OnRep_PhysicalRes(const FGameplayAttributeData& OldPhysicalRes) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, PhysicalRes);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_MagicalRes, Category = "Resistance Attributes")
|
||||
FGameplayAttributeData MagicalRes;
|
||||
UFUNCTION() void OnRep_MagicalRes(const FGameplayAttributeData& OldMagicalRes) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, MagicalRes);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_FireRes, Category = "Resistance Attributes")
|
||||
FGameplayAttributeData FireRes;
|
||||
UFUNCTION() void OnRep_FireRes(const FGameplayAttributeData& OldFireRes) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, FireRes);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_IceRes, Category = "Resistance Attributes")
|
||||
FGameplayAttributeData IceRes;
|
||||
UFUNCTION() void OnRep_IceRes(const FGameplayAttributeData& OldIceRes) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, IceRes);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_ShockRes, Category = "Resistance Attributes")
|
||||
FGameplayAttributeData ShockRes;
|
||||
UFUNCTION() void OnRep_ShockRes(const FGameplayAttributeData& OldShockRes) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, ShockRes);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_ShadowRes, Category = "Resistance Attributes")
|
||||
FGameplayAttributeData ShadowRes;
|
||||
UFUNCTION() void OnRep_ShadowRes(const FGameplayAttributeData& OldShadowRes) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, ShadowRes);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_ArcaneRes, Category = "Resistance Attributes")
|
||||
FGameplayAttributeData ArcaneRes;
|
||||
UFUNCTION() void OnRep_ArcaneRes(const FGameplayAttributeData& OldArcaneRes) const;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, ArcaneRes);
|
||||
|
||||
/** Meta Attributes */
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Meta Attributes")
|
||||
FGameplayAttributeData IncomingDamage;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, IncomingDamage);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Meta Attributes")
|
||||
FGameplayAttributeData IncomingXP;
|
||||
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, IncomingXP);
|
||||
|
||||
private:
|
||||
|
||||
void HandleModificationData_IncomingDamage(const FGameplayEffectModCallbackData& Data);
|
||||
void HandleModificationData_IncomingXP(const FGameplayEffectModCallbackData& Data);
|
||||
|
||||
void SendXPEvent(const FEffectProperties& Props, int32 DeathXp);
|
||||
void ExtractEffectModProperties(const FGameplayEffectModCallbackData& Data, FEffectProperties& Props) const;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "GameplayEffectInterceptor.generated.h"
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE(MinimalAPI)
|
||||
class UGameplayEffectInterceptor : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class AURA_API IGameplayEffectInterceptor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Effect Interceptor")
|
||||
void WillApplyGameplayEffectSpec(const FGameplayEffectSpec& GameplayEffect, bool& bIntercepted);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "LevelingExperienceComponent.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnLevelChangedSignature, int32, NewLevel);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnExperienceChangedSignature, int32, TotalExperience, float, Progress);
|
||||
|
||||
|
||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
class AURA_API ULevelingExperienceComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
|
||||
ULevelingExperienceComponent();
|
||||
|
||||
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
||||
|
||||
/* Level */
|
||||
FORCEINLINE int32 GetPlayerLevel() const { return Level; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Level")
|
||||
void AddToLevel(int32 AddLevel, bool KeepProgressPercent = true);
|
||||
UFUNCTION(BlueprintCallable, Category = "Level")
|
||||
void SetLevel(int32 NewLevel, bool KeepProgressPercent = true);
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category = "Level")
|
||||
FOnLevelChangedSignature OnLevelChanged;
|
||||
|
||||
/* Experience */
|
||||
FORCEINLINE int32 GetExperience() const { return Experience; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Experience")
|
||||
void AddToExperience(int32 AddExperience);
|
||||
UFUNCTION(BlueprintCallable, Category = "Experience")
|
||||
void SetExperience(int32 NewExperience);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Experience")
|
||||
float GetExperienceProgress() const;
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category = "Experience")
|
||||
FOnExperienceChangedSignature OnExperienceChanged;
|
||||
|
||||
/* Leveling Infos */
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Data")
|
||||
TObjectPtr<class ULevelingInfo> LevelingInfo;
|
||||
|
||||
private:
|
||||
|
||||
void UpdateLevel(bool ForwardOnly);
|
||||
|
||||
/* Level */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, ReplicatedUsing = OnRep_Level, Category = "Level", meta = (AllowPrivateAccess = true))
|
||||
int32 Level = 1;
|
||||
UFUNCTION() void OnRep_Level(int32 OldLevel) const;
|
||||
|
||||
/* Experience */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, ReplicatedUsing = OnRep_Experience, Category = "Experience", meta = (AllowPrivateAccess = true))
|
||||
int32 Experience = 0;
|
||||
UFUNCTION() void OnRep_Experience(int32 OldExperience) const;
|
||||
|
||||
/* Cached Experiences */
|
||||
int32 CachedLevel = -1;
|
||||
int32 CachedMinExperience;
|
||||
int32 CachedMaxExperience;
|
||||
|
||||
void UpdateCacheLevel();
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "PerkPointsComponent.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPointChangedSignature, int32, NewPoints);
|
||||
|
||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
class AURA_API UPerkPointsComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UPerkPointsComponent();
|
||||
|
||||
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
||||
|
||||
/** Attribute Points */
|
||||
|
||||
FORCEINLINE int32 GetAttributePoints() const { return AttributePoints; }
|
||||
UFUNCTION(BlueprintCallable, Category = "Attributes")
|
||||
void AddToAttributePoints(int32 AddingPoints);
|
||||
UFUNCTION(BlueprintCallable, Category = "Attributes")
|
||||
int32 SpendAttributePoints(int32 Count);
|
||||
UFUNCTION(BlueprintCallable, Category = "Attributes")
|
||||
void SetAttributePoints(int32 NewPoints);
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category = "Attributes")
|
||||
FOnPointChangedSignature OnAttributePointsChangedDelegate;
|
||||
|
||||
/** Ability Points */
|
||||
|
||||
FORCEINLINE int32 GetAbilityPoints() const { return AbilityPoints; }
|
||||
UFUNCTION(BlueprintCallable, Category = "Abilities")
|
||||
void AddToAbilityPoints(int32 AddingPoints);
|
||||
UFUNCTION(BlueprintCallable, Category = "Abilities")
|
||||
int32 SpendAbilityPoints(int32 Count);
|
||||
UFUNCTION(BlueprintCallable, Category = "Abilities")
|
||||
void SetAbilityPoints(int32 NewPoints);
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category = "Abilities")
|
||||
FOnPointChangedSignature OnAbilityPointsChangedDelegate;
|
||||
|
||||
protected:
|
||||
|
||||
/** Attribute Points */
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_AttributePoints, Category = "Attributes")
|
||||
int32 AttributePoints = 0;
|
||||
UFUNCTION() void OnRep_AttributePoints(int32 OldAttributePoints) const;
|
||||
|
||||
/** Ability Points */
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_AbilityPoints, Category = "Abilitys")
|
||||
int32 AbilityPoints = 0;
|
||||
UFUNCTION() void OnRep_AbilityPoints(int32 OldAbilityPoints) const;
|
||||
|
||||
};
|
||||
79
Source/Aura/Public/AbilitySystem/Data/AbilityBook.h
Normal file
79
Source/Aura/Public/AbilitySystem/Data/AbilityBook.h
Normal file
@@ -0,0 +1,79 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "AbilitySystem/AbilitySystemTypes.h"
|
||||
#include "AuraGameplayTags.h"
|
||||
#include "AbilityBook.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FAuraAbilityRequirement
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Player Level")
|
||||
int32 MiminalPlayerLevel = 1;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Abilities")
|
||||
TArray<FGameplayAbilityGrant> RequiredAbilities;
|
||||
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FAuraAbilityInfo
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Ability")
|
||||
TSubclassOf<class UGameplayAbility> Ability;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Icon")
|
||||
TObjectPtr<const UTexture2D> Icon = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Icon")
|
||||
TObjectPtr<const UMaterialInterface> Background = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Description")
|
||||
FText Name = FText();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Description")
|
||||
FText Description = FText();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Levels")
|
||||
TArray<FAuraAbilityRequirement> RequirementsForLevels;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "TreeLocation")
|
||||
FName TreeName;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "TreeLocation")
|
||||
FVector2D TreePosition = FVector2D(0.5f, 150);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAbilityBook : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Abilities")
|
||||
const TMap<FGameplayTag, FAuraAbilityInfo>& GetAbilities();
|
||||
|
||||
const FAuraAbilityRequirement* GetRequirementsForAbilityLevel(FGameplayTag AbilityID, int32 Level);
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Abilities")
|
||||
TArray<FAuraAbilityInfo> AllAbilities;
|
||||
|
||||
TMap<FGameplayTag, FAuraAbilityInfo> Abilities;
|
||||
|
||||
bool DictionaryInitialized = false;
|
||||
|
||||
};
|
||||
43
Source/Aura/Public/AbilitySystem/Data/AttributeInfo.h
Normal file
43
Source/Aura/Public/AbilitySystem/Data/AttributeInfo.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "AttributeInfo.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FAuraAttributeInfo
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
FGameplayTag AttributeTag = FGameplayTag();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
FText AttributeName = FText();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
FText AttributeDescription = FText();
|
||||
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
float AttributeValue = 0.0f;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAttributeInfo : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
FAuraAttributeInfo FindAttributeInfoForTag(const FGameplayTag& AttributeTag, bool bLogNotFound = false) const;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
TArray<FAuraAttributeInfo> AttributeInformation;
|
||||
};
|
||||
46
Source/Aura/Public/AbilitySystem/Data/CharacterClassInfo.h
Normal file
46
Source/Aura/Public/AbilitySystem/Data/CharacterClassInfo.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "AbilitySystem/AbilitySystemTypes.h"
|
||||
#include "ScalableFloat.h"
|
||||
#include "CharacterClassInfo.generated.h"
|
||||
|
||||
class UGameplayEffect;
|
||||
class UGameplayAbility;
|
||||
struct FGameplayEffectParameters;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UCharacterClassInfo : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Character Class")
|
||||
FText Name;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Character Class")
|
||||
FGameplayTagContainer ClassTag;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Character Class")
|
||||
TArray<TSubclassOf<UGameplayEffect>> BaseEffects;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Abilities")
|
||||
TArray<FGameplayAbilityGrant> StartupAbilities;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Abilities")
|
||||
TObjectPtr<class UAbilityBook> AbilitiesBook;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Starting")
|
||||
TArray<FGameplayEffectParameters> OnBeginEffects;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Experience")
|
||||
FScalableFloat DeathExperience;
|
||||
|
||||
};
|
||||
42
Source/Aura/Public/AbilitySystem/Data/EffectInfo.h
Normal file
42
Source/Aura/Public/AbilitySystem/Data/EffectInfo.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "EffectInfo.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FAuraEffectInfo
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Tag")
|
||||
FGameplayTag MessageTag;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Message")
|
||||
FText Message = FText();
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Widget")
|
||||
TSubclassOf<class UUserWidget> MessageWidget;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Widget")
|
||||
TObjectPtr<UTexture2D> Image = nullptr;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UEffectInfo : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Effect Information")
|
||||
TMap<FGameplayTag, FAuraEffectInfo> EffectsInformations;
|
||||
|
||||
};
|
||||
48
Source/Aura/Public/AbilitySystem/Data/LevelingInfo.h
Normal file
48
Source/Aura/Public/AbilitySystem/Data/LevelingInfo.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "ScalableFloat.h"
|
||||
#include "LevelingInfo.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FLevelingRewardInfo
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes")
|
||||
int32 AttributePointsAward = 3;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ability")
|
||||
int32 AbilityPointAward = 1;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API ULevelingInfo : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
// Input curve should be constantly increasing. The key is the level and the value is the required experience
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Experience")
|
||||
FScalableFloat ExperienceCurve;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Level")
|
||||
int32 MaxLevel = 20;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Rewards")
|
||||
TArray<FLevelingRewardInfo> LevelRewards;
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
int32 FindLevelForXP(int32 ExperiencePoints, int32 MinLevel = 0) const;
|
||||
|
||||
void GetExperienceBoundsAtLevel(int32 Level, int32& MinExperience, int32& MaxExperience) const;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayEffectExecutionCalculation.h"
|
||||
#include "GameplayEffectTypes.h"
|
||||
#include "AbilitySystem/AuraAttributeList.h"
|
||||
#include "ExecCalc_AttributeBased.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UExecCalc_AttributeBased : public UGameplayEffectExecutionCalculation
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Gameplay Effect|Data")
|
||||
void GetCapturedAttributesMagnitudes(const FGameplayEffectCustomExecutionParameters& ExecutionParams, TArray<float>& Attributes) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Gameplay Effect|Data")
|
||||
void GetContext(const FGameplayEffectCustomExecutionParameters& ExecutionParams, FGameplayEffectContextHandle& Context) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Gameplay Effect|Data")
|
||||
float GetSetByCallerTagMagnitude(const FGameplayEffectCustomExecutionParameters& ExecutionParams, FGameplayTag DataTag, bool WarnIfNotFound = false, float Default = 0.0f) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Ability|Gameplay Effect")
|
||||
const TMap<FGameplayTag, float>& GetSetByCallerTagMagnitudes(const FGameplayEffectCustomExecutionParameters& ExecutionParams) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Gameplay Effect|Modifiers")
|
||||
void AddExecutionOutputs(const TArray<FGameplayModifierEvaluatedData>& EvaluatedDatas, FGameplayEffectCustomExecutionOutput& OutExecutionOutput) const;
|
||||
|
||||
|
||||
/** Attribute Modifiers */
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Gameplay Effect|Attribute Modifier")
|
||||
FGameplayModifierEvaluatedData MakeModifierEvaluatedData_IncomingDamage(EGameplayModOp::Type Operation, float Value) const;
|
||||
|
||||
// #define MakeModifier(AttributeName, CategoryName) \
|
||||
// UFUNCTION(BlueprintCallable, Category = "Gameplay Effect|Attribute Modifier") \
|
||||
// FGameplayModifierEvaluatedData MakeModifierEvaluatedData_##AttributeName(EGameplayModOp::Type Operation, float Value) const;
|
||||
|
||||
// FOREACH_ATTRIBUTE_All(MakeModifier)
|
||||
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayModMagnitudeCalculation.h"
|
||||
#include "MMC_AttributeBased.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class AURA_API UMMC_AttributeBased : public UGameplayModMagnitudeCalculation
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
UFUNCTION(BlueprintCallable, Category = "Ability|Gameplay Effect")
|
||||
void GetCapturedAttributesMagnitudes(const FGameplayEffectSpec& EffectSpec, TArray<float>& Attributes) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Ability|Gameplay Effect")
|
||||
void GetContext(const FGameplayEffectSpec& EffectSpec, FGameplayEffectContextHandle& Context) const;
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/Tasks/AbilityTask.h"
|
||||
#include "TargetDataUnderMouse.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FMouseTargetDataSignature, const FGameplayAbilityTargetDataHandle&, DataHandle);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FNoTargetDataSignature);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UTargetDataUnderMouse : public UAbilityTask
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FMouseTargetDataSignature ValidData;
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FNoTargetDataSignature NoData;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Ability|Tasks", meta = (DisplayName = "TargetDataUnderMouse", HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = true))
|
||||
static UTargetDataUnderMouse* CreateTargetDataUnderMouse(UGameplayAbility* OwningAbility);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
void SendMouseCursorData();
|
||||
};
|
||||
53
Source/Aura/Public/Actor/AuraEffectActor.h
Normal file
53
Source/Aura/Public/Actor/AuraEffectActor.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayEffect.h"
|
||||
#include "GameplayEffectTypes.h"
|
||||
#include "AbilitySystem/AbilitySystemTypes.h"
|
||||
#include "AuraEffectActor.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct AURA_API FEffectHandleArray
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TArray<FActiveGameplayEffectHandle> Handles;
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class AURA_API AAuraEffectActor : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AAuraEffectActor();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool ApplyEffectToActor(AActor* Actor);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool ApplyEffectToAbilitySystemComponent(UAbilitySystemComponent* ASC);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool RemoveEffectFromActor(AActor* Actor);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool RemoveEffectFromAbilitySystemComponent(UAbilitySystemComponent* ASC);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effects", meta = (AllowPrivateAccess = true))
|
||||
TArray<FGameplayEffectParameters> Effects;
|
||||
|
||||
UPROPERTY()
|
||||
TMap<class UAbilitySystemComponent*, FEffectHandleArray> ActiveEffectHandles;
|
||||
|
||||
};
|
||||
84
Source/Aura/Public/Actor/AuraProjectile.h
Normal file
84
Source/Aura/Public/Actor/AuraProjectile.h
Normal file
@@ -0,0 +1,84 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "AbilitySystem/AbilitySystemTypes.h"
|
||||
#include "AuraProjectile.generated.h"
|
||||
|
||||
class UPrimitiveComponent;
|
||||
class USphereComponent;
|
||||
class UProjectileMovementComponent;
|
||||
class UArrowComponent;
|
||||
class UAbilitySystemComponent;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FProjectileImpactSignature, AAuraProjectile*, Projectile, FHitResult, HitResult);
|
||||
|
||||
UCLASS()
|
||||
class AURA_API AAuraProjectile : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AAuraProjectile();
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Projectile|Applied Effects", meta = (ExposeOnSpawn = true, AllowPrivateAccess = true))
|
||||
TArray<FGameplayEffectParameters> AppliedEffects;
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "Projectile")
|
||||
TArray<FActiveGameplayEffectHandle> ApplyEffects(UAbilitySystemComponent* TargetASC, const FHitResult& Collision) const;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Projectile|Instigator", meta = (ExposeOnSpawn = true, AllowPrivateAccess = true))
|
||||
TObjectPtr<class UGameplayAbility> InstigatorAbility;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Projectile|Impact")
|
||||
bool ShouldImpact(const FHitResult& HitResult);
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "Projectile|Impact")
|
||||
void Impact(const FHitResult& HitResult);
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "Projectile|Impact")
|
||||
void Overlapped(const FHitResult& HitResult);
|
||||
|
||||
UFUNCTION()
|
||||
void OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& HitResult);
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category = "Projectile|Impact")
|
||||
FProjectileImpactSignature OnImpact;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Projectile", meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<USphereComponent> Sphere;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Projectile", meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UProjectileMovementComponent> ProjectileMovement;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, Category = "Projectile");
|
||||
TObjectPtr<UArrowComponent> ArrowComponent;
|
||||
};
|
||||
|
||||
UINTERFACE(MinimalAPI)
|
||||
class UProjectileReactionInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
class AURA_API IProjectileReactionInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
void OverlappedByProjectile(AAuraProjectile* Projectile, const FHitResult& HitResult);
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
void ImpactedByProjectile(AAuraProjectile* Projectile, const FHitResult& HitResult);
|
||||
|
||||
};
|
||||
53
Source/Aura/Public/AsyncTask/InspectCooldownTask.h
Normal file
53
Source/Aura/Public/AsyncTask/InspectCooldownTask.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintAsyncActionBase.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "ActiveGameplayEffectHandle.h"
|
||||
#include "InspectCooldownTask.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FCooldownChangeSignature, float, TimeRemaining, float, TimeTotal);
|
||||
|
||||
class UAbilitySystemComponent;
|
||||
struct FGameplayEffectSpec;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(BlueprintType, meta = (ExposedAsyncProxy = "AsyncTask"))
|
||||
class AURA_API UInspectCooldownTask : public UBlueprintAsyncActionBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FCooldownChangeSignature CooldownStart;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FCooldownChangeSignature CooldownEnd;
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = true))
|
||||
static UInspectCooldownTask* InspectCooldown(UAbilitySystemComponent* AbilitySystemComponent, FGameplayTag InCooldownTag);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void EndTask();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void BroadcastEffectCooldownTime();
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UAbilitySystemComponent> ASC;
|
||||
|
||||
FGameplayTag CooldownTag;
|
||||
|
||||
void CooldownTagChanged(const FGameplayTag ChangedTag, int32 NewCount);
|
||||
void OnActiveEffectAdded(UAbilitySystemComponent* TargetASC, const FGameplayEffectSpec& SpecApplied, FActiveGameplayEffectHandle ActiveEffectHandle);
|
||||
|
||||
bool EffectHasCooldownTag(const FGameplayEffectSpec& EffectSpec);
|
||||
|
||||
};
|
||||
23
Source/Aura/Public/AuraAssetManager.h
Normal file
23
Source/Aura/Public/AuraAssetManager.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/AssetManager.h"
|
||||
#include "AuraAssetManager.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraAssetManager : public UAssetManager
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
static UAuraAssetManager& Get();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void StartInitialLoading() override;
|
||||
};
|
||||
37
Source/Aura/Public/AuraBlueprintFunctionLibrary.h
Normal file
37
Source/Aura/Public/AuraBlueprintFunctionLibrary.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "AuraBlueprintFunctionLibrary.generated.h"
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_DELEGATE_TwoParams(FOnDeathDelegateSignature, AActor*, DeadActor, const FGameplayEffectSpec&, KillingEffectSpec);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Components")
|
||||
static void RegisterComponent(UActorComponent* Component);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Components")
|
||||
static void UnregisterComponent(UActorComponent* Component);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Team")
|
||||
static bool AreActorsEnemies(AActor* FirstActor, AActor* SecondActor);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "CombatInterface|OnDeath")
|
||||
static void AddOnDeathCallback(UObject* CombatInterfaceObject, FOnDeathDelegateSignature Callback);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "CombatInterface|OnDeath")
|
||||
static void RemoveOnDeathCallback(UObject* CombatInterfaceObject, FOnDeathDelegateSignature Callback);
|
||||
|
||||
};
|
||||
96
Source/Aura/Public/AuraGameplayTags.h
Normal file
96
Source/Aura/Public/AuraGameplayTags.h
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "AbilitySystem/AuraAttributeList.h"
|
||||
|
||||
/**
|
||||
* AuraGameplayTags
|
||||
*
|
||||
* Singleton containing gameplay tags
|
||||
*/
|
||||
|
||||
struct FAuraGameplayTags
|
||||
{
|
||||
public:
|
||||
static const FAuraGameplayTags& Get() { return GameplayTags; }
|
||||
static void InitializeNativeGameplayTags();
|
||||
|
||||
#define __AURAGAMEPLAYTAGS_SINGLETON_PROPERTYDECLARATION__(AttributeName, CategoryName) FGameplayTag Attributes_##CategoryName##_##AttributeName;
|
||||
|
||||
FOREACH_ATTRIBUTE_All(__AURAGAMEPLAYTAGS_SINGLETON_PROPERTYDECLARATION__)
|
||||
|
||||
FGameplayTag InputTag;
|
||||
FGameplayTag InputTag_LMB;
|
||||
FGameplayTag InputTag_RMB;
|
||||
FGameplayTag InputTag_1;
|
||||
FGameplayTag InputTag_2;
|
||||
FGameplayTag InputTag_3;
|
||||
FGameplayTag InputTag_4;
|
||||
FGameplayTag InputTag_Q;
|
||||
FGameplayTag InputTag_E;
|
||||
FGameplayTag InputTag_R;
|
||||
FGameplayTag InputTag_F;
|
||||
FGameplayTag InputTag_Space;
|
||||
FGameplayTag InputTag_Passive_1;
|
||||
FGameplayTag InputTag_Passive_2;
|
||||
FGameplayTag InputTag_Passive_3;
|
||||
|
||||
TArray<FGameplayTag> InputTags;
|
||||
|
||||
FGameplayTag Event;
|
||||
FGameplayTag Event_AbilitySystem_DamageApplied;
|
||||
|
||||
FGameplayTag Damage;
|
||||
FGameplayTag Damage_Physical;
|
||||
FGameplayTag Damage_Magical;
|
||||
FGameplayTag Damage_Magical_Fire;
|
||||
FGameplayTag Damage_Magical_Ice;
|
||||
FGameplayTag Damage_Magical_Shock;
|
||||
FGameplayTag Damage_Magical_Shadow;
|
||||
FGameplayTag Damage_Magical_Arcane;
|
||||
|
||||
TArray<FGameplayTag> DamageTypes;
|
||||
|
||||
TMap<FGameplayTag, FGameplayTag> DamageResistanceMap;
|
||||
|
||||
FGameplayTag Effects_HitReact;
|
||||
|
||||
FGameplayTag Debuff;
|
||||
FGameplayTag Debuff_Stun;
|
||||
FGameplayTag Debuff_Slow;
|
||||
FGameplayTag Debuff_Dot;
|
||||
FGameplayTag Debuff_Attributes;
|
||||
|
||||
FGameplayTag Ability_ID;
|
||||
|
||||
FGameplayTag Ability_Cooldown;
|
||||
|
||||
FGameplayTag Ability_Status;
|
||||
FGameplayTag Ability_Status_Locked;
|
||||
FGameplayTag Ability_Status_Eligible;
|
||||
FGameplayTag Ability_Status_Unlocked;
|
||||
FGameplayTag Ability_Status_Equipped;
|
||||
|
||||
FGameplayTag Ability_Type;
|
||||
FGameplayTag Ability_Type_Activable;
|
||||
FGameplayTag Ability_Type_Passive;
|
||||
FGameplayTag Ability_Type_Utility;
|
||||
|
||||
FGameplayTag Ability_Interruptible;
|
||||
FGameplayTag Ability_Interruptible_HitReact;
|
||||
|
||||
FGameplayTag Ability_AI_BasicAttack;
|
||||
|
||||
FGameplayTag Player_Hide_Cursor;
|
||||
FGameplayTag Player_Block_AbilityInput;
|
||||
FGameplayTag Player_Block_CursorTrace;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
static FAuraGameplayTags GameplayTags;
|
||||
};
|
||||
101
Source/Aura/Public/Character/AuraCharacterBase.h
Normal file
101
Source/Aura/Public/Character/AuraCharacterBase.h
Normal file
@@ -0,0 +1,101 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "Interaction/CombatInterface.h"
|
||||
#include "Interfaces/WorldHoverable.h"
|
||||
#include "GameplayEffectTypes.h"
|
||||
#include "AuraCharacterBase.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_DELEGATE_TwoParams(FTagCountChangeSignature, FGameplayTag, Tag, int32, NewCount);
|
||||
|
||||
class UAbilitySystemComponent;
|
||||
class UAttributeSet;
|
||||
class UCharacterClassInfo;
|
||||
|
||||
UCLASS(Abstract)
|
||||
class AURA_API AAuraCharacterBase : public ACharacter, public IAbilitySystemInterface, public ICombatInterface, public IWorldHoverable
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AAuraCharacterBase();
|
||||
|
||||
FOnASCRegisteredDelegate OnASCRegistered;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnDeathBroadcastSignature OnDeath;
|
||||
|
||||
/** Ability System */
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
UFUNCTION(BlueprintCallable, Category = "Ability")
|
||||
FORCEINLINE UAttributeSet* GetAttributeSet() const { return AttributeSet; }
|
||||
|
||||
/** Highlight */
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "Highlight")
|
||||
void SetHighlighted(bool bNewHighlighted);
|
||||
virtual void SetHighlighted_Implementation(bool bNewHighlighted);
|
||||
UFUNCTION(BlueprintCallable, Category = "Highlight")
|
||||
bool GetHighlighted() const { return bHighlighted; }
|
||||
|
||||
/** World Hoverable */
|
||||
virtual void GetWorldHoverableInfos_Implementation(FWorldHoverableInfos& Infos) override;
|
||||
virtual bool CanBeHovered_Implementation(AController* Controller, const FHitResult& TraceHit) override;
|
||||
virtual void HoveredBegin_Implementation(AController* Controller, const FHitResult& TraceHit) override;
|
||||
virtual void HoveredEnd_Implementation(AController* Controller) override;
|
||||
|
||||
|
||||
FORCEINLINE const UCharacterClassInfo* GetClassInfo() const { return ClassInfo; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
virtual void Restart() override;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Combat")
|
||||
TObjectPtr<USkeletalMeshComponent> Weapon;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Combat")
|
||||
bool bHitReacting = false;
|
||||
|
||||
/** Combat Interface*/
|
||||
virtual int32 GetDeathExperience_Implementation() const override;
|
||||
virtual FVector GetCombatSocketLocation_Implementation(FGameplayTag SocketTagName) const override;
|
||||
virtual bool IsDead_Implementation() const override;
|
||||
virtual FOnASCRegisteredDelegate& GetOnASCRegisteredDelegate() override;
|
||||
virtual FOnDeathBroadcastSignature& GetOnDeathDelegate() override;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Highlight")
|
||||
bool bHighlighted;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Ability", meta = (AllowPrivateAccess = "true"))
|
||||
TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UAttributeSet> AttributeSet;
|
||||
|
||||
/* InitAbilityActorInfo */
|
||||
UFUNCTION()
|
||||
virtual void InitAbilitySystem();
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "Ability System")
|
||||
void AbilitySystemInitialized(UAbilitySystemComponent* ASC);
|
||||
|
||||
void AddCharacterBaseEffects();
|
||||
void AddCharacterAbilities();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void ApplyBeginEffects();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Gameplay Effect|Event Tag")
|
||||
void RegisterGameplayTagEvent(FGameplayTag EventTag, EGameplayTagEventType::Type TagEventType, FTagCountChangeSignature OnTagCountChanged);
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Class")
|
||||
TObjectPtr<UCharacterClassInfo> ClassInfo;
|
||||
|
||||
};
|
||||
38
Source/Aura/Public/Character/AuraEnemy.h
Normal file
38
Source/Aura/Public/Character/AuraEnemy.h
Normal file
@@ -0,0 +1,38 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Character/AuraCharacterBase.h"
|
||||
#include "AuraEnemy.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AAuraEnemy : public AAuraCharacterBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
AAuraEnemy();
|
||||
|
||||
/** Combat Interface */
|
||||
virtual int32 GetPlayerLevel_Implementation() const override { return Level; }
|
||||
virtual void SetCombatTarget_Implementation(USceneComponent *NewCombatTarget) override { CombatTarget = NewCombatTarget; }
|
||||
virtual USceneComponent* GetCombatTarget_Implementation() const override { return CombatTarget; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
virtual void InitAbilitySystem() override;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Class Default")
|
||||
int32 Level = 1;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<USceneComponent> CombatTarget;
|
||||
|
||||
};
|
||||
45
Source/Aura/Public/Character/AuraPlayerCharacter.h
Normal file
45
Source/Aura/Public/Character/AuraPlayerCharacter.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Character/AuraCharacterBase.h"
|
||||
#include "Interaction/PlayerInterface.h"
|
||||
#include "AuraPlayerCharacter.generated.h"
|
||||
|
||||
class USpringArmComponent;
|
||||
class UCameraComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AAuraPlayerCharacter : public AAuraCharacterBase, public IPlayerInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AAuraPlayerCharacter();
|
||||
|
||||
FORCEINLINE USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
|
||||
FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; }
|
||||
|
||||
virtual void PossessedBy(AController* NewController) override;
|
||||
virtual void OnRep_PlayerState() override;
|
||||
|
||||
protected:
|
||||
|
||||
/** Combat Interface */
|
||||
virtual int32 GetPlayerLevel_Implementation() const override;
|
||||
|
||||
/** Player Interface */
|
||||
virtual class ULevelingExperienceComponent* GetLevelingExperienceComponent_Implementation() const override;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera", meta = (AllowPrivateAccess = "true"))
|
||||
TObjectPtr<USpringArmComponent> CameraBoom;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera", meta = (AllowPrivateAccess = "true"))
|
||||
TObjectPtr<UCameraComponent> FollowCamera;
|
||||
|
||||
virtual void InitAbilitySystem() override;
|
||||
};
|
||||
17
Source/Aura/Public/Game/AuraGameModeBase.h
Normal file
17
Source/Aura/Public/Game/AuraGameModeBase.h
Normal file
@@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/GameMode.h"
|
||||
#include "AuraGameModeBase.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API AAuraGameModeBase : public AGameMode
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
||||
18
Source/Aura/Public/Game/AuraGameState.h
Normal file
18
Source/Aura/Public/Game/AuraGameState.h
Normal file
@@ -0,0 +1,18 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/GameState.h"
|
||||
#include "AuraGameState.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API AAuraGameState : public AGameState
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
};
|
||||
47
Source/Aura/Public/Input/AuraInputComponent.h
Normal file
47
Source/Aura/Public/Input/AuraInputComponent.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "AuraInputConfig.h"
|
||||
#include "AuraInputComponent.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraInputComponent : public UEnhancedInputComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
template<class UserClass, typename PressedFuncType, typename ReleaseFuncType, typename HeldFuncType>
|
||||
void BindAbilityActions(const UAuraInputConfig* InputConfig,
|
||||
UserClass* BindObject, PressedFuncType PressedFunc,
|
||||
ReleaseFuncType ReleaseFunc, HeldFuncType HeldFunc);
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<class UserClass, typename PressedFuncType, typename ReleaseFuncType, typename HeldFuncType>
|
||||
void UAuraInputComponent::BindAbilityActions(const UAuraInputConfig* InputConfig,
|
||||
UserClass* BindObject, PressedFuncType PressedFunc,
|
||||
ReleaseFuncType ReleaseFunc, HeldFuncType HeldFunc)
|
||||
{
|
||||
check(InputConfig)
|
||||
|
||||
for (const FAuraInputAction& Action : InputConfig->AbilityInputActions)
|
||||
{
|
||||
if (!(Action.InputAction && Action.InputTag.IsValid()))
|
||||
continue;
|
||||
|
||||
if (PressedFunc)
|
||||
BindAction(Action.InputAction, ETriggerEvent::Started, BindObject, PressedFunc, Action.InputTag);
|
||||
if (ReleaseFunc)
|
||||
BindAction(Action.InputAction, ETriggerEvent::Completed, BindObject, ReleaseFunc, Action.InputTag);
|
||||
if (HeldFunc)
|
||||
BindAction(Action.InputAction, ETriggerEvent::Triggered, BindObject, HeldFunc, Action.InputTag);
|
||||
}
|
||||
}
|
||||
39
Source/Aura/Public/Input/AuraInputConfig.h
Normal file
39
Source/Aura/Public/Input/AuraInputConfig.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "AuraInputConfig.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FAuraInputAction
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
class UInputAction* InputAction = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
FGameplayTag InputTag = FGameplayTag();
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraInputConfig : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
const UInputAction* FindAbilityInputActionForTag(const FGameplayTag& InputTag, bool bLogNotFound) const;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Input")
|
||||
TArray<FAuraInputAction> AbilityInputActions;
|
||||
|
||||
};
|
||||
79
Source/Aura/Public/Interaction/CombatInterface.h
Normal file
79
Source/Aura/Public/Interaction/CombatInterface.h
Normal file
@@ -0,0 +1,79 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "CombatInterface.generated.h"
|
||||
|
||||
class UAbilitySystemComponent;
|
||||
|
||||
DECLARE_MULTICAST_DELEGATE_OneParam(FOnASCRegisteredDelegate, UAbilitySystemComponent*);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnDeathBroadcastSignature, AActor*, DeadActor, const FGameplayEffectSpec&, KillingEffectSpec);
|
||||
|
||||
USTRUCT(BlueprintType, Blueprintable)
|
||||
struct FCombatMontage
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
FCombatMontage(){}
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
class UAnimMontage* Montage;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FGameplayTag EventTag;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FGameplayTag SocketTag;
|
||||
|
||||
};
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE(MinimalAPI)
|
||||
class UCombatInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class AURA_API ICombatInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
int32 GetPlayerLevel() const;
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
int32 GetDeathExperience() const;
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
FVector GetCombatSocketLocation(FGameplayTag SocketTagName) const;
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
USceneComponent* GetCombatComponent(FGameplayTag ComponentTagName) const;
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
FCombatMontage GetCombatMontage(FGameplayTag MontageTagName) const;
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
void SetCombatTarget(USceneComponent *NewCombatTarget);
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
USceneComponent* GetCombatTarget() const;
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void Die(const FGameplayEffectSpec& KillingEffectSpec);
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
bool IsDead() const;
|
||||
|
||||
virtual FOnASCRegisteredDelegate& GetOnASCRegisteredDelegate() = 0;
|
||||
virtual FOnDeathBroadcastSignature& GetOnDeathDelegate() = 0;
|
||||
|
||||
};
|
||||
29
Source/Aura/Public/Interaction/PlayerInterface.h
Normal file
29
Source/Aura/Public/Interaction/PlayerInterface.h
Normal file
@@ -0,0 +1,29 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "PlayerInterface.generated.h"
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE(MinimalAPI)
|
||||
class UPlayerInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class AURA_API IPlayerInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
class ULevelingExperienceComponent* GetLevelingExperienceComponent() const;
|
||||
|
||||
};
|
||||
42
Source/Aura/Public/Inventory/AuraInventoryComponent.h
Normal file
42
Source/Aura/Public/Inventory/AuraInventoryComponent.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/SlotInventoryComponent_Networked.h"
|
||||
#include "InventoryItem.h"
|
||||
#include "AuraInventoryComponent.generated.h"
|
||||
|
||||
class UAuraInventoryDataSource;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS( Blueprintable, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
class AURA_API UAuraInventoryComponent : public USlotInventoryComponent_Networked
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
|
||||
virtual uint8 GetMaxStackSizeForID(const FName& ID) const override;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Data")
|
||||
bool FetchSlotData(const FName& SlotId, FInventoryItemData& Data) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Data|Quality")
|
||||
FLinearColor GetColorFromQuality(EInventoryItemQuality Quality) const;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Quick Drop")
|
||||
TObjectPtr<USlotInventoryComponent> QuickDeliverInventory;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Data|Asset", meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UAuraInventoryDataSource> DataSource;
|
||||
|
||||
};
|
||||
34
Source/Aura/Public/Inventory/AuraInventoryDataSource.h
Normal file
34
Source/Aura/Public/Inventory/AuraInventoryDataSource.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "InventoryItem.h"
|
||||
#include "AuraInventoryDataSource.generated.h"
|
||||
|
||||
|
||||
UCLASS()
|
||||
class AURA_API UAuraInventoryDataSource : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Data")
|
||||
bool GetDataForItemId(const FName& ItemId, FInventoryItemData& Data) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Data")
|
||||
FLinearColor GetColorFromQuality(EInventoryItemQuality Quality) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Data")
|
||||
TObjectPtr<UDataTable> ItemDataTable;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Data")
|
||||
TMap<EInventoryItemQuality, FLinearColor> QualityColors;
|
||||
|
||||
|
||||
};
|
||||
46
Source/Aura/Public/Inventory/InventoryItem.h
Normal file
46
Source/Aura/Public/Inventory/InventoryItem.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Amasson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataTable.h"
|
||||
#include "InventoryItem.generated.h"
|
||||
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EInventoryItemQuality : uint8
|
||||
{
|
||||
IIQ_Trash UMETA(DisplayName="Trash"),
|
||||
IIQ_Common UMETA(DisplayName="Common"),
|
||||
IIQ_Unusual UMETA(DisplayName="Unusual"),
|
||||
IIQ_Rare UMETA(DisplayName="Rare"),
|
||||
IIQ_Epic UMETA(DisplayName="Epic"),
|
||||
IIQ_Legendary UMETA(DisplayName="Legendary"),
|
||||
IIQ_Doom UMETA(DisplayName="Doom"),
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FInventoryItemData : public FTableRowBase
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
FText Name;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
FText Description;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
TObjectPtr<UTexture2D> Icon;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
EInventoryItemQuality Quality = EInventoryItemQuality::IIQ_Common;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
TObjectPtr<UClass> Behavior;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
uint8 MaxStackSize = 255;
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user