2025-10-14 22:20:59 -04:00
|
|
|
// Copyright Echo Devgroup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Character/AuraCharacterBase.h"
|
|
|
|
|
#include "AbilitySystemComponent.h"
|
2025-10-16 14:33:58 -04:00
|
|
|
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
2025-10-14 22:20:59 -04:00
|
|
|
|
|
|
|
|
AAuraCharacterBase::AAuraCharacterBase()
|
|
|
|
|
{
|
|
|
|
|
PrimaryActorTick.bCanEverTick = false;
|
|
|
|
|
|
|
|
|
|
Weapon = CreateDefaultSubobject<USkeletalMeshComponent>("Weapon");
|
|
|
|
|
Weapon->SetupAttachment(GetMesh(), FName("WeaponHandSocket"));
|
|
|
|
|
Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UAbilitySystemComponent* AAuraCharacterBase::GetAbilitySystemComponent() const
|
|
|
|
|
{
|
|
|
|
|
return AbilitySystemComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AAuraCharacterBase::BeginPlay()
|
|
|
|
|
{
|
|
|
|
|
Super::BeginPlay();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AAuraCharacterBase::InitAbilityActorInfo()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AAuraCharacterBase::ApplyEffectToSelf(TSubclassOf<UGameplayEffect> GameplayEffectClass, float Level) const
|
|
|
|
|
{
|
|
|
|
|
check(IsValid(GetAbilitySystemComponent()));
|
|
|
|
|
check(GameplayEffectClass);
|
2025-10-15 15:39:53 -04:00
|
|
|
FGameplayEffectContextHandle ContextHandle = GetAbilitySystemComponent()->MakeEffectContext();
|
|
|
|
|
ContextHandle.AddSourceObject(this);
|
2025-10-14 22:20:59 -04:00
|
|
|
const FGameplayEffectSpecHandle SpecHandle = GetAbilitySystemComponent()->MakeOutgoingSpec(GameplayEffectClass,Level, ContextHandle);
|
|
|
|
|
GetAbilitySystemComponent()->ApplyGameplayEffectSpecToTarget(*SpecHandle.Data.Get(), GetAbilitySystemComponent());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AAuraCharacterBase::InitializeDefaultAttributes() const
|
|
|
|
|
{
|
|
|
|
|
ApplyEffectToSelf(DefaultPrimaryAttributes,1.f);
|
|
|
|
|
ApplyEffectToSelf(DefaultSecondaryAttributes, 1.f);
|
2025-10-15 15:39:53 -04:00
|
|
|
ApplyEffectToSelf(DefaultVitalAttributes, 1.f);
|
2025-10-14 22:20:59 -04:00
|
|
|
}
|
|
|
|
|
|
2025-10-16 14:33:58 -04:00
|
|
|
void AAuraCharacterBase::AddCharacterAbilities()
|
|
|
|
|
{
|
|
|
|
|
UAuraAbilitySystemComponent* AuraASC = CastChecked<UAuraAbilitySystemComponent>(AbilitySystemComponent);
|
|
|
|
|
if (!HasAuthority()) return;
|
|
|
|
|
|
|
|
|
|
AuraASC->AddCharacterAbilities(StartupAbilities);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-14 22:20:59 -04:00
|
|
|
|