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

#include "SCW_USCS_Node.h"
#include "Engine/SCS_Node.h"
#include "SourcifyCoreUEWrapperModule.h"

using namespace Sourcify;

SCW_USCS_Node::SCW_USCS_Node(USCS_Node* InSCS_Node) : SCW_UObject(InSCS_Node), SCS_Node(InSCS_Node)
{

}

void SCW_USCS_Node::ClearOnNameChanged()
{
	SCS_Node->SetOnNameChanged(FSCSNodeNameChanged());
}

wstring SCW_USCS_Node::GetAttachToName() const
{
	return *SCS_Node->AttachToName.ToString();
}

vector<shared_ptr<ISCW_USCS_Node>> SCW_USCS_Node::GetChildNodes() const
{
	vector<shared_ptr<ISCW_USCS_Node>> WrappedNodes;
	for (USCS_Node* Node : SCS_Node->ChildNodes)
	{
		WrappedNodes.push_back(FSourcifyCoreUEWrapper::Get().Wrap(*Node));
	}
	return WrappedNodes;
}

ISCW_UClassConstPtr SCW_USCS_Node::GetComponentClass() const
{
	return FSourcifyCoreUEWrapper::Get().Wrap(*SCS_Node->ComponentClass);
}

ISCW_UActorComponentPtr SCW_USCS_Node::GetComponentTemplate() const
{
	return FSourcifyCoreUEWrapper::Get().Wrap(*SCS_Node->ComponentTemplate);
}

wstring SCW_USCS_Node::GetVariableName() const
{
	return *SCS_Node->GetVariableName().ToString();
}

wstring SCW_USCS_Node::GetParentComponentOrVariableName() const
{
	return *SCS_Node->ParentComponentOrVariableName.ToString();
}

ISCW_USimpleConstructionScriptPtr SCW_USCS_Node::GetSCS() const
{
	return FSourcifyCoreUEWrapper::Get().Wrap(*SCS_Node->GetSCS());
}

bool SCW_USCS_Node::IsParentComponentNative() const
{
	return SCS_Node->bIsParentComponentNative;
}

USCS_Node* SCW_USCS_Node::ToUSCS_Node() const
{
	return SCS_Node;
}

ISCW_USCS_NodePtr SCW_USCS_Node::ToUSCS_NodePtr()
{
	return GetSharedThisAs<SCW_USCS_Node>();
}

ISCW_USCS_NodeConstPtr SCW_USCS_Node::ToUSCS_NodePtr() const
{
	return GetSharedThisAs<SCW_USCS_Node>();
}

