// Copyright (c) Microsoft Corporation. 
// Licensed under the MIT license.

#pragma once

#include "Components/InstancedStaticMeshComponent.h"
#include "Components/BillboardComponent.h"
#include "NavigationSystem.h"
#include "GameFramework/Info.h"
#include "NavSysVisibilityDataVisualizer.generated.h"

UCLASS(MinimalAPI, hidecategories = (Input, Actor, Rendering, Replication, LOD, Cooking, Collision))
class ASimplygonVisibilitySamplerVisualizer : public AActor
{
    GENERATED_BODY()

public:

#if WITH_EDITORONLY_DATA
	UPROPERTY(EditAnywhere, Category = NavMeshSampling)
	int32 NumOfSamples;

	UPROPERTY(EditAnywhere, Category = NavMeshSampling)
	float MinZ;

	UPROPERTY(EditAnywhere, Category = NavMeshSampling)
	float MaxZ;
#endif

public:
    	
	ASimplygonVisibilitySamplerVisualizer(const FObjectInitializer& InInitializer);

#if WITH_EDITOR
	virtual void PostEditMove(bool bFinished);
	virtual void PostLoad();
#endif

	void UpdateInstances();
	void ClearSamples();
	void Build();
	void ToggleInEditor();


#if WITH_EDITORONLY_DATA
	/** Returns SpriteComponent subobject **/
	UBillboardComponent* GetSpriteComponent() const;
#endif

private:
	void UpdateMeshReductionSamples();
private:

#if WITH_EDITORONLY_DATA
	UPROPERTY()
	TArray<FVector> SampleLocations;
	
	//Each sampling point is a Instanced Static Mesh using a sphere mesh
	UPROPERTY()
	TObjectPtr<UInstancedStaticMeshComponent> Component;

	/** Billboard Component displayed in editor */
	UPROPERTY()
	TObjectPtr<UBillboardComponent> SpriteComponent;
#endif
  
};
