mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 08:02:23 -07:00
First Submit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#include "CogSampleFunctionLibrary_Gameplay.h"
|
||||
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "GameplayEffectTypes.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSampleFunctionLibrary_Gameplay::AdjustAttributeForMaxChange(UAbilitySystemComponent* AbilityComponent, FGameplayAttributeData& AffectedAttribute, float OldValue, float NewMaxValue, const FGameplayAttribute& AffectedAttributeProperty)
|
||||
{
|
||||
if (AbilityComponent == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (FMath::IsNearlyEqual(OldValue, NewMaxValue))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Change current value to maintain the current Val / Max percent
|
||||
const float CurrentValue = AffectedAttribute.GetCurrentValue();
|
||||
const float NewDelta = (OldValue > 0.f) ? (CurrentValue * NewMaxValue / OldValue) - CurrentValue : NewMaxValue;
|
||||
|
||||
AbilityComponent->ApplyModToAttributeUnsafe(AffectedAttributeProperty, EGameplayModOp::Additive, NewDelta);
|
||||
}
|
||||
Reference in New Issue
Block a user