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

#pragma once

#include "CoreMinimal.h"
#include "Graph/InworldCharacterData.h"
#include "Graph/InworldData.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Templates/Casts.h"
#include "UObject/UnrealType.h"

#include "InworldCharacterBFL.generated.h"

/**
 * @class UInworldCharacterBFL
 * @brief Blueprint Function Library for Inworld Character utility functions.
 *
 * This class provides Blueprint-accessible utility functions for working with
 * Inworld character data structures, including break functions for complex
 * data types like relations and emotions.
 */
UCLASS()
class INWORLDCHARACTER_API UInworldCharacterBFL : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
	/**
	 * @brief Breaks down an Inworld relation structure into its individual components.
	 *
	 * This function extracts all relationship values and the computed label from
	 * an FInworldRelation structure, making them accessible as separate variables
	 * in Blueprint. Useful for displaying relationship information in UI or for
	 * conditional logic based on specific relationship values.
	 *
	 * @param Relation The relation structure to break down
	 * @param Trust Output value for the trust component (-100 to 100)
	 * @param Respect Output value for the respect component (-100 to 100)
	 * @param Familiar Output value for the familiarity component (0 to 100)
	 * @param Flirtatious Output value for the flirtatious component (0 to 100)
	 * @param Attraction Output value for the attraction component (-100 to 100)
	 * @param Label Output enum value for the computed relationship label
	 * @param LabelString Output string representation of the relationship label
	 */
	UFUNCTION(BlueprintPure, Category = "Inworld|Data")
	static void BreakInworldRelation(const FInworldRelation& Relation, int32& Trust, int32& Respect, int32& Familiar,
		int32& Flirtatious, int32& Attraction, EInworldRelationLabel& Label, FString& LabelString)
	{
		Trust = Relation.Trust;
		Respect = Relation.Respect;
		Familiar = Relation.Familiar;
		Flirtatious = Relation.Flirtatious;
		Attraction = Relation.Attraction;
		Label = Relation.GetLabel();
		LabelString = Relation.GetLabelString();
	}

	/**
	 * @brief Breaks down an Inworld emotion structure into its individual components.
	 *
	 * This function extracts the emotion label and its string representation from
	 * an FInworldEmotion structure, making them accessible as separate variables
	 * in Blueprint. Useful for emotion-based UI display or gameplay logic that
	 * responds to character emotional states.
	 *
	 * @param Emotion The emotion structure to break down
	 * @param Label Output enum value for the emotion label
	 * @param LabelString Output string representation of the emotion label
	 */
	UFUNCTION(BlueprintPure, Category = "Inworld|Data")
	static void BreakInworldEmotion(const FInworldEmotion& Emotion, EInworldEmotionLabel& Label, FString& LabelString)
	{
		Label = Emotion.Label;
		LabelString = Emotion.GetLabelString();
	}
};
