37 lines
938 B
C++
37 lines
938 B
C++
// Multiplayer By Caleb
|
|
|
|
|
|
#include "GAS/CAbilitySystemComponent.h"
|
|
|
|
|
|
void UCAbilitySystemComponent::ApplyInitialEffects()
|
|
{
|
|
if (!GetOwner() || !GetOwner()->HasAuthority()) return;
|
|
|
|
for (const auto& EffectClass : InitialEffects)
|
|
{
|
|
/**
|
|
* this will work as well
|
|
* const auto Effect{EffectClass->GetDefaultObject<UGameplayEffect>()};
|
|
* ApplyGameplayEffectToSelf(Effect, 0.f, MakeEffectContext());
|
|
**/
|
|
auto GameplayEffectSpecHandle{MakeOutgoingSpec(EffectClass, 1, MakeEffectContext())};
|
|
ApplyGameplayEffectSpecToSelf(*GameplayEffectSpecHandle.Data.Get());
|
|
}
|
|
}
|
|
|
|
void UCAbilitySystemComponent::GiveInitialAbilities()
|
|
{
|
|
if (!GetOwner() || !GetOwner()->HasAuthority()) return;
|
|
|
|
for (const auto& AbilityClass : Abilities)
|
|
{
|
|
GiveAbility(FGameplayAbilitySpec(AbilityClass, 0, -1, nullptr));
|
|
}
|
|
|
|
for (const auto& AbilityClass : BasicAbilities)
|
|
{
|
|
GiveAbility(FGameplayAbilitySpec(AbilityClass, 1, -1, nullptr));
|
|
}
|
|
}
|