2025-10-15 18:50:55 -04:00
|
|
|
// Copyright Echo Devgroup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "UI/WidgetController/AttributeMenuWidgetController.h"
|
|
|
|
|
#include "AbilitySystem/Data/AttributeInfo.h"
|
|
|
|
|
#include "AbilitySystem/AuraAttributeSet.h"
|
|
|
|
|
|
2025-10-15 20:11:02 -04:00
|
|
|
void UAttributeMenuWidgetController::BindCallbacksToDependencies()
|
|
|
|
|
{
|
|
|
|
|
UAuraAttributeSet* AS = CastChecked<UAuraAttributeSet>(AttributeSet);
|
|
|
|
|
check(AttributeInfo);
|
|
|
|
|
for (auto& Pair : AS->TagsToAttributes)
|
|
|
|
|
{
|
|
|
|
|
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Pair.Value()).AddLambda(
|
|
|
|
|
[this, Pair](const FOnAttributeChangeData& Data)
|
|
|
|
|
{
|
|
|
|
|
BroadcastAttributeInfo(Pair.Key, Pair.Value());
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-15 18:50:55 -04:00
|
|
|
|
2025-10-15 20:11:02 -04:00
|
|
|
void UAttributeMenuWidgetController::BroadcastInitialValues()
|
|
|
|
|
{
|
|
|
|
|
UAuraAttributeSet* AS = CastChecked<UAuraAttributeSet>(AttributeSet);
|
|
|
|
|
check(AttributeInfo);
|
|
|
|
|
for (auto& Pair : AS->TagsToAttributes)
|
|
|
|
|
{
|
|
|
|
|
BroadcastAttributeInfo(Pair.Key, Pair.Value());
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-15 18:50:55 -04:00
|
|
|
|
2025-10-15 20:11:02 -04:00
|
|
|
void UAttributeMenuWidgetController::BroadcastAttributeInfo(const FGameplayTag& AttributeTag, const FGameplayAttribute& Attribute) const
|
|
|
|
|
{
|
|
|
|
|
FAuraAttributeInfo Info = AttributeInfo->FindAttributeInfoForTag(AttributeTag);
|
|
|
|
|
Info.AttributeValue = Attribute.GetNumericValue(AttributeSet);
|
|
|
|
|
AttributeInfoDelegate.Broadcast(Info);
|
|
|
|
|
}
|