Files
UnrealEngineUWP/Engine/Plugins/Runtime/SmartObjects/Source/SmartObjectsModule/Public/SmartObjectComponent.h
yoan stamant 4b56d97931 [SmartObject] added support for GameplayTags on runtime instance
+ SmartObjectComponent acts a bridge to sync tags from the RuntimeInstance and the AbilitySystemComponent (if present on the owning actor)
+ Component streamed out and back it will be bound with their persistent counterpart from the simulation and will synchronize their tags
+ RuntimeInstance and Slot now have a dedicated state when they are disabled when the instance tags don't pass the restrictions defined in the SmartObjectDefinition (ObjectTagFilter)
+ Made a pass to improve consistency in error reporting and methods descriptions
+ Added methods to validate if the object/slot associated to a FSmartObjectClaimHandle and FSmartObjectSlotHandle is still valid when those are stored and not used immediately after a call to any of the 'Find' or 'Claim' methods
#rnx
#rb mikko.mononen
#preflight 6230a0b4e65a7e65d68741e4

#ROBOMERGE-AUTHOR: yoan.stamant
#ROBOMERGE-SOURCE: CL 19386803 via CL 19389419 via CL 19398538 via CL 19398590
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v926-19321884)

[CL 19403765 by yoan stamant in ue5-main branch]
2022-03-16 03:47:02 -04:00

81 lines
3.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Components/SceneComponent.h"
#include "SmartObjectTypes.h"
#include "SmartObjectDefinition.h"
#include "SmartObjectComponent.generated.h"
class UAbilitySystemComponent;
struct FSmartObjectRuntime;
UCLASS(Blueprintable, ClassGroup = Gameplay, meta = (BlueprintSpawnableComponent), config = Game, HideCategories = (Activation, AssetUserData, Collision, Cooking, HLOD, Lighting, LOD, Mobile, Mobility, Navigation, Physics, RayTracing, Rendering, Tags, TextureStreaming))
class SMARTOBJECTSMODULE_API USmartObjectComponent : public USceneComponent
{
GENERATED_BODY()
public:
explicit USmartObjectComponent(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
FBox GetSmartObjectBounds() const;
const USmartObjectDefinition* GetDefinition() const { return DefinitionAsset; }
void SetDefinition(USmartObjectDefinition* Definition) { DefinitionAsset = Definition; }
FSmartObjectHandle GetRegisteredHandle() const { return RegisteredHandle; }
void SetRegisteredHandle(const FSmartObjectHandle Value) { RegisteredHandle = Value; }
void OnRuntimeInstanceCreated(FSmartObjectRuntime& RuntimeInstance);
void OnRuntimeInstanceDestroyed();
void OnRuntimeInstanceBound(FSmartObjectRuntime& RuntimeInstance);
void OnRuntimeInstanceUnbound(FSmartObjectRuntime& RuntimeInstance);
protected:
friend struct FSmartObjectComponentInstanceData;
virtual TStructOnScope<FActorComponentInstanceData> GetComponentInstanceData() const override;
virtual void OnRegister() override;
virtual void OnUnregister() override;
void RegisterToSubsystem();
void BindTagsDelegates(FSmartObjectRuntime& RuntimeInstance, UAbilitySystemComponent& AbilitySystemComponent);
void UnbindComponentTagsDelegate();
void UnbindRuntimeInstanceTagsDelegate(FSmartObjectRuntime& RuntimeInstance);
UPROPERTY(EditAnywhere, Category = SmartObject, BlueprintReadWrite)
TObjectPtr<USmartObjectDefinition> DefinitionAsset;
/** RegisteredHandle != FSmartObjectHandle::Invalid when registered into a collection by SmartObjectSubsystem */
UPROPERTY(Transient, VisibleAnywhere, Category = SmartObject)
FSmartObjectHandle RegisteredHandle;
FDelegateHandle OnComponentTagsModifiedHandle;
bool bInstanceTagsDelegateBound = false;
};
/** Used to store SmartObjectComponent data during RerunConstructionScripts */
USTRUCT()
struct FSmartObjectComponentInstanceData : public FActorComponentInstanceData
{
GENERATED_BODY()
public:
FSmartObjectComponentInstanceData() = default;
explicit FSmartObjectComponentInstanceData(const USmartObjectComponent* SourceComponent, USmartObjectDefinition* Asset)
: FActorComponentInstanceData(SourceComponent)
, DefinitionAsset(Asset)
{}
USmartObjectDefinition* GetDefinitionAsset() const { return DefinitionAsset; }
protected:
virtual bool ContainsData() const override;
virtual void ApplyToComponent(UActorComponent* Component, const ECacheApplyPhase CacheApplyPhase) override;
UPROPERTY()
TObjectPtr<USmartObjectDefinition> DefinitionAsset = nullptr;
};