// © 2025 Naked People Team. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Subsystems/GameInstanceSubsystem.h"
#include "AudioSettingsSubsystem.generated.h"

class UNakedDesireUserSettings;

// Applies the master / music / SFX volume settings to SoundClasses via the configured
// SoundMix (UNakedDesireGameInstance::AudioConfig). Re-applies whenever settings change
// and on each world start so volumes survive level travel.
UCLASS()
class NAKEDDESIRE_API UAudioSettingsSubsystem : public UGameInstanceSubsystem
{
	GENERATED_BODY()

public:
	virtual void Initialize(FSubsystemCollectionBase& Collection) override;
	virtual void Deinitialize() override;

	// Pushes the current settings volumes onto the configured SoundMix. Safe to call any time.
	void ApplyVolumes();

private:
	UFUNCTION()
	void HandleSettingsChanged(UNakedDesireUserSettings* Settings);

	void HandleMapLoaded(UWorld* LoadedWorld);

	FDelegateHandle MapLoadHandle;
};