2021-09-28 13:33:00 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Components/SceneComponent.h"
|
|
|
|
|
#include "SmartObjectTypes.h"
|
2021-11-26 12:55:06 -05:00
|
|
|
#include "SmartObjectDefinition.h"
|
2021-09-28 13:33:00 -04:00
|
|
|
#include "SmartObjectComponent.generated.h"
|
|
|
|
|
|
2022-03-16 03:47:02 -04:00
|
|
|
class UAbilitySystemComponent;
|
|
|
|
|
struct FSmartObjectRuntime;
|
|
|
|
|
|
2021-11-02 11:09:09 -04:00
|
|
|
UCLASS(Blueprintable, ClassGroup = Gameplay, meta = (BlueprintSpawnableComponent), config = Game, HideCategories = (Activation, AssetUserData, Collision, Cooking, HLOD, Lighting, LOD, Mobile, Mobility, Navigation, Physics, RayTracing, Rendering, Tags, TextureStreaming))
|
2021-09-28 13:33:00 -04:00
|
|
|
class SMARTOBJECTSMODULE_API USmartObjectComponent : public USceneComponent
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
2021-11-02 11:09:09 -04:00
|
|
|
explicit USmartObjectComponent(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
2021-09-28 13:33:00 -04:00
|
|
|
|
|
|
|
|
FBox GetSmartObjectBounds() const;
|
|
|
|
|
|
2021-11-26 09:52:13 -05:00
|
|
|
const USmartObjectDefinition* GetDefinition() const { return DefinitionAsset; }
|
|
|
|
|
void SetDefinition(USmartObjectDefinition* Definition) { DefinitionAsset = Definition; }
|
2021-09-28 13:33:00 -04:00
|
|
|
|
2022-01-19 14:16:16 -05:00
|
|
|
FSmartObjectHandle GetRegisteredHandle() const { return RegisteredHandle; }
|
|
|
|
|
void SetRegisteredHandle(const FSmartObjectHandle Value) { RegisteredHandle = Value; }
|
2021-11-02 11:09:09 -04:00
|
|
|
|
2022-03-16 03:47:02 -04:00
|
|
|
void OnRuntimeInstanceCreated(FSmartObjectRuntime& RuntimeInstance);
|
|
|
|
|
void OnRuntimeInstanceDestroyed();
|
|
|
|
|
void OnRuntimeInstanceBound(FSmartObjectRuntime& RuntimeInstance);
|
|
|
|
|
void OnRuntimeInstanceUnbound(FSmartObjectRuntime& RuntimeInstance);
|
|
|
|
|
|
2021-09-28 13:33:00 -04:00
|
|
|
protected:
|
2022-02-03 13:28:03 -05:00
|
|
|
friend struct FSmartObjectComponentInstanceData;
|
|
|
|
|
virtual TStructOnScope<FActorComponentInstanceData> GetComponentInstanceData() const override;
|
|
|
|
|
|
2021-11-02 11:09:09 -04:00
|
|
|
virtual void OnRegister() override;
|
|
|
|
|
virtual void OnUnregister() override;
|
2021-09-28 13:33:00 -04:00
|
|
|
|
2022-02-03 13:28:03 -05:00
|
|
|
void RegisterToSubsystem();
|
|
|
|
|
|
2022-03-16 03:47:02 -04:00
|
|
|
void BindTagsDelegates(FSmartObjectRuntime& RuntimeInstance, UAbilitySystemComponent& AbilitySystemComponent);
|
|
|
|
|
void UnbindComponentTagsDelegate();
|
|
|
|
|
void UnbindRuntimeInstanceTagsDelegate(FSmartObjectRuntime& RuntimeInstance);
|
|
|
|
|
|
2022-01-31 18:38:28 -05:00
|
|
|
UPROPERTY(EditAnywhere, Category = SmartObject, BlueprintReadWrite)
|
2021-11-26 09:52:13 -05:00
|
|
|
TObjectPtr<USmartObjectDefinition> DefinitionAsset;
|
2021-09-28 13:33:00 -04:00
|
|
|
|
2022-01-19 14:16:16 -05:00
|
|
|
/** RegisteredHandle != FSmartObjectHandle::Invalid when registered into a collection by SmartObjectSubsystem */
|
2021-09-28 13:33:00 -04:00
|
|
|
UPROPERTY(Transient, VisibleAnywhere, Category = SmartObject)
|
2022-01-19 14:16:16 -05:00
|
|
|
FSmartObjectHandle RegisteredHandle;
|
2022-03-16 03:47:02 -04:00
|
|
|
|
|
|
|
|
FDelegateHandle OnComponentTagsModifiedHandle;
|
|
|
|
|
bool bInstanceTagsDelegateBound = false;
|
2021-09-28 13:33:00 -04:00
|
|
|
};
|
2022-02-03 13:28:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 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;
|
|
|
|
|
};
|