// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Layout/ComboActionGraphLayoutStrategy.h"

#include "ComboActionTreeSolveLayoutStrategy.generated.h"


/**
 * 
 */
UCLASS()
class COMBOINPUTEDITOR_API UComboActionTreeSolveLayoutStrategy : public UComboActionGraphLayoutStrategy
{
	GENERATED_BODY()

	virtual void Layout(UEdGraph *InEdGraph) override;

protected:
	void InitPass(UComboActionGraphNode *RootNode, const FVector2D &Anchor);
	bool ResolveConflictPass(UComboActionGraphNode *Node);

	bool ResolveConflict(UComboActionGraphNode *LRoot, UComboActionGraphNode *RRoot);

	void GetLeftContour(UComboActionGraphNode *RootNode, int32 Level, TArray<UEdComboActionGraphNode*>& Contour);
	void GetRightContour(UComboActionGraphNode *RootNode, int32 Level, TArray<UEdComboActionGraphNode*>& Contour);
	
	void ShiftSubTree(UComboActionGraphNode* RootNode, const FVector2D& Offset);

	void UpdateParentNodePosition(UComboActionGraphNode* RootNode);
};
