// Copyright (c) 2024 Codemongous LLC. All Rights Reserved.

#include "SCW_FBPInterfaceDescription.h"
#include "Engine/Blueprint.h"
#include "SCW_UClass.h"
#include "SourcifyCoreUEWrapperModule.h"

using namespace Sourcify;

SCW_FBPInterfaceDescription::SCW_FBPInterfaceDescription(FBPInterfaceDescription* InBPInterfaceDescription) : BPInterfaceDescription(InBPInterfaceDescription)
{

}

vector<ISCW_UEdGraphPtr> SCW_FBPInterfaceDescription::GetGraphs() const
{
	vector<ISCW_UEdGraphPtr> Result;
	for (UEdGraph* Graph : BPInterfaceDescription->Graphs)
	{
		Result.push_back(FSourcifyCoreUEWrapper::Get().Wrap(*Graph));
	}
	return Result;
}

ISCW_UClassPtr SCW_FBPInterfaceDescription::GetInterface() const
{
	return FSourcifyCoreUEWrapper::Get().Wrap(*BPInterfaceDescription->Interface.Get());
}

void SCW_FBPInterfaceDescription::SetInterface(ISCW_UClassConstPtr InInterface)
{
	BPInterfaceDescription->Interface = dynamic_cast<const SCW_UClass*>(InInterface.get())->ToUClass();
}

FBPInterfaceDescription* SCW_FBPInterfaceDescription::ToFBPInterfaceDescription() const
{
	return BPInterfaceDescription;
}

ISCW_FBPInterfaceDescriptionPtr SCW_FBPInterfaceDescription::ToFBPInterfaceDescriptionPtr()
{
	return GetSharedThisAs<SCW_FBPInterfaceDescription>();
}

ISCW_FBPInterfaceDescriptionConstPtr SCW_FBPInterfaceDescription::ToFBPInterfaceDescriptionPtr() const
{
	return GetSharedThisAs<SCW_FBPInterfaceDescription>();
}