Files
UnrealEngineUWP/Engine/Plugins/Runtime/SmartObjects/Source/SmartObjectsModule/Private/SmartObjectCollection.cpp
mieszko zielinski bf25520ccc SmartObject collection rework, introducing a FSmartObjectContainer type that encapsulates SmartObjectComponent registration and storage. The SmartObjectSubsystem now stores a Container that aggregates all other containers supplied by loaded/streamed in SmartObjectPersistentCollection instances.
In addition:
* SmartObjectCollection got deprecated and there's a auto-update path triggered in SmartObjectCollection::PostLoad
* SmartObjectComponent component can opt out of being a part of a collection with `bCanBePartOfCollection`
* Right now we limit SmartObjects to be registered with at most a single Collection. This might change in the future if required.

Note that this is the first change in a series, we're going to support miltiple collections per level with convenient ways of assigning SmartObjects to individual collections.

#jira UE-168977
#preflight 637f8faa4004f73f627ecaca

#preflight 637fa5378b12eb83a77ad7d9

[CL 23262132 by mieszko zielinski in ue5-main branch]
2022-11-24 14:53:52 -05:00

51 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SmartObjectCollection.h"
#include "SmartObjectSubsystem.h"
#include "Engine/World.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(SmartObjectCollection)
//----------------------------------------------------------------------//
// ADEPRECATED_SmartObjectCollection
//----------------------------------------------------------------------//
ADEPRECATED_SmartObjectCollection::ADEPRECATED_SmartObjectCollection(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
#if WITH_EDITORONLY_DATA
bActorLabelEditable = false;
#endif
PrimaryActorTick.bCanEverTick = false;
bNetLoadOnClient = false;
SetCanBeDamaged(false);
}
void ADEPRECATED_SmartObjectCollection::PostLoad()
{
Super::PostLoad();
#if WITH_EDITORONLY_DATA
PRAGMA_DISABLE_DEPRECATION_WARNINGS
bBuildCollectionAutomatically = !bBuildOnDemand_DEPRECATED;
PRAGMA_ENABLE_DEPRECATION_WARNINGS
if (UWorld* World = GetWorld())
{
if (World->IsEditorWorld())
{
USmartObjectSubsystem::CreatePersistentCollectionFromDeprecatedData(*World, *this);
ClearCollection();
MarkAsGarbage();
MarkPackageDirty();
}
}
#endif // WITH_EDITORONLY_DATA
}
void ADEPRECATED_SmartObjectCollection::ClearCollection()
{
CollectionEntries.Reset();
RegisteredIdToObjectMap.Empty();
Definitions.Reset();
}