// Gravity Stomp Copyright Kevin Poretti

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "InputActionValue.h"
#include "GSCharacter.generated.h"

USTRUCT(BlueprintType)
struct FPlayerMaterial
{
	GENERATED_BODY()

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
	UMaterialInstance* TorsoMaterial;

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
	UMaterialInstance* HeadLegsMaterial;
};

UCLASS(config=Game)
class AGSCharacter : public ACharacter
{
	GENERATED_BODY()

	/** MappingContext */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
	class UInputMappingContext* DefaultMappingContext;

	/** Move Input Action */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
	class UInputAction* MoveAction;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
	class UInputAction* ChangeGravityAction;

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Player Materials", meta = (AllowPrivateAccess = "true"))
	TArray<FPlayerMaterial> PlayerMaterials;

public:
	AGSCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());

	void ChangeTeamColor(bool bIsPlayerFriendly);

	UFUNCTION(BlueprintImplementableEvent)
	void OnGravityDirectionChanged(FVector NewUpDir);

protected:

	/** Called for movement input */
	void Move(const FInputActionValue& Value);

	UPROPERTY(BlueprintReadWrite, Category = "Player Actions Flags")
	bool bCanChangeGravity = true;

	/** Called when the player changes the gravity direction */
	void ChangeGravityDirection(const FInputActionValue& Value);

public:
	virtual void PawnClientRestart() override;

	virtual void PossessedBy(AController* NewController) override;

protected:
	// APawn interface
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
	
	// To add mapping context
	virtual void BeginPlay();
};

