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

#include "SCW_UBlackboardKeyType_Enum.h"
#include "BehaviorTree/Blackboard/BlackboardKeyType_Enum.h"
#include "SCW_UEnum.h"
#include "SourcifyCoreUEWrapperModule.h"

using namespace Sourcify;

SCW_UBlackboardKeyType_Enum::SCW_UBlackboardKeyType_Enum(UBlackboardKeyType_Enum* InBlackboardKeyType_Enum) : SCW_UBlackboardKeyType(InBlackboardKeyType_Enum), BlackboardKeyType_Enum(InBlackboardKeyType_Enum)
{

}

UBlackboardKeyType_Enum* SCW_UBlackboardKeyType_Enum::ToUBlackboardKeyType_Enum() const
{
	return BlackboardKeyType_Enum;
}

ISCW_UBlackboardKeyType_EnumPtr SCW_UBlackboardKeyType_Enum::ToUBlackboardKeyType_EnumPtr()
{
	return GetSharedThisAs<SCW_UBlackboardKeyType_Enum>();
}

ISCW_UBlackboardKeyType_EnumConstPtr SCW_UBlackboardKeyType_Enum::ToUBlackboardKeyType_EnumPtr() const
{
	return GetSharedThisAs<SCW_UBlackboardKeyType_Enum>();
}

wstring SCW_UBlackboardKeyType_Enum::GetEnumName() const
{
	return *BlackboardKeyType_Enum->EnumName;
}

void SCW_UBlackboardKeyType_Enum::SetEnumName(const wstring& EnumName)
{
	BlackboardKeyType_Enum->EnumName = EnumName.c_str();

	// Notify the editor that the property has changed in order to update the UI and EnumType
	FProperty* Property = FindFProperty<FProperty>(UBlackboardKeyType_Enum::StaticClass(), "EnumName");
	check(Property);
	FPropertyChangedEvent PropertyChangedEvent{ Property };
	// Have to cast to UObject to call PostEditChangeProperty because it's a protected method in UBlackboardKeyType_Enum
	CastChecked<UObject>(BlackboardKeyType_Enum)->PostEditChangeProperty(PropertyChangedEvent);
}

ISCW_UEnumPtr SCW_UBlackboardKeyType_Enum::GetEnumType() const
{
	return BlackboardKeyType_Enum->EnumType ? FSourcifyCoreUEWrapper::Get().Wrap(*BlackboardKeyType_Enum->EnumType) : nullptr;
}

void SCW_UBlackboardKeyType_Enum::SetEnumType(ISCW_UEnumPtr EnumType)
{
	BlackboardKeyType_Enum->EnumType = dynamic_pointer_cast<SCW_UEnum>(EnumType)->ToUEnum();
}