starting to add the hud in the sample

This commit is contained in:
Arnaud Jamin
2023-10-06 17:22:23 -04:00
parent 92396410d4
commit b18e62cd02
112 changed files with 707 additions and 333 deletions
@@ -0,0 +1,40 @@
#include "CogSampleTask_WaitAttributeChanged.h"
//--------------------------------------------------------------------------------------------------------------------------
UCogSampleTask_WaitAttributeChanged* UCogSampleTask_WaitAttributeChanged::ListenForAttributeChange(UAbilitySystemComponent* AbilitySystemComponent, FGameplayAttribute Attribute)
{
if (!IsValid(AbilitySystemComponent) || !Attribute.IsValid())
{
return nullptr;
}
UCogSampleTask_WaitAttributeChanged* WaitForAttributeChangedTask = NewObject<UCogSampleTask_WaitAttributeChanged>();
WaitForAttributeChangedTask->AbilitySystemComponent = AbilitySystemComponent;
WaitForAttributeChangedTask->AttributeToListenFor = Attribute;
return WaitForAttributeChangedTask;
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleTask_WaitAttributeChanged::Activate()
{
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AttributeToListenFor).AddUObject(this, &UCogSampleTask_WaitAttributeChanged::AttributeChanged);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleTask_WaitAttributeChanged::EndTask()
{
if (IsValid(AbilitySystemComponent))
{
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(AttributeToListenFor).RemoveAll(this);
}
SetReadyToDestroy();
MarkAsGarbage();
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleTask_WaitAttributeChanged::AttributeChanged(const FOnAttributeChangeData& Data)
{
OnAttributeChanged.Broadcast(Data.Attribute, Data.NewValue, Data.OldValue);
}