// REALMS IN RUIN. Copyright (c) 2025 Trevor Edwards. All rights reserved. #include "UI/WidgetController/OverlayWidgetController.h" #include "Attributes/RIRAttributeSet.h" void UOverlayWidgetController::BroadcastInitialInitialValues() { const URIRAttributeSet* RIRAttributeSet = CastChecked(AttributeSet); OnHealthChanged.Broadcast(RIRAttributeSet->GetHealth()); OnMaxHealthChanged.Broadcast(RIRAttributeSet->GetMaxHealth()); OnManaChanged.Broadcast(RIRAttributeSet->GetMana()); OnMaxManaChanged.Broadcast(RIRAttributeSet->GetMaxMana()); OnStaminaChanged.Broadcast(RIRAttributeSet->GetStamina()); OnMaxStaminaChanged.Broadcast(RIRAttributeSet->GetMaxStamina()); } void UOverlayWidgetController::BindCallbacksToDependencies() { const URIRAttributeSet* RIRAttributeSet = CastChecked(AttributeSet); // Register a delegate to be notified when the Health attribute changes. AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(RIRAttributeSet->GetHealthAttribute()).AddUObject(this, &UOverlayWidgetController::HealthChanged); // Register a delegate for MaxHealth changes. AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(RIRAttributeSet->GetMaxHealthAttribute()).AddUObject(this, &UOverlayWidgetController::MaxHealthChanged); // Register a delegate for Mana changes. AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(RIRAttributeSet->GetManaAttribute()).AddUObject(this, &UOverlayWidgetController::ManaChanged); // Register a delegate for MaxMana changes. AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(RIRAttributeSet->GetMaxManaAttribute()).AddUObject(this, &UOverlayWidgetController::MaxManaChanged); // Register a delegate for Stamina changes. AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(RIRAttributeSet->GetStaminaAttribute()).AddUObject(this, &UOverlayWidgetController::StaminaChanged); // Register a delegate for MaxStamina changes. AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(RIRAttributeSet->GetMaxStaminaAttribute()).AddUObject(this, &UOverlayWidgetController::MaxStaminaChanged); } void UOverlayWidgetController::HealthChanged(const FOnAttributeChangeData& Data) const { // Broadcasts the new Health value to the UI layer. OnHealthChanged.Broadcast(Data.NewValue); } void UOverlayWidgetController::MaxHealthChanged(const FOnAttributeChangeData& Data) const { // Broadcasts the new MaxHealth value to the UI layer. OnMaxHealthChanged.Broadcast(Data.NewValue); } void UOverlayWidgetController::ManaChanged(const FOnAttributeChangeData& Data) const { // Broadcasts the new Mana value to the UI layer. OnManaChanged.Broadcast(Data.NewValue); } void UOverlayWidgetController::MaxManaChanged(const FOnAttributeChangeData& Data) const { // Broadcasts the new MaxMana value to the UI layer. OnMaxManaChanged.Broadcast(Data.NewValue); } void UOverlayWidgetController::StaminaChanged(const FOnAttributeChangeData& Data) const { // Broadcasts the new Stamina value to the UI layer. OnStaminaChanged.Broadcast(Data.NewValue); } void UOverlayWidgetController::MaxStaminaChanged(const FOnAttributeChangeData& Data) const { // Broadcasts the new MaxStamina value to the UI layer. OnMaxStaminaChanged.Broadcast(Data.NewValue); }