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

#pragma once

#include "CoreMinimal.h"
#include "CoverageObjectiveBase.h"
#include "TravelObjectiveBase.generated.h"

// Shared base for "cover RequiredMeters while <condition> holds" objectives. Owns the distance-sampling
// timer; per-sample movement is clamped so a teleport / streaming jump can't satisfy it. Subclasses only
// declare what counts via DoesSampleCount() (e.g. naked + running, or a part revealing while walking).
UCLASS(Abstract)
class NAKEDDESIRE_API UTravelObjectiveBase : public UCoverageObjectiveBase
{
	GENERATED_BODY()

public:
	virtual float GetProgress() const override;

protected:
	virtual void OnActivate() override;
	virtual void OnDeactivate() override;

	// Whether the latest movement sample should accrue toward the distance (constraints are ANDed on top).
	virtual bool DoesSampleCount() const { return false; }

	UPROPERTY(EditDefaultsOnly, meta = (ClampMin = 1))
	float RequiredMeters = 50.0f;

private:
	void SampleDistance();

	float AccumulatedCm = 0.0f;
	FVector LastLocation = FVector::ZeroVector;
	FTimerHandle SampleTimer;
};