// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Subsystems/WorldSubsystem.h"
#include "RecorderSession.generated.h"

/**
* Groups every recording made in a single PIE / game session under one subfolder.
* The timestamp is captured when the subsystem is initialized, but the subfolder
* is not created on disk until the first recording actually asks for it.
*/
UCLASS()
class ROOTMOTIONRECORDER_API URecorderSession : public UWorldSubsystem
{
	GENERATED_BODY()

public:
	/** Timestamp captured at session start, used as the subfolder name. */
	UFUNCTION(BlueprintPure, Category = "Root Motion Recorder")
	FString GetSessionTimestamp() const { return SessionTimestamp; }

	/**
	* Returns "<Root>/Session_<timestamp>/" and creates it on disk the first time it's called.
	* Subsequent calls return the cached path without touching the filesystem.
	*/
	FString GetOrCreateSessionDirectory(const FString& Root);

protected:
	virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
	virtual void Initialize(FSubsystemCollectionBase& Collection) override;

private:
	FString SessionTimestamp;
	FString CachedSessionDirectory;
	bool bDirectoryCreated = false;
};
