2025-10-14 22:20:59 -04:00
|
|
|
// Copyright Echo Devgroup
|
|
|
|
|
|
|
|
|
|
#include "Character/AuraEnemy.h"
|
|
|
|
|
|
|
|
|
|
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
|
|
|
|
#include "AbilitySystem/AuraAttributeSet.h"
|
|
|
|
|
#include "Aura/Aura.h"
|
2025-10-17 20:49:29 -04:00
|
|
|
#include "Components/WidgetComponent.h"
|
|
|
|
|
#include "UI/Widget/AuraUserWidget.h"
|
2025-10-14 22:20:59 -04:00
|
|
|
|
|
|
|
|
AAuraEnemy::AAuraEnemy()
|
|
|
|
|
{
|
|
|
|
|
GetMesh()->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);
|
|
|
|
|
AbilitySystemComponent = CreateDefaultSubobject<UAuraAbilitySystemComponent>("AbilitySystemComponent");
|
|
|
|
|
AbilitySystemComponent->SetIsReplicated(true);
|
|
|
|
|
AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Minimal);
|
|
|
|
|
AttributeSet = CreateDefaultSubobject<UAuraAttributeSet>("AttributeSet");
|
2025-10-17 20:49:29 -04:00
|
|
|
|
|
|
|
|
HealthBar = CreateDefaultSubobject<UWidgetComponent>("HealthBar");
|
|
|
|
|
HealthBar->SetupAttachment(GetRootComponent());
|
2025-10-14 22:20:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AAuraEnemy::HighlightActor()
|
|
|
|
|
{
|
|
|
|
|
GetMesh()->SetRenderCustomDepth(true);
|
2025-10-17 16:43:49 -04:00
|
|
|
GetMesh()->SetCustomDepthStencilValue(CUSTOM_DEPTH_RED);
|
2025-10-14 22:20:59 -04:00
|
|
|
Weapon->SetRenderCustomDepth(true);
|
2025-10-17 16:43:49 -04:00
|
|
|
Weapon->SetCustomDepthStencilValue(CUSTOM_DEPTH_RED);
|
2025-10-17 20:49:29 -04:00
|
|
|
|
|
|
|
|
if (UAuraUserWidget* AuraUserWidget = Cast<UAuraUserWidget>(HealthBar->GetUserWidgetObject()))
|
|
|
|
|
{
|
|
|
|
|
AuraUserWidget->SetWidgetController(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (const UAuraAttributeSet* AuraAS = Cast<UAuraAttributeSet>(AttributeSet))
|
|
|
|
|
{
|
|
|
|
|
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AuraAS->GetHealthAttribute()).AddLambda(
|
|
|
|
|
[this](const FOnAttributeChangeData& Data){ OnHealthChanged.Broadcast(Data.NewValue); }
|
|
|
|
|
);
|
|
|
|
|
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AuraAS->GetMaxHealthAttribute()).AddLambda(
|
|
|
|
|
[this](const FOnAttributeChangeData& Data)
|
|
|
|
|
{
|
|
|
|
|
OnMaxHealthChanged.Broadcast(Data.NewValue);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
OnHealthChanged.Broadcast(AuraAS->GetHealth());
|
|
|
|
|
OnMaxHealthChanged.Broadcast(AuraAS->GetMaxHealth());
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-14 22:20:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AAuraEnemy::UnHighlightActor()
|
|
|
|
|
{
|
|
|
|
|
GetMesh()->SetRenderCustomDepth(false);
|
|
|
|
|
Weapon->SetRenderCustomDepth(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32 AAuraEnemy::GetPlayerLevel()
|
|
|
|
|
{
|
|
|
|
|
return Level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AAuraEnemy::BeginPlay()
|
|
|
|
|
{
|
|
|
|
|
Super::BeginPlay();
|
|
|
|
|
InitAbilityActorInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AAuraEnemy::InitAbilityActorInfo()
|
|
|
|
|
{
|
2025-10-17 14:46:42 -04:00
|
|
|
AbilitySystemComponent->InitAbilityActorInfo(this, this);
|
2025-10-14 22:20:59 -04:00
|
|
|
Cast<UAuraAbilitySystemComponent>(AbilitySystemComponent)->AbilityActorInfoSet();
|
2025-10-17 14:46:42 -04:00
|
|
|
|
|
|
|
|
InitializeDefaultAttributes();
|
2025-10-17 16:43:49 -04:00
|
|
|
}
|