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

#pragma once

#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "MissionGoal.generated.h"

class ANakedDesireCharacter;
class UMissionGoal;
class UGoalRestriction;

DECLARE_MULTICAST_DELEGATE_OneParam(FGoalUpdateSignature, UMissionGoal*);

/**
 * 
 */
UCLASS(EditInlineNew, BlueprintType)
class NAKEDDESIRE_API UMissionGoal : public UObject
{
	GENERATED_BODY()

	UPROPERTY(EditDefaultsOnly, Instanced)
	TArray<UGoalRestriction*> Restrictions;

	TArray<FDelegateHandle> RestrictionUpdateHandles;

public:
	virtual void Init(ANakedDesireCharacter* PlayerCharacter);
	virtual void Complete();

	UFUNCTION(BlueprintPure)
	bool GetIsCompleted() const
	{
		return IsCompleted;
	}

	UFUNCTION(BlueprintPure)
	TArray<UGoalRestriction*> GetRestrictions() const
	{
		return Restrictions;
	}

	FGoalUpdateSignature OnUpdate;

	bool CheckRestrictions();

	UFUNCTION(BlueprintPure)
	virtual FText GetDescription() const;

protected:
	UPROPERTY()
	ANakedDesireCharacter* Player = nullptr;

	virtual	void OnRestrictionUpdated(UGoalRestriction* Restriction);
	
	bool IsCompleted = false;
};
