2023-01-31 14:46:14 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "GeometryCollection/GeometryCollectionISMPoolSubSystem.h"
|
|
|
|
|
#include "GeometryCollection/GeometryCollectionISMPoolActor.h"
|
|
|
|
|
#include "Engine/World.h"
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
// UGeometryCollectionISMPoolSubSystem
|
|
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
UGeometryCollectionISMPoolSubSystem::UGeometryCollectionISMPoolSubSystem()
|
|
|
|
|
: ISMPoolActor(nullptr)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UGeometryCollectionISMPoolSubSystem::Initialize(FSubsystemCollectionBase& Collection)
|
|
|
|
|
{
|
|
|
|
|
Super::Initialize(Collection);
|
|
|
|
|
Collection.InitializeDependency<UGeometryCollectionISMPoolSubSystem>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UGeometryCollectionISMPoolSubSystem::Deinitialize()
|
|
|
|
|
{
|
|
|
|
|
if (ISMPoolActor)
|
|
|
|
|
{
|
|
|
|
|
if (UWorld* World = GetWorld())
|
|
|
|
|
{
|
|
|
|
|
GetWorld()->DestroyActor(ISMPoolActor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Super::Deinitialize();
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-04 19:18:34 -04:00
|
|
|
AGeometryCollectionISMPoolActor* UGeometryCollectionISMPoolSubSystem::FindISMPoolActor()
|
2023-01-31 14:46:14 -05:00
|
|
|
{
|
|
|
|
|
// on demand creation of the actor
|
|
|
|
|
// very simple logic for now, we can extend that in the future to return a specific actor based on the criteria
|
|
|
|
|
if (!ISMPoolActor)
|
|
|
|
|
{
|
|
|
|
|
// we keep it as transient to avoid accumulation of those actors in saved levels
|
|
|
|
|
FActorSpawnParameters Params;
|
|
|
|
|
Params.ObjectFlags = EObjectFlags::RF_DuplicateTransient | EObjectFlags::RF_Transient;
|
|
|
|
|
ISMPoolActor = GetWorld()->SpawnActor<AGeometryCollectionISMPoolActor>(Params);
|
|
|
|
|
}
|
|
|
|
|
return ISMPoolActor;
|
|
|
|
|
}
|
2023-06-08 19:39:06 -04:00
|
|
|
|
|
|
|
|
void UGeometryCollectionISMPoolSubSystem::GetISMPoolActors(TArray<AGeometryCollectionISMPoolActor*>& OutActors) const
|
|
|
|
|
{
|
|
|
|
|
if (ISMPoolActor != nullptr)
|
|
|
|
|
{
|
|
|
|
|
OutActors.Add(ISMPoolActor);
|
|
|
|
|
}
|
|
|
|
|
}
|