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

#include "SCW_UBlueprintGeneratedClass.h"

#include "Engine/BlueprintGeneratedClass.h"
#include "SCW_UScriptStruct.h"
#include "SourcifyCoreUEWrapperModule.h"


using namespace Sourcify;

SCW_UBlueprintGeneratedClass::SCW_UBlueprintGeneratedClass(UBlueprintGeneratedClass* InBlueprintGeneratedClass) : SCW_UClass(InBlueprintGeneratedClass), BlueprintGeneratedClass(InBlueprintGeneratedClass)
{

}

ISCW_UBlueprintGeneratedClassPtr SCW_UBlueprintGeneratedClass::ToBlueprintGeneratedClassPtr() const
{
	return GetSharedThisAs<SCW_UBlueprintGeneratedClass>();
}

ISCW_UBlueprintGeneratedClassConstPtr SCW_UBlueprintGeneratedClass::ToBlueprintGeneratedClassConstPtr() const
{
	return GetSharedThisAs<SCW_UBlueprintGeneratedClass>();
}

vector<ISCW_UActorComponentPtr> SCW_UBlueprintGeneratedClass::GetComponentTemplates() const
{
	vector<ISCW_UActorComponentPtr> Result;
	for (UActorComponent* Component : BlueprintGeneratedClass->ComponentTemplates)
	{
		Result.push_back(FSourcifyCoreUEWrapper::Get().Wrap(*Component));
	}
	return Result;
}

void SCW_UBlueprintGeneratedClass::PrepareToConformSparseClassData(ISCW_UScriptStructPtr ScriptStruct) const
{
	BlueprintGeneratedClass->PrepareToConformSparseClassData(ScriptStruct ? dynamic_cast<SCW_UScriptStruct*>(ScriptStruct.get())->ToUScriptStruct() : nullptr);
}

UBlueprintGeneratedClass* SCW_UBlueprintGeneratedClass::ToUBlueprintGeneratedClass() const
{
	return BlueprintGeneratedClass;
}

ISCW_USimpleConstructionScriptPtr SCW_UBlueprintGeneratedClass::SimpleConstructionScript() const
{
	return BlueprintGeneratedClass->SimpleConstructionScript ? FSourcifyCoreUEWrapper::Get().Wrap(*BlueprintGeneratedClass->SimpleConstructionScript) : nullptr;
}