// Multiplayer By Caleb

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "GenericTeamAgentInterface.h"
#include "CPlayerController.generated.h"

class UGameplayWidget;
class ACPlayerCharacter;

UCLASS()
class CRUNCH_API ACPlayerController : public APlayerController, public IGenericTeamAgentInterface
{
	GENERATED_BODY()

public:
	virtual void OnPossess(APawn* InPawn) override;
	virtual void AcknowledgePossession(APawn* P) override;

	virtual FGenericTeamId GetGenericTeamId() const override;
	virtual void SetGenericTeamId(const FGenericTeamId& NewTeamID) override;
	virtual void GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const override;

private:
	void SpawnGameplayWidget();

	UPROPERTY()
	TObjectPtr<ACPlayerCharacter> CPlayerCharacter;
	
	UPROPERTY(EditDefaultsOnly, Category= "UI")
	TSubclassOf<UGameplayWidget> GameplayWidgetClass;
	
	UPROPERTY()
	TObjectPtr<UGameplayWidget> GameplayWidget;
	
	UPROPERTY(Replicated)
	FGenericTeamId TeamId;
	
};
