bool ASpawnWithHoudini::ClearObstacles()

in Ambit/Source/Ambit/Actors/Spawners/SpawnWithHoudini.cpp [131:162]


bool ASpawnWithHoudini::ClearObstacles()
{
    UWorld* World = GetWorld();

    const bool bIsRuntime = World != nullptr && (World->IsPlayInEditor() || World->IsPlayInPreview());

    if (CurrentGeneration == FromEditor && bIsRuntime)
    {
        FMenuHelpers::DisplayMessagePopup("Content generated in the editor cannot be modified in runtime.", "Error");
        return false;
    }

    for (auto& LoadedSet : HoudiniAssetDetails)
    {
        TArray<UHoudiniPublicAPIAssetWrapper*> SpawnedActors = LoadedSet.SpawnedActors;

        for (auto* Actor : SpawnedActors)
        {
            if (Actor->IsValidLowLevel() && !Actor->IsPendingKill())
            {
                Actor->DeleteInstantiatedAsset();
            }
        }

        LoadedSet.SpawnedActors.Empty();
    }

    CurrentGeneration = NotGenerated;
    ActorBakeCount = 0;
    CachedActorCount = 0;
    return true;
}