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

#include "SCW_UPackage.h"
#include "UObject/MetaData.h"
#include "UObject/Package.h"
#include "SourcifyCoreUEWrapperModule.h"

using namespace Sourcify;

SCW_UPackage::SCW_UPackage(UPackage* InPackage) : SCW_UObject(InPackage), Package(InPackage)
{

}

UPackage* SCW_UPackage::ToUPackage() const
{
	return Package;
}

ISCW_UPackagePtr SCW_UPackage::ToUPackagePtr()
{
	return GetSharedThisAs<SCW_UPackage>();
}

ISCW_UPackageConstPtr SCW_UPackage::ToUPackagePtr() const
{
	return GetSharedThisAs<SCW_UPackage>();
}

#if ISCW_UE_VERSION_OLDER_THAN(5, 6, 0)
ISCW_UMetaDataPtr SCW_UPackage::GetMetaData() const
{
	return FSourcifyCoreUEWrapper::Get().Wrap(*Package->GetMetaData());
}
#else
ISCW_FMetaDataPtr SCW_UPackage::GetMetaData() const
{
	return FSourcifyCoreUEWrapper::Get().Wrap(Package->GetMetaData());
}
#endif // ISCW_UE_VERSION_OLDER_THAN(5, 6, 0)

wstring SCW_UPackage::GetPathName() const
{
	return *Package->GetPathName();
}

bool SCW_UPackage::IsDirty() const
{
	return Package->IsDirty();
}