#pragma once

#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "UObject/StrongObjectPtr.h"
#include "Dom/JsonObject.h"
#include "WingHandler.generated.h"

// Marker struct for handler parameters that accept a JSON object.
// PopulateFromJson stashes the actual JSON object into the Json field.
USTRUCT()
struct FWingJsonObject
{
	GENERATED_BODY()
	TSharedPtr<FJsonObject> Json;
};

// Marker struct for handler parameters that accept a JSON array.
// PopulateFromJson stashes the actual JSON array into the Array field.
USTRUCT()
struct FWingJsonArray
{
	GENERATED_BODY()
	TArray<TSharedPtr<FJsonValue>> Array;
};

UENUM()
enum class EWingHandlerKind
{
	Normal,
	Create
};

USTRUCT()
struct FWingHandlerConfig
{
	GENERATED_BODY()
	FString Name;
	FString Documentation;
	TStrongObjectPtr<UClass> Class;
	TStrongObjectPtr<UObject> Config;
	EWingHandlerKind Kind = EWingHandlerKind::Normal;
};

UCLASS(Abstract)
class UEWINGMAN_API UWingHandler : public UObject
{
	GENERATED_BODY()

public:
	// Register this handler's commands with the server.
	virtual void Register() PURE_VIRTUAL(UWingHandler::Register);

	// Called after parameter fields have been populated from JSON.
	virtual void Handle() {}

	// The configuration object.
	UObject *ConfigurationObject;
};
