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

89 lines
3.4 KiB
C++
Raw Permalink 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"
2024-04-26 17:08:08 -07:00
#include "GasaDevOptions.h"
#include "TaggedMessageRow.h"
using namespace Gasa;
2024-04-21 22:54:33 -07:00
2024-04-21 22:54:33 -07:00
#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-26 17:08:08 -07:00
void UHostWidgetController::OnEffectAppliedAssetTags( FGameplayTagContainer const& AssetTags )
{
UDataTable* TaggedMessages = GetDevOptions()->TaggedMessageTable.Get();
for ( FGameplayTag const& Tag : AssetTags )
{
FGameplayTag MessageTagCategory = FGameplayTag::RequestGameplayTag( FName( "Message" ) );
if ( ! Tag.MatchesTag( MessageTagCategory ) )
continue;
FTaggedMessageRow* Row = TaggedMessages->FindRow<FTaggedMessageRow>( Tag.GetTagName(), TEXT( "" ) );
OnTaggedAssetMessage.Broadcast( *Row );
}
}
2024-04-21 21:30:29 -07:00
void UHostWidgetController::BroadcastInitialValues()
{
2024-04-22 09:01:30 -07:00
// This function is managed by: GenGasa/GenGasa_HostWidgetController.cpp
2024-04-21 21:30:29 -07:00
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-22 09:01:30 -07:00
BindCallbacksToDependencies();
2024-04-21 21:30:29 -07:00
}
2024-04-21 22:54:33 -07:00
void UHostWidgetController::BindCallbacksToDependencies()
{
2024-04-22 09:01:30 -07:00
// This function is managed by: GenGasa/GenGasa_HostWidgetController.cpp
2024-04-21 22:54:33 -07:00
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 );
2024-04-26 17:08:08 -07:00
AbilitySystem->Event_OnEffectAppliedAssetTags.AddUObject( this, &UHostWidgetController::OnEffectAppliedAssetTags );
2024-04-21 22:54:33 -07:00
}