46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||
|
|
||
|
#include "LyraGameplayAbility_FromEquipment.h"
|
||
|
#include "LyraEquipmentInstance.h"
|
||
|
#include "Inventory/LyraInventoryItemInstance.h"
|
||
|
|
||
|
ULyraGameplayAbility_FromEquipment::ULyraGameplayAbility_FromEquipment(const FObjectInitializer& ObjectInitializer)
|
||
|
: Super(ObjectInitializer)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
ULyraEquipmentInstance* ULyraGameplayAbility_FromEquipment::GetAssociatedEquipment() const
|
||
|
{
|
||
|
if (FGameplayAbilitySpec* Spec = UGameplayAbility::GetCurrentAbilitySpec())
|
||
|
{
|
||
|
return Cast<ULyraEquipmentInstance>(Spec->SourceObject);
|
||
|
}
|
||
|
|
||
|
return nullptr;
|
||
|
}
|
||
|
|
||
|
ULyraInventoryItemInstance* ULyraGameplayAbility_FromEquipment::GetAssociatedItem() const
|
||
|
{
|
||
|
if (ULyraEquipmentInstance* Equipment = GetAssociatedEquipment())
|
||
|
{
|
||
|
return Cast<ULyraInventoryItemInstance>(Equipment->GetInstigator());
|
||
|
}
|
||
|
return nullptr;
|
||
|
}
|
||
|
|
||
|
|
||
|
#if WITH_EDITOR
|
||
|
EDataValidationResult ULyraGameplayAbility_FromEquipment::IsDataValid(TArray<FText>& ValidationErrors)
|
||
|
{
|
||
|
EDataValidationResult Result = Super::IsDataValid(ValidationErrors);
|
||
|
|
||
|
if (InstancingPolicy == EGameplayAbilityInstancingPolicy::NonInstanced)
|
||
|
{
|
||
|
ValidationErrors.Add(NSLOCTEXT("Lyra", "EquipmentAbilityMustBeInstanced", "Equipment ability must be instanced"));
|
||
|
Result = EDataValidationResult::Invalid;
|
||
|
}
|
||
|
|
||
|
return Result;
|
||
|
}
|
||
|
|
||
|
#endif
|