diff --git a/Source/GameBaseFramework/Private/GAS/Abilities/GBFAbilitySet.cpp b/Source/GameBaseFramework/Private/GAS/Abilities/GBFAbilitySet.cpp index 1027df14..94410c1e 100644 --- a/Source/GameBaseFramework/Private/GAS/Abilities/GBFAbilitySet.cpp +++ b/Source/GameBaseFramework/Private/GAS/Abilities/GBFAbilitySet.cpp @@ -112,43 +112,43 @@ void UGBFAbilitySet::GiveToAbilitySystem( UAbilitySystemComponent * asc, FGBFAbi } } - // Grant the gameplay effects. - for ( auto effect_index = 0; effect_index < GrantedGameplayEffects.Num(); ++effect_index ) + // Grant the attribute sets. + for ( auto set_index = 0; set_index < GrantedAttributes.Num(); ++set_index ) { - const auto & effect_to_grant = GrantedGameplayEffects[ effect_index ]; + const auto & set_to_grant = GrantedAttributes[ set_index ]; - if ( !IsValid( effect_to_grant.GameplayEffect ) ) + if ( !IsValid( set_to_grant.AttributeSet ) ) { - UE_LOG( LogGBF_GAS, Error, TEXT( "GrantedGameplayEffects[%d] on ability set [%s] is not valid" ), effect_index, *GetNameSafe( this ) ); + UE_LOG( LogGBF_GAS, Error, TEXT( "GrantedAttributes[%d] on ability set [%s] is not valid" ), set_index, *GetNameSafe( this ) ); continue; } - const auto * gameplay_effect = effect_to_grant.GameplayEffect->GetDefaultObject< UGameplayEffect >(); - const auto gameplay_effect_handle = asc->ApplyGameplayEffectToSelf( gameplay_effect, effect_to_grant.EffectLevel, asc->MakeEffectContext() ); + auto * new_set = NewObject< UAttributeSet >( asc->GetOwner(), set_to_grant.AttributeSet ); + asc->AddAttributeSetSubobject( new_set ); if ( out_granted_handles != nullptr ) { - out_granted_handles->AddGameplayEffectHandle( gameplay_effect_handle ); + out_granted_handles->AddAttributeSet( new_set ); } } - // Grant the attribute sets. - for ( auto set_index = 0; set_index < GrantedAttributes.Num(); ++set_index ) + // Grant the gameplay effects. + for ( auto effect_index = 0; effect_index < GrantedGameplayEffects.Num(); ++effect_index ) { - const auto & set_to_grant = GrantedAttributes[ set_index ]; + const auto & effect_to_grant = GrantedGameplayEffects[ effect_index ]; - if ( !IsValid( set_to_grant.AttributeSet ) ) + if ( !IsValid( effect_to_grant.GameplayEffect ) ) { - UE_LOG( LogGBF_GAS, Error, TEXT( "GrantedAttributes[%d] on ability set [%s] is not valid" ), set_index, *GetNameSafe( this ) ); + UE_LOG( LogGBF_GAS, Error, TEXT( "GrantedGameplayEffects[%d] on ability set [%s] is not valid" ), effect_index, *GetNameSafe( this ) ); continue; } - auto * new_set = NewObject< UAttributeSet >( asc->GetOwner(), set_to_grant.AttributeSet ); - asc->AddAttributeSetSubobject( new_set ); + const auto * gameplay_effect = effect_to_grant.GameplayEffect->GetDefaultObject< UGameplayEffect >(); + const auto gameplay_effect_handle = asc->ApplyGameplayEffectToSelf( gameplay_effect, effect_to_grant.EffectLevel, asc->MakeEffectContext() ); if ( out_granted_handles != nullptr ) { - out_granted_handles->AddAttributeSet( new_set ); + out_granted_handles->AddGameplayEffectHandle( gameplay_effect_handle ); } } } \ No newline at end of file