/**
 * Copyright 2022-2025 Theai, Inc. dba Inworld AI
 */
#include "GraphEditor/InworldGraphEdgeFactory.h"
#include "Graph/Edges/InworldEdge_WithCondition.h"
#include "Kismet2/KismetEditorUtilities.h"
#include "AssetTypeCategories.h"

UInworldGraphEdgeFactory::UInworldGraphEdgeFactory()
{
	bCreateNew = true;
	bEditAfterNew = true;
	SupportedClass = UInworldEdge_WithCondition::StaticClass();
}

UObject* UInworldGraphEdgeFactory::FactoryCreateNew(
	UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
{
	UBlueprint* NewEdge = FKismetEditorUtilities::CreateBlueprint(UInworldEdge_WithCondition::StaticClass(), InParent, InName,
		BPTYPE_Normal, UBlueprint::StaticClass(), UBlueprintGeneratedClass::StaticClass());
	if (NewEdge->GeneratedClass)
	{
		UObject* CDO = NewEdge->GeneratedClass->GetDefaultObject();
		if (UInworldEdge_WithCondition* DefaultEdge = Cast<UInworldEdge_WithCondition>(CDO))
		{
			DefaultEdge->EdgeTitle = InName.ToString();
		}
	}
	return NewEdge;
}
