
#pragma once

#include "K2Node.h"

#include "LuprexK2Node.generated.h"

//
// Base class for Luprex K2 nodes, adding common utility functions.
//
UCLASS(Abstract, MinimalAPI)
class UlxK2Node : public UK2Node
{
	GENERATED_BODY()

protected:
	/** Add a single-char prefix to a pin name, e.g. AddPrefix("foo", 'A') -> "A:foo" */
	static FName AddPrefix(const FString &Name, char Prefix);

	/** Check if a pin name has a given single-char prefix. */
	static bool HasPrefix(FName Name, char Prefix);

	/** Strip a single-char prefix from a pin name, returning the original name if no prefix is found. */
	static FName RemovePrefix(FName Name);

	/** Convert a UFunction property to a pin type. Returns a default (wildcard) pin type on failure. */
	static FEdGraphPinType PropertyToPinType(const FProperty *Property);

	/** Set a fatal error message on this node. */
	void SetErrorMsg(const FString &Msg);

	/** Spawn an intermediate UK2Node_CallFunction during node expansion. */
	class UK2Node_CallFunction* MakeCallFunctionNode(class FKismetCompilerContext &CompilerContext, UEdGraph *SourceGraph, UFunction *Func);

	/** Link ExecOut to NextNode's exec pin, return NextNode's output exec pin (by name). */
	static UEdGraphPin* ChainExecPin(UEdGraphPin *ExecOut, UK2Node *NextNode, const TCHAR *OutputPinName);
};
