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

#include "SCW_UInheritableComponentHandler.h"
#include "Engine/InheritableComponentHandler.h"
#include "SourcifyCoreUEWrapperModule.h"
#include "SCW_FComponentKey.h"

using namespace Sourcify;

SCW_UInheritableComponentHandler::SCW_UInheritableComponentHandler(UInheritableComponentHandler* InInheritableComponentHandler) : SCW_UObject(InInheritableComponentHandler), InheritableComponentHandler(InInheritableComponentHandler)
{

}

UInheritableComponentHandler* SCW_UInheritableComponentHandler::ToUInheritableComponentHandler() const
{
	return InheritableComponentHandler;
}

ISCW_UInheritableComponentHandlerPtr SCW_UInheritableComponentHandler::ToUInheritableComponentHandlerPtr()
{
	return GetSharedThisAs<SCW_UInheritableComponentHandler>();
}

ISCW_UInheritableComponentHandlerConstPtr SCW_UInheritableComponentHandler::ToUInheritableComponentHandlerPtr() const
{
	return GetSharedThisAs<SCW_UInheritableComponentHandler>();
}

ISCW_UActorComponentPtr SCW_UInheritableComponentHandler::CreateOverridenComponentTemplate(ISCW_FComponentKeyPtr Key)
{
	SCW_FComponentKey* SCWKey = dynamic_cast<SCW_FComponentKey*>(Key.get());
	return FSourcifyCoreUEWrapper::Get().Wrap(*InheritableComponentHandler->CreateOverridenComponentTemplate(SCWKey->ToFComponentKey()));
}

ISCW_UActorComponentPtr SCW_UInheritableComponentHandler::GetOverridenComponentTemplate(ISCW_FComponentKeyPtr Key) const
{
	SCW_FComponentKey* SCWKey = dynamic_cast<SCW_FComponentKey*>(Key.get());
	return FSourcifyCoreUEWrapper::Get().Wrap(*InheritableComponentHandler->GetOverridenComponentTemplate(SCWKey->ToFComponentKey()));
}