// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.

#include "Events/ComboActionDelegateBinding.h"

#include "EnhancedInputComponent.h"
#include "Components/ComboManagerComponent.h"
#include "GameFramework/PlayerController.h"

#include UE_INLINE_GENERATED_CPP_BY_NAME(ComboActionDelegateBinding)


UComboActionDelegateBinding::UComboActionDelegateBinding(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
}

void UComboActionDelegateBinding::BindDynamicDelegates(UObject *InInstance) const
{
	APlayerController *PlayerController = Cast<APlayerController>(InInstance);
	if (!PlayerController)
	{
		return;
	}

	if (UComboManagerComponent *ComboManager = PlayerController->GetComponentByClass<UComboManagerComponent>())
	{
		for (const FBlueprintComboActionBinding &Binding : this->ComboActionDelegateBindings)
		{
			ComboManager->BindAction(PlayerController, Binding.FunctionNameToBind, Binding.ComboAction, Binding.TriggerEvent);
		}
	}
}
