#include "HostWidgetController.h" #include "AbilitySystem/GasaAbilitySystemComponent_Inlines.h" #include "AbilitySystem/GasaAttributeSet.h" #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 void UHostWidgetController::BroadcastInitialValues() { UGasaAttributeSet* GasaAttribs = Cast( Data.Attributes ); if ( GasaAttribs ) { Event_OnHealthChanged.Broadcast( GasaAttribs->GetHealth() ); Event_OnMaxHealthChanged.Broadcast( GasaAttribs->GetMaxHealth() ); Event_OnManaChanged.Broadcast( GasaAttribs->GetMana() ); Event_OnMaxManaChanged.Broadcast( GasaAttribs->GetMaxMana() ); } } void UHostWidgetController::BindCallbacksToDependencies() { UGasaAbilitySystemComp* AbilitySystem = Cast( Data.AbilitySystem ); UGasaAttributeSet* GasaAttribs = Cast( 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 ); }