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

#include "SCW_UActorComponent.h"
#include "Components/ActorComponent.h"
#include "SourcifyCoreUEWrapperModule.h"

using namespace Sourcify;

SCW_UActorComponent::SCW_UActorComponent(UActorComponent* InActorComponent) : SCW_UObject(InActorComponent), ActorComponent(InActorComponent)
{

}

SCW_EComponentCreationMethod SCW_UActorComponent::CreationMethod() const
{
	return static_cast<SCW_EComponentCreationMethod>(ActorComponent->CreationMethod);
}

void SCW_UActorComponent::DestroyComponent(bool bPromoteChildren/* = false*/)
{
	ActorComponent->DestroyComponent(bPromoteChildren);
}

ISCW_AActorPtr SCW_UActorComponent::GetOwner() const
{
	return FSourcifyCoreUEWrapper::Get().Wrap(*ActorComponent->GetOwner());
}

void SCW_UActorComponent::GetUCSModifiedProperties(set<ISCW_FPropertyConstPtr>& ModifiedProperties) const
{
	TSet<const FProperty*> OutModifiedProperties;
	ActorComponent->GetUCSModifiedProperties(OutModifiedProperties);
	for (const FProperty* Property : OutModifiedProperties)
	{
		ModifiedProperties.insert(FSourcifyCoreUEWrapper::Get().Wrap(*const_cast<FProperty*>(Property)));
	}
}

bool SCW_UActorComponent::IsCreatedByConstructionScript() const
{
	return ActorComponent->IsCreatedByConstructionScript();
}

bool SCW_UActorComponent::IsRegistered() const
{
	return ActorComponent->IsRegistered();
}

void SCW_UActorComponent::RegisterComponent()
{
	ActorComponent->RegisterComponent();
}

void SCW_UActorComponent::UnregisterComponent()
{
	ActorComponent->UnregisterComponent();
}

UActorComponent* SCW_UActorComponent::ToUActorComponent() const
{
	return ActorComponent;
}
