/**
 * Copyright 2022-2025 Theai, Inc. dba Inworld AI
 */

#include "Components/InworldSimplePlayerComponent.h"

#include "Components/InworldSimpleCharacterComponent.h"
#include "InworldCharacter.h"

void UInworldSimplePlayerComponent::OnAudioCapture(
	const UInworldAudioCapture* AudioCapture, const FInworldData_Audio& AudioData, bool VAD)
{
	if (IsValid(ConversationTarget.GetObject()) && VAD)
	{
		IInworldConversationTarget::Execute_Interrupt(ConversationTarget.GetObject());
	}
	Super::OnAudioCapture(AudioCapture, AudioData, VAD);
}

void UInworldSimplePlayerComponent::SendMessage(const FInworldDataHandle& Message)
{
	if (IsValid(ConversationTarget.GetObject()))
	{
		IInworldConversationTarget::Execute_Interrupt(ConversationTarget.GetObject());
		IInworldConversationTarget::Execute_SendPlayerMessage(ConversationTarget.GetObject(), Message, PlayerProfile);
	}
	else
	{
		UE_LOG(LogInworldCharacter, Warning,
			TEXT("UInworldSimplePlayerComponent::SendMessage - failed to send message."
				 " Invalid target conversation."))
	}
}
