68 lines
2.4 KiB
C++
68 lines
2.4 KiB
C++
|
|
// Copyright Echo Devgroup
|
||
|
|
|
||
|
|
|
||
|
|
#include "UI/WidgetController/OverlayWidgetController.h"
|
||
|
|
|
||
|
|
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||
|
|
#include "AbilitySystem/AuraAttributeSet.h"
|
||
|
|
|
||
|
|
void UOverlayWidgetController::BroadcastInitialValues()
|
||
|
|
{
|
||
|
|
//UE_LOG(LogTemp, Warning, TEXT("OverlayWidgetController - BroadcastInitialValues"));
|
||
|
|
UAuraAttributeSet* AuraAttributeSet = CastChecked<UAuraAttributeSet>(AttributeSet);
|
||
|
|
OnHealthChanged.Broadcast(AuraAttributeSet->GetHealth());
|
||
|
|
OnMaxHealthChanged.Broadcast(AuraAttributeSet->GetMaxHealth());
|
||
|
|
OnManaChanged.Broadcast(AuraAttributeSet->GetMana());
|
||
|
|
OnMaxManaChanged.Broadcast(AuraAttributeSet->GetMaxMana());
|
||
|
|
}
|
||
|
|
|
||
|
|
void UOverlayWidgetController::BindCallbacksToDependencies()
|
||
|
|
{
|
||
|
|
UAuraAttributeSet* AuraAttributeSet = CastChecked<UAuraAttributeSet>(AttributeSet);
|
||
|
|
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AuraAttributeSet->GetHealthAttribute()).AddLambda(
|
||
|
|
[this](const FOnAttributeChangeData& Data)
|
||
|
|
{
|
||
|
|
OnHealthChanged.Broadcast(Data.NewValue);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
|
||
|
|
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AuraAttributeSet->GetMaxHealthAttribute()).AddLambda(
|
||
|
|
[this](const FOnAttributeChangeData& Data)
|
||
|
|
{
|
||
|
|
OnMaxHealthChanged.Broadcast(Data.NewValue);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AuraAttributeSet->GetManaAttribute()).AddLambda(
|
||
|
|
[this](const FOnAttributeChangeData& Data)
|
||
|
|
{
|
||
|
|
OnManaChanged.Broadcast(Data.NewValue);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AuraAttributeSet->GetMaxManaAttribute()).AddLambda(
|
||
|
|
[this](const FOnAttributeChangeData& Data)
|
||
|
|
{
|
||
|
|
OnMaxManaChanged.Broadcast(Data.NewValue);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
|
||
|
|
Cast<UAuraAbilitySystemComponent>(AbilitySystemComponent)->EffectAssetTags.AddLambda(
|
||
|
|
[this](const FGameplayTagContainer& AssetTags)
|
||
|
|
{
|
||
|
|
for (const FGameplayTag& Tag : AssetTags)
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
//* "A.1".MatchesTag("A") will return True, "A".MatchesTag("A.1") will return False
|
||
|
|
FGameplayTag MessageTag = FGameplayTag::RequestGameplayTag(FName("Message"));
|
||
|
|
if (Tag.MatchesTag(MessageTag))
|
||
|
|
{
|
||
|
|
const FUIWidgetRow* Row = GetDataTableRowByTag<FUIWidgetRow>(MessageWidgetDataTable, Tag);
|
||
|
|
MessageWidgetRowDelegate.Broadcast(*Row);
|
||
|
|
}
|
||
|
|
//Debug Message code incase stops working
|
||
|
|
//const FString msg = FString::Printf(TEXT("GE Tag: %s"), *Tag.ToString());
|
||
|
|
//GEngine->AddOnScreenDebugMessage(-1,8.f, FColor::Blue,msg);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}
|