RealtimeStyleTransferRuntime/Source/LyraGame/Inventory/LyraInventoryItemInstance.h

81 lines
2.6 KiB
C
Raw Permalink Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
2022-09-13 07:18:28 +00:00
#include "HAL/Platform.h"
2022-05-23 18:41:30 +00:00
#include "System/GameplayTagStack.h"
2022-09-13 07:18:28 +00:00
#include "Templates/SubclassOf.h"
#include "UObject/Object.h"
#include "UObject/UObjectGlobals.h"
2022-05-23 18:41:30 +00:00
#include "LyraInventoryItemInstance.generated.h"
2022-09-13 07:18:28 +00:00
class ULyraInventoryItemDefinition;
class ULyraInventoryItemFragment;
struct FFrame;
struct FGameplayTag;
2022-05-23 18:41:30 +00:00
/**
* 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:
2022-09-13 07:18:28 +00:00
#if UE_WITH_IRIS
/** Register all replication fragments */
virtual void RegisterReplicationFragments(UE::Net::FFragmentRegistrationContext& Context, UE::Net::EFragmentRegistrationFlags RegistrationFlags) override;
#endif // UE_WITH_IRIS
2022-05-23 18:41:30 +00:00
void SetItemDef(TSubclassOf<ULyraInventoryItemDefinition> InDef);
friend struct FLyraInventoryList;
private:
UPROPERTY(Replicated)
FGameplayTagStackContainer StatTags;
// The item definition
UPROPERTY(Replicated)
TSubclassOf<ULyraInventoryItemDefinition> ItemDef;
};