// Copyright Epic Games, Inc. All Rights Reserved. #include "LyraAbilityCost_InventoryItem.h" #include "LyraGameplayAbility.h" #include "Inventory/LyraInventoryManagerComponent.h" ULyraAbilityCost_InventoryItem::ULyraAbilityCost_InventoryItem() { Quantity.SetValue(1.0f); } bool ULyraAbilityCost_InventoryItem::CheckCost(const ULyraGameplayAbility* Ability, const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, FGameplayTagContainer* OptionalRelevantTags) const { #if 0 if (AController* PC = Ability->GetControllerFromActorInfo()) { if (ULyraInventoryManagerComponent* InventoryComponent = PC->GetComponentByClass()) { const int32 AbilityLevel = Ability->GetAbilityLevel(Handle, ActorInfo); const float NumItemsToConsumeReal = Quantity.GetValueAtLevel(AbilityLevel); const int32 NumItemsToConsume = FMath::TruncToInt(NumItemsToConsumeReal); return InventoryComponent->GetTotalItemCountByDefinition(ItemDefinition) >= NumItemsToConsume; } } #endif return false; } void ULyraAbilityCost_InventoryItem::ApplyCost(const ULyraGameplayAbility* Ability, const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo) { #if 0 if (ActorInfo->IsNetAuthority()) { if (AController* PC = Ability->GetControllerFromActorInfo()) { if (ULyraInventoryManagerComponent* InventoryComponent = PC->GetComponentByClass()) { const int32 AbilityLevel = Ability->GetAbilityLevel(Handle, ActorInfo); const float NumItemsToConsumeReal = Quantity.GetValueAtLevel(AbilityLevel); const int32 NumItemsToConsume = FMath::TruncToInt(NumItemsToConsumeReal); InventoryComponent->ConsumeItemsByDefinition(ItemDefinition, NumItemsToConsume); } } } #endif }