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

#include "CoreMinimal.h"
#include "EdGraph/EdGraphNode.h"

#include "EdNode_InworldGraphEdge.generated.h"

class UInworldNodeAsset;
class UInworldEdgeAsset;
class UEdNode_InworldGraphNode;
class UEdGraph;

UCLASS(MinimalAPI)
class UEdNode_InworldGraphEdge : public UEdGraphNode
{
	GENERATED_BODY()

public:
	UEdNode_InworldGraphEdge();

	UPROPERTY()
	TObjectPtr<UEdGraph> Graph;

	UPROPERTY(VisibleAnywhere, Instanced, Category = "Inworld Graph")
	TObjectPtr<UInworldEdgeAsset> InworldGraphEdge;

	void SetEdge(UInworldEdgeAsset* Edge);

	virtual void AllocateDefaultPins() override;
	virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
	virtual void PinConnectionListChanged(UEdGraphPin* Pin) override;
	virtual void PrepareForCopying() override;

	virtual bool CanJumpToDefinition() const override;
	virtual void JumpToDefinition() const override;

	virtual UEdGraphPin* GetInputPin() const
	{
		return Pins[0];
	}
	virtual UEdGraphPin* GetOutputPin() const
	{
		return Pins[1];
	}

	UEdGraphPin* GetStartPin() const;
	UEdGraphPin* GetEndPin() const;

	void CreateConnections(UEdNode_InworldGraphNode* Start, UEdNode_InworldGraphNode* End);

	UEdNode_InworldGraphNode* GetStartNode();
	UEdNode_InworldGraphNode* GetEndNode();

	void SetRequired(bool IsRequired);
	void SetEdgeType(UClass* InEdgeType);
};
