GASATHON/Project/Source/Gasa/UI/HostWIdgetController.cpp

62 lines
2.5 KiB
C++
Raw Normal View History

2024-04-21 21:30:29 -07:00
#include "HostWidgetController.h"
2024-04-21 22:54:33 -07:00
#include "AbilitySystem/GasaAbilitySystemComponent_Inlines.h"
2024-04-21 21:30:29 -07:00
#include "AbilitySystem/GasaAttributeSet.h"
2024-04-21 22:54:33 -07:00
#include "GameplayEffectTypes.h"
#pragma region Attribute Changed Callbacks
// Attribute Changed Callbacks are generated by GasaGen/GasaGen_HostWidgetController.cpp
void UHostWidgetController::HealthChanged( FOnAttributeChangeData const& Attribute )
{
Event_OnHealthChanged.Broadcast( Attribute.NewValue );
}
void UHostWidgetController::MaxHealthChanged( FOnAttributeChangeData const& Attribute )
{
Event_OnMaxHealthChanged.Broadcast( Attribute.NewValue );
}
void UHostWidgetController::ManaChanged( FOnAttributeChangeData const& Attribute )
{
Event_OnManaChanged.Broadcast( Attribute.NewValue );
}
void UHostWidgetController::MaxManaChanged( FOnAttributeChangeData const& Attribute )
{
Event_OnMaxManaChanged.Broadcast( Attribute.NewValue );
}
#pragma endregion Attribute Changed Callbacks
2024-04-21 21:30:29 -07:00
void UHostWidgetController::BroadcastInitialValues()
{
UGasaAttributeSet* GasaAttribs = Cast<UGasaAttributeSet>( Data.Attributes );
if ( GasaAttribs )
{
Event_OnHealthChanged.Broadcast( GasaAttribs->GetHealth() );
Event_OnMaxHealthChanged.Broadcast( GasaAttribs->GetMaxHealth() );
Event_OnManaChanged.Broadcast( GasaAttribs->GetMana() );
Event_OnMaxManaChanged.Broadcast( GasaAttribs->GetMaxMana() );
}
}
2024-04-21 22:54:33 -07:00
void UHostWidgetController::BindCallbacksToDependencies()
{
UGasaAbilitySystemComp* AbilitySystem = Cast<UGasaAbilitySystemComp>( Data.AbilitySystem );
UGasaAttributeSet* GasaAttribs = Cast<UGasaAttributeSet>( Data.Attributes );
FOnGameplayAttributeValueChange& HealthAttributeChangedDelegate =
AbilitySystem->GetGameplayAttributeValueChangeDelegate( GasaAttribs->GetHealthAttribute() );
HealthAttributeChangedDelegate.AddUObject( this, &ThisClass::HealthChanged );
FOnGameplayAttributeValueChange& MaxHealthAttributeChangedDelegate =
AbilitySystem->GetGameplayAttributeValueChangeDelegate( GasaAttribs->GetMaxHealthAttribute() );
MaxHealthAttributeChangedDelegate.AddUObject( this, &ThisClass::MaxHealthChanged );
FOnGameplayAttributeValueChange& ManaAttributeChangedDelegate = AbilitySystem->GetGameplayAttributeValueChangeDelegate( GasaAttribs->GetManaAttribute() );
ManaAttributeChangedDelegate.AddUObject( this, &ThisClass::ManaChanged );
FOnGameplayAttributeValueChange& MaxManaAttributeChangedDelegate =
AbilitySystem->GetGameplayAttributeValueChangeDelegate( GasaAttribs->GetMaxManaAttribute() );
MaxManaAttributeChangedDelegate.AddUObject( this, &ThisClass::MaxManaChanged );
}