You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This is required since the newly created components in the process will try to register before the Definition asset gets set. #rb maxime.mercier #rnx #preflight 61faf0935e35b9215bfedaab #ROBOMERGE-AUTHOR: yoan.stamant #ROBOMERGE-SOURCE: CL 18841643 via CL 18842123 via CL 18842168 via CL 18845170 via CL 18845776 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18845836 by yoan stamant in ue5-main branch]
66 lines
2.4 KiB
C++
66 lines
2.4 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"
|
|
|
|
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; }
|
|
|
|
protected:
|
|
friend struct FSmartObjectComponentInstanceData;
|
|
virtual TStructOnScope<FActorComponentInstanceData> GetComponentInstanceData() const override;
|
|
|
|
virtual void OnRegister() override;
|
|
virtual void OnUnregister() override;
|
|
|
|
void RegisterToSubsystem();
|
|
|
|
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;
|
|
};
|
|
|
|
|
|
/** 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;
|
|
}; |