File size: 2,555 Bytes
7fd553e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | // Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "System/GameplayTagStack.h"
#include "Templates/SubclassOf.h"
#include "LyraInventoryItemInstance.generated.h"
class FLifetimeProperty;
class ULyraInventoryItemDefinition;
class ULyraInventoryItemFragment;
struct FFrame;
struct FGameplayTag;
/**
* ULyraInventoryItemInstance
*/
UCLASS(BlueprintType)
class ULyraInventoryItemInstance : public UObject
{
GENERATED_BODY()
public:
ULyraInventoryItemInstance(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
//~UObject interface
virtual bool IsSupportedForNetworking() const override { return true; }
//~End of UObject interface
// Adds a specified number of stacks to the tag (does nothing if StackCount is below 1)
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category=Inventory)
void AddStatTagStack(FGameplayTag Tag, int32 StackCount);
// Removes a specified number of stacks from the tag (does nothing if StackCount is below 1)
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category= Inventory)
void RemoveStatTagStack(FGameplayTag Tag, int32 StackCount);
// Returns the stack count of the specified tag (or 0 if the tag is not present)
UFUNCTION(BlueprintCallable, Category=Inventory)
int32 GetStatTagStackCount(FGameplayTag Tag) const;
// Returns true if there is at least one stack of the specified tag
UFUNCTION(BlueprintCallable, Category=Inventory)
bool HasStatTag(FGameplayTag Tag) const;
TSubclassOf<ULyraInventoryItemDefinition> GetItemDef() const
{
return ItemDef;
}
UFUNCTION(BlueprintCallable, BlueprintPure=false, meta=(DeterminesOutputType=FragmentClass))
const ULyraInventoryItemFragment* FindFragmentByClass(TSubclassOf<ULyraInventoryItemFragment> FragmentClass) const;
template <typename ResultClass>
const ResultClass* FindFragmentByClass() const
{
return (ResultClass*)FindFragmentByClass(ResultClass::StaticClass());
}
private:
#if UE_WITH_IRIS
/** Register all replication fragments */
virtual void RegisterReplicationFragments(UE::Net::FFragmentRegistrationContext& Context, UE::Net::EFragmentRegistrationFlags RegistrationFlags) override;
#endif // UE_WITH_IRIS
void SetItemDef(TSubclassOf<ULyraInventoryItemDefinition> InDef);
friend struct FLyraInventoryList;
private:
UPROPERTY(Replicated)
FGameplayTagStackContainer StatTags;
// The item definition
UPROPERTY(Replicated)
TSubclassOf<ULyraInventoryItemDefinition> ItemDef;
};
|