// Fill out your copyright notice in the Description page of Project Settings.

#include "OrdersComponent.h"


UOrdersComponent::UOrdersComponent()
{
	PrimaryComponentTick.bCanEverTick = false;
}

void UOrdersComponent::AddOrder(UCoffeeFilter* Filter, ANpcPawn* InNpcPawn)
{
	FOrderData OrderData;
	OrderData.Filter = Filter;
	OrderData.NpcPawn = InNpcPawn;
	OrderList.Add(OrderData);
}


UCoffeeFilter* UOrdersComponent::GetOrderForNpc(ANpcPawn* InNpcPawn) const
{
	if (!InNpcPawn) return nullptr;
	
	const FOrderData* FoundOrderData = OrderList.FindByPredicate([InNpcPawn](const FOrderData& OrderData)
	{
		return OrderData.NpcPawn == InNpcPawn;
	});
	
	if (FoundOrderData)
	{
		return FoundOrderData->Filter;
	}
	
	return nullptr;
}

void UOrdersComponent::BeginPlay()
{
	Super::BeginPlay();
	
}


