#pragma once

#include "CoreMinimal.h"
#include "WingHandler.h"
#include "WingFetcher.h"
#include "WingServer.h"
#include "WingActorComponent.h"
#include "ActorComponent_Remove.generated.h"


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

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

public:
	UPROPERTY(EditAnywhere, meta=(Description="Path to the component (e.g. '/Game/MyBP,component:MyComp')"))
	FString Component;

	virtual void Register() override
	{
		UWingServer::AddHandler(this,
			TEXT("Remove a component from a Blueprint's SimpleConstructionScript."));
	}
	virtual void Handle() override
	{
		WingFetcher F;
		UWingComponentReference* CompRef = F.Walk(Component).Cast<UWingComponentReference>();
		if (!CompRef) return;

		if (!CompRef->DeleteComponent()) return;

		UWingServer::Printf(TEXT("Removed component.\n"));
	}
};
