GKLEffects.cpp
Click a line number to link it. Shift-click to select a range.
| 1 | // Copyright (c) 2026 Reignance Studios. MIT License, see LICENSE. |
| 2 | |
| 3 | #include "GKLEffects.h" |
| 4 | |
| 5 | #include "GKLAttributeSet.h" |
| 6 | #include "GKLGameplayTags.h" |
| 7 | |
| 8 | static FGameplayModifierInfo GKLSetByCallerModifier(const FGameplayAttribute& Attribute, const FGameplayTag& DataTag) |
| 9 | { |
| 10 | FSetByCallerFloat SetByCaller; |
| 11 | SetByCaller.DataTag = DataTag; |
| 12 | |
| 13 | FGameplayModifierInfo Info; |
| 14 | Info.Attribute = Attribute; |
| 15 | Info.ModifierOp = EGameplayModOp::Additive; |
| 16 | Info.ModifierMagnitude = FGameplayEffectModifierMagnitude(SetByCaller); |
| 17 | return Info; |
| 18 | } |
| 19 | |
| 20 | static FGameplayModifierInfo GKLConstantModifier(const FGameplayAttribute& Attribute, float Value) |
| 21 | { |
| 22 | FGameplayModifierInfo Info; |
| 23 | Info.Attribute = Attribute; |
| 24 | Info.ModifierOp = EGameplayModOp::Additive; |
| 25 | Info.ModifierMagnitude = FGameplayEffectModifierMagnitude(FScalableFloat(Value)); |
| 26 | return Info; |
| 27 | } |
| 28 | |
| 29 | UGKLCostEffect::UGKLCostEffect() |
| 30 | { |
| 31 | DurationPolicy = EGameplayEffectDurationType::Instant; |
| 32 | Modifiers.Add(GKLSetByCallerModifier(UGKLAttributeSet::GetStaminaAttribute(), GKLTags::Data_Cost_Stamina)); |
| 33 | Modifiers.Add(GKLSetByCallerModifier(UGKLAttributeSet::GetManaAttribute(), GKLTags::Data_Cost_Mana)); |
| 34 | } |
| 35 | |
| 36 | UGKLCooldownEffect::UGKLCooldownEffect() |
| 37 | { |
| 38 | FSetByCallerFloat SetByCaller; |
| 39 | SetByCaller.DataTag = GKLTags::Data_Cooldown; |
| 40 | |
| 41 | DurationPolicy = EGameplayEffectDurationType::HasDuration; |
| 42 | DurationMagnitude = FGameplayEffectModifierMagnitude(SetByCaller); |
| 43 | } |
| 44 | |
| 45 | UGKLDamageEffect::UGKLDamageEffect() |
| 46 | { |
| 47 | DurationPolicy = EGameplayEffectDurationType::Instant; |
| 48 | Modifiers.Add(GKLSetByCallerModifier(UGKLAttributeSet::GetDamageAttribute(), GKLTags::Data_Damage)); |
| 49 | } |
| 50 | |
| 51 | UGKLHealEffect::UGKLHealEffect() |
| 52 | { |
| 53 | DurationPolicy = EGameplayEffectDurationType::Instant; |
| 54 | Modifiers.Add(GKLSetByCallerModifier(UGKLAttributeSet::GetHealthAttribute(), GKLTags::Data_Healing)); |
| 55 | } |
| 56 | |
| 57 | UGKLRegenEffect::UGKLRegenEffect() |
| 58 | { |
| 59 | DurationPolicy = EGameplayEffectDurationType::Infinite; |
| 60 | Period = 1.f; |
| 61 | Modifiers.Add(GKLConstantModifier(UGKLAttributeSet::GetStaminaAttribute(), 10.f)); |
| 62 | Modifiers.Add(GKLConstantModifier(UGKLAttributeSet::GetManaAttribute(), 2.f)); |
| 63 | } |