This commit is contained in:
2025-10-17 17:13:13 -04:00
parent fc85fa2a5a
commit dc37ba58c4
240 changed files with 24101 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
// Copyright Echo Devgroup
#include "AbilitySystem/AuraProjectileSpell.h"
#include "AbilitySystemBlueprintLibrary.h"
#include "AbilitySystemComponent.h"
#include "Actor/AuraProjectile.h"
#include "Interact/CombatInterface.h"
void UAuraProjectileSpell::ActivateAbility(const FGameplayAbilitySpecHandle Handle,
const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo,
const FGameplayEventData* TriggerEventData)
{
Super::ActivateAbility(Handle, ActorInfo, ActivationInfo, TriggerEventData);
}
void UAuraProjectileSpell::SpawnProjectile(const FVector ProjectileTargetLocation)
{
const bool bIsServer = GetAvatarActorFromActorInfo()->HasAuthority();
if (bIsServer) return;
ICombatInterface* CombatInterface = Cast<ICombatInterface>(GetAvatarActorFromActorInfo());
if (CombatInterface)
{
const FVector SocketLocation = CombatInterface->GetCombatSocketLocation();
FRotator Rotation = (ProjectileTargetLocation - SocketLocation).Rotation();
Rotation.Pitch = 0.0f;
FTransform SpawnTransform;
SpawnTransform.SetLocation(SocketLocation);
SpawnTransform.SetRotation(Rotation.Quaternion());
AAuraProjectile* Projectile = GetWorld()->SpawnActorDeferred<AAuraProjectile>(
ProjectileClass,
SpawnTransform,
GetOwningActorFromActorInfo(),
Cast<APawn>(CurrentActorInfo->AvatarActor), //Changed to allow GetInstigator() to work accurately in Projectile. Allowing ignoring the player character.
ESpawnActorCollisionHandlingMethod::AlwaysSpawn);
const UAbilitySystemComponent* SourceASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(GetAvatarActorFromActorInfo());
const FGameplayEffectSpecHandle SpecHandle = SourceASC->MakeOutgoingSpec(DamageEffectClass, GetAbilityLevel(), SourceASC->MakeEffectContext());
Projectile->DamageEffectSpecHandle = SpecHandle;
UE_LOG(LogTemp,Warning,TEXT("Projectile - SourceASC %s - DamageEffectClass %s"), *SourceASC->GetName(), *DamageEffectClass->GetName());
Projectile->FinishSpawning(SpawnTransform);
}
}

View File

@@ -0,0 +1,5 @@
// Copyright Echo Devgroup
#include "AbilitySystem/GameplayAbility/AuraGameplayAbility.h"

View File

@@ -0,0 +1,53 @@
// Copyright Echo Devgroup
#include "AbilitySystem/Tasks/TargetDataUnderMouse.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
{
//TODO: We are on the server, so listen for target data
}
}
void UTargetDataUnderMouse::SendMouseCursorData()
{
FScopedPredictionWindow ScopedPrediction(AbilitySystemComponent.Get());
APlayerController* PC = Ability->GetCurrentActorInfo()->PlayerController.Get();
FHitResult CursorHit;
PC->GetHitResultUnderCursor(ECC_Visibility, false, CursorHit);
FGameplayAbilityTargetDataHandle DataHandle;
FGameplayAbilityTargetData_SingleTargetHit* Data = new FGameplayAbilityTargetData_SingleTargetHit();
Data->HitResult = CursorHit;
DataHandle.Add(Data);
AbilitySystemComponent->ServerSetReplicatedTargetData(
GetAbilitySpecHandle(),
GetActivationPredictionKey(),
DataHandle, FGameplayTag(),
AbilitySystemComponent->ScopedPredictionKey
);
if (ShouldBroadcastAbilityTaskDelegates())
{
ValidData.Broadcast(DataHandle);
}
}

View File

@@ -0,0 +1,75 @@
// Copyright Echo Devgroup
#include "Actor/AuraProjectile.h"
#include "AbilitySystemBlueprintLibrary.h"
#include "AbilitySystemComponent.h"
#include "NiagaraFunctionLibrary.h"
#include "Aura/Aura.h"
#include "Components/AudioComponent.h"
#include "Components/SphereComponent.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "Kismet/GameplayStatics.h"
AAuraProjectile::AAuraProjectile()
{
bReplicates = true;
PrimaryActorTick.bCanEverTick = false;
Sphere = CreateDefaultSubobject<USphereComponent>("Sphere");
SetRootComponent(Sphere);
Sphere->SetCollisionObjectType(ECC_PROJECTILE);
Sphere->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
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.f;
ProjectileMovement->MaxSpeed = 550.f;
ProjectileMovement->ProjectileGravityScale = 0.f;
}
void AAuraProjectile::BeginPlay()
{
Super::BeginPlay();
SetLifeSpan(LifeSpan);
Sphere->OnComponentBeginOverlap.AddDynamic(this, &AAuraProjectile::OnSphereOverlap);
LoopingSoundComponent = UGameplayStatics::SpawnSoundAttached(LoopingSound, GetRootComponent());
}
void AAuraProjectile::Destroyed()
{
if (!bHit && !HasAuthority())
{
UGameplayStatics::PlaySoundAtLocation(GetWorld(), ImpactSound, GetActorLocation());
UNiagaraFunctionLibrary::SpawnSystemAtLocation(this, ImpactEffect, GetActorLocation());
LoopingSoundComponent->Stop();
}
Super::Destroyed();
}
void AAuraProjectile::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult& SweepResult)
{
if (OtherActor == GetInstigator()) return; //So that the projectile will not collide with the owning actor.
UGameplayStatics::PlaySoundAtLocation(GetWorld(), ImpactSound, GetActorLocation());
UNiagaraFunctionLibrary::SpawnSystemAtLocation(this, ImpactEffect, GetActorLocation());
LoopingSoundComponent->Stop();
if (HasAuthority())
{
if (UAbilitySystemComponent* TargetASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(OtherActor))
{
TargetASC->ApplyGameplayEffectSpecToSelf(*DamageEffectSpecHandle.Data.Get());
}
Destroy();
}
else { bHit = true; }
}

View File

@@ -0,0 +1,5 @@
// Copyright Echo Devgroup
#include "Input/AuraInputComponent.h"

View File

@@ -0,0 +1,24 @@
// Copyright Echo Devgroup
#include "Input/AuraInputConfig.h"
#include "InputAction.h"
const UInputAction* UAuraInputConfig::FindAbilityInputActionForTag(const FGameplayTag& InputTag,
bool bLogNotFound) const
{
for (const FAuraInputAction& Action : AbilityInputActions)
{
if (Action.InputAction && Action.InputTag == InputTag)
{
return Action.InputAction;
}
}
if (bLogNotFound)
{
UE_LOG(LogTemp, Error, TEXT("Can't find AbilityInputAction for InputTag [%s], on InputConfig [%s]"), *InputTag.ToString(), *GetName());
}
return nullptr;
}