/**
 * Copyright 2022-2025 Theai, Inc. dba Inworld AI
 */
#include "GraphEditor/InworldGraphNodeFactory.h"
#include "Graph/Nodes/InworldNode_Custom.h"
#include "Kismet2/KismetEditorUtilities.h"
#include "AssetTypeCategories.h"

UInworldGraphNodeFactory::UInworldGraphNodeFactory()
{
	bCreateNew = true;
	bEditAfterNew = true;
	SupportedClass = UInworldNode_Custom::StaticClass();
}

UObject* UInworldGraphNodeFactory::FactoryCreateNew(
	UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
{
	UBlueprint* NewNode = FKismetEditorUtilities::CreateBlueprint(UInworldNode_Custom::StaticClass(), InParent, InName, BPTYPE_Normal,
		UBlueprint::StaticClass(), UBlueprintGeneratedClass::StaticClass());
	if (NewNode->GeneratedClass)
	{
		UObject* CDO = NewNode->GeneratedClass->GetDefaultObject();
		if (UInworldNode* DefaultNode = Cast<UInworldNode>(CDO))
		{
			DefaultNode->SetNodeName(InName.ToString());
		}
	}
	return NewNode;
}
