// Copyright Pacificao. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "Subsystems/GameInstanceSubsystem.h" #include "AgrarianPersistenceSubsystem.generated.h" class UAgrarianSaveGame; class UAgrarianPersistentActorComponent; UCLASS() class UAgrarianPersistenceSubsystem : public UGameInstanceSubsystem { GENERATED_BODY() public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Persistence") FString DefaultSlotName = TEXT("AgrarianMVP"); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Persistence") int32 UserIndex = 0; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Persistence") TMap> WorldActorClassRegistry; UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence") UAgrarianSaveGame* CreateEmptySave() const; UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence") UAgrarianSaveGame* LoadOrCreateSave() const; UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence") bool WriteSave(UAgrarianSaveGame* SaveGame) const; UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence") bool DoesSaveExist() const; UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence") void RegisterWorldActorClass(FName ActorTypeId, TSubclassOf ActorClass); UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence") int32 CaptureWorldActors(UAgrarianSaveGame* SaveGame) const; UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence") int32 RestoreWorldActors(const UAgrarianSaveGame* SaveGame, bool bClearExistingActors = true) const; UFUNCTION(BlueprintCallable, Category = "Agrarian|Persistence") bool SaveCurrentWorld() const; protected: void FindPersistentComponents(TArray& OutComponents) const; };