// Copyright Pacificao. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "AgrarianSaveGame.h"
#include "AgrarianPersistentActorComponent.generated.h"

UCLASS(ClassGroup = (Agrarian), BlueprintType, Blueprintable, meta = (BlueprintSpawnableComponent))
class UAgrarianPersistentActorComponent : public UActorComponent
{
	GENERATED_BODY()

public:
	UAgrarianPersistentActorComponent();

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Persistence")
	FName ActorTypeId = NAME_None;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Persistence")
	bool bSaveTransform = true;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Persistence")
	TMap<FName, FString> StringState;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Persistence")
	TMap<FName, float> NumberState;

	UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence")
	bool IsSaveable() const;

	UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence")
	FAgrarianSavedWorldActor CaptureSaveState() const;

	UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence")
	void ApplySaveState(const FAgrarianSavedWorldActor& SavedActor);
};
