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

#pragma once

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


DECLARE_MULTICAST_DELEGATE_OneParam(FMissionCompleteSignature, class UMission*);

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

	UPROPERTY(EditDefaultsOnly, Instanced)
	TArray<UMissionGoal*> Goals;

	UPROPERTY(EditDefaultsOnly)
	int MoneyReward = 0;
	
	bool IsCompleted = false;

	TArray<FDelegateHandle> GoalUpdateHandles;

public:
	FMissionCompleteSignature OnComplete;

	void Init(ANakedDesireCharacter* PlayerCharacter);
	
	UFUNCTION(BlueprintPure)
	int GetMoneyReward() const
	{
		return MoneyReward;
	}
	
	UFUNCTION(BlueprintPure)
	TArray<UMissionGoal*> GetGoals() const
	{
		return Goals;
	}
	
	UFUNCTION(BlueprintPure)
	bool GetIsCompleted() const
	{
		return IsCompleted;
	}

protected:
	UPROPERTY()
	ANakedDesireCharacter* Player = nullptr;

private:
	UFUNCTION()
	void OnGoalUpdated(UMissionGoal* MissionGoal);

	void Complete();

	bool CheckGoals();
};
