// Project Lab - NHTV Igad

#pragma once

#include "GameFramework/Pawn.h"
#include "DefaultPlayer.generated.h"


UCLASS(Config=Game)
class UNREALPROJECT_API ADefaultPlayer : public APawn
{
	GENERATED_BODY()

public:
	ADefaultPlayer();

	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
	virtual void Tick(float DeltaSeconds) override;
	
	// Resets the respawn timer
	void OnSpawn();

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
	class UCameraComponent* camera;

	UPROPERTY(ReplicatedUsing=m_OnRep_RespawnTimer, BlueprintReadOnly, Category = "RespawnTimer")
	float respawnTimer;
	UPROPERTY(Replicated, BlueprintReadOnly, Category = "RespawnTimer")
	bool isRespawning;

	UPROPERTY(Config, BlueprintReadOnly)
	float respawnDelay;

	DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnRespawnTimerSet, float, time);
	UPROPERTY(BlueprintAssignable)
	FOnRespawnTimerSet onRespawnTimerSet;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
	class USpringArmComponent* CameraBoom;
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
	class UCameraComponent* TopDownCamera;

private:
	UFUNCTION()
	void m_OnRep_RespawnTimer();
};
