Files
UnrealEngine/Engine/Plugins/Experimental/SceneState/Source/SceneStateMachineGraph/Private/SceneStateMachineGraphUtils.cpp
2025-05-18 13:04:45 +08:00

49 lines
1.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SceneStateMachineGraphUtils.h"
#include "Kismet2/BlueprintEditorUtils.h"
#include "Nodes/SceneStateMachineNode.h"
namespace UE::SceneState::Graph
{
bool CanDirectlyRemoveGraph(UEdGraph* InGraph)
{
if (!InGraph || !InGraph->bAllowDeletion)
{
return false;
}
if (USceneStateMachineNode* const ParentNode = Cast<USceneStateMachineNode>(InGraph->GetOuter()))
{
return !ParentNode->GetBoundGraphs().Contains(InGraph);
}
return true;
}
void RemoveGraph(UEdGraph* InGraph)
{
if (!InGraph)
{
return;
}
if (UEdGraph* const ParentGraph = InGraph->GetTypedOuter<UEdGraph>())
{
ParentGraph->SubGraphs.Remove(InGraph);
}
if (UBlueprint* const Blueprint = FBlueprintEditorUtils::FindBlueprintForGraph(InGraph))
{
Blueprint->LastEditedDocuments.RemoveAll(
[InGraph](const FEditedDocumentInfo& InEditedDocumentInfo)
{
UObject* EditedObject = InEditedDocumentInfo.EditedObjectPath.ResolveObject();
return EditedObject && (EditedObject == InGraph || EditedObject->IsIn(InGraph));
});
}
}
} //UE::SceneState::Graph