// Gravity Stomp Copyright Kevin Poretti

#pragma once

// UE includes
#include "CoreMinimal.h"
#include "GameFramework/PlayerState.h"

#include "GSPlayerState.generated.h"

/**
 *	Player state for a team deathmatch/free for all game mode
 */
UCLASS()
class GRAVITYSTOMPGAME_API AGSPlayerState : public APlayerState
{
	GENERATED_BODY()

public:
    AGSPlayerState();

	UFUNCTION(BlueprintPure)
	FORCEINLINE int32 GetTeamNum() const { return TeamNum; }

    void SetTeamNum(int32 InTeamNum);

	/**
	 *	Changes how this player is rendered depending on their team number
	 */
    void UpdateTeamColor();

	UFUNCTION(BlueprintPure)
	FORCEINLINE int32 GetNumKills() const { return NumKills; }

	FORCEINLINE void SetNumKills(int32 InNumKills) { NumKills = InNumKills; }

	FORCEINLINE void IncrementNumKills() { NumKills++; }

	UFUNCTION(BlueprintPure)
	FORCEINLINE int32 GetNumDeaths() const { return NumDeaths; }

	FORCEINLINE void SetNumDeaths(int32 InNumDeaths) { NumDeaths = InNumDeaths; }

	FORCEINLINE void IncrementNumDeaths() { NumDeaths++; }

	UFUNCTION(BlueprintPure)
	bool IsPlayerFriendly(const AGSPlayerState* PS) const;

	// Begin APlayerState interface
	/**
	 *	Clear kills and deaths
	 */
	virtual void Reset() override;

	/**
	 *	Updates team color on init
	 */
	virtual void ClientInitialize(class AController* InController) override;
	// End APlayerState interface

protected:
	UPROPERTY(Replicated)
	int32 NumKills;

	UPROPERTY(Replicated)
	int32 NumDeaths;

	UPROPERTY(ReplicatedUsing=OnRep_TeamNum)
	int32 TeamNum;

	UFUNCTION()
	void OnRep_TeamNum();
};
