mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 08:02:23 -07:00
starting to add the hud in the sample
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user