#pragma once

#include "CoreMinimal.h"
#include "WingServer.h"
#include "WingBasics.h"
#include "WingFetcher.h"
#include "EdGraph/EdGraph.h"
#include "EdGraph/EdGraphNode.h"
#include "GraphNode_SetPosition.generated.h"


UCLASS()
class UWing_GraphNode_SetPosition : public UWingHandler
{
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, meta=(Description="Target node"))
	FString NodePath;

	UPROPERTY(EditAnywhere, meta=(Description="New X position"))
	int32 X = 0;

	UPROPERTY(EditAnywhere, meta=(Description="New Y position"))
	int32 Y = 0;

	virtual void Register() override
	{
		UWingServer::AddHandler(this,
			TEXT("Reposition a node in a Blueprint graph."));
	}
	virtual void Handle() override
	{
		WingFetcher F(WingOut::Stdout);
		UEdGraphNode* FoundNode = F.Walk(NodePath).Cast<UEdGraphNode>();
		if (!FoundNode) return;

		FoundNode->NodePosX = X;
		FoundNode->NodePosY = Y;
		WingOut::Stdout.Print(TEXT("Moved node.\n"));
	}
};
