GASATHON/Project/Source/Gasa/UI/HostWIdgetController.cpp
Ed_ ad41867dc5 WIP: Boostrapping NetSlime
- Just a old name for a set of changes to make the game framework hardened for multiplayer as well as some ease of use functionality.
2024-04-23 01:10:02 -04:00

70 lines
2.7 KiB
C++

#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()
{
// This function is managed by: GenGasa/GenGasa_HostWidgetController.cpp
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() );
}
BindCallbacksToDependencies();
}
void UHostWidgetController::BindCallbacksToDependencies()
{
// This function is managed by: GenGasa/GenGasa_HostWidgetController.cpp
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 );
}